Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Container exits immediately in detached mode

Tags:

docker

I suppose a docker container run at background could be held alive. But the truth is container always exists immediately in detached mode.

docker run -d busybox
ps -a
CONTAINER ID        IMAGE                      COMMAND             CREATED             STATUS                      PORTS               NAMES
42d4db933e8a        busybox:latest             /bin/sh             11 seconds ago      Exited (0) 11 seconds ago                       sharp_sammet

How to persist this session without faking doing some loop jobs to prevent being closed.

like image 569
Stefani Demar Avatar asked Oct 18 '25 18:10

Stefani Demar


1 Answers

Just simply run docker run -dt busybox instead. The option "t" means tty(stdio/stdout) will be held and thing works as you expected.

like image 189
John Hua Avatar answered Oct 20 '25 13:10

John Hua



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!