Skip to content

Commit

Permalink
Fix ctrl+c by using -it
Browse files Browse the repository at this point in the history
Without `-it` ctrl+c won't work, TESTED BY ME ON windows.

Issue resolved at link - moby/moby#2838 (comment)
  • Loading branch information
sahilrajput03 committed Nov 25, 2020
1 parent 4e004b1 commit da1f8d7
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions pages/part1/part1.md
Original file line number Diff line number Diff line change
Expand Up @@ -262,10 +262,12 @@ We'll look more into the Ubuntu image in part 3.

Let's run a container in the background:

`docker run -d --name looper ubuntu:16.04 sh -c 'while true; do date; sleep 1; done'`
`docker run -d -it --name looper ubuntu:16.04 sh -c 'while true; do date; sleep 1; done'`

- The first part, `docker run -d`, should be familiar by now.

- Followed by `-it` is short for `-i` and `-t` where `-i` is "interactive, connect STDIN" and `-t` "allocate a pseudo-TTY". Or to put it more simply, `-it` allows you to interact with the container by using the command line.

- Because we ran the container with `--name looper`, we can now reference it easily.

- The image is `ubuntu:16.04` and what follows it is the command given to the container.
Expand Down Expand Up @@ -325,7 +327,7 @@ $ docker exec -it looper bash
root 387 0.0 0.0 36836 2900 pts/0 R+ 10:34 0:00 ps aux
```

In our command `-it` is short for `-i` and `-t` where `-i` is "interactive, connect STDIN" and `-t` "allocate a pseudo-TTY". Or to put it more simply, `-it` allows you to interact with the container by using the command line. From the `ps aux` listing we can see that our `bash` process got PID (process ID) of 300.
From the `ps aux` listing we can see that our `bash` process got PID (process ID) of 300.

Now that we're inside the container it behaves as you'd expect from ubuntu, and we can terminate the container by killing the process with `kill 1`, or exit the container with `exit` and then either kill or stop the container.

Expand Down

0 comments on commit da1f8d7

Please sign in to comment.