Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to quit in teminal when running docket in terminal mode

Tags:

docker

I am running

docker run --rm -t -p 3000:3000 --name node-app foo/node

How do i quit ctrl + C does not seem to work. Currently I have to open another terminal to stop the docker. Is this the only option?

like image 957
kumar Avatar asked Dec 11 '25 23:12

kumar


1 Answers

If you use -t and -i then Control-C will terminate the container. When using -i with -t then you have to use Control-P Control-Q to detach without terminating

Test 1:

$ ID=$(sudo docker run -t -d ubuntu /usr/bin/top -b)
$ sudo docker attach $ID
Control-C
$ sudo docker ps

The container is still listed.

Test 2:

$ ID=$(sudo docker run -t -i -d ubuntu /usr/bin/top -b)
$ sudo docker attach $ID
Control-C
$ sudo docker ps

The container is terminated

like image 145
user2039152 Avatar answered Dec 13 '25 12:12

user2039152



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!