Skip to content

Commit

Permalink
Merge pull request #89 from sahilrajput03/patch-1
Browse files Browse the repository at this point in the history
Fix ctrl+c by using -it
  • Loading branch information
Jakousa authored Nov 26, 2020
2 parents b7a20a5 + f1742a4 commit cc1856e
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 cc1856e

Please sign in to comment.