"docker run" cannot be killed with ctrl+c

Can the tutorial be updated? The following is incorrect:

"
Run the app, mapping your machine’s port 4000 to the container’s published port 80 using -p:

docker run -p 4000:80 friendlyhello

Hit CTRL+C in your terminal to quit.

Now let’s run the app in the background, in detached mode:

docker run -d -p 4000:80 friendlyhello

"
Actual result: Ctrl+c detaches the friendlyhello process and returns control to the terminal. When you try to run the next “docker run…” command an error returns because there is already a process using the port 80.

Adding the flags -t and -i will allow Ctrl-c to work as suggested: [(source)] (https://github.com/moby/moby/issues/2838#issuecomment-29205965)

docker run -t -i -p 4000:80 friendlyhello

4 Likes