If command "docker run ubuntu bash" the container won't last.
but if I command "docker run -it ubuntu bash" the container will make a pseudo-tty and keep this container alive.
my question is is there any way I can make a Dockerfile for building an image based on ubuntu/centos then I just need to command "docker run my-image" and the container will last.
apologize for my poor english, I don't know if my question is clear enough. thanks for any response
There are three ways to run containers:
docker run ubuntu ls /
-it
, like docker run -it ubuntu bash
-d
, like docker run -d ubuntu:14.04 ping localhost
Docker keeps the container running as long as there is an active process in the container. The first container exits when the ls
command completes. The second container will exit when you exit the bash session. The third container will stay running as long as the ping
process keeps running (note that ping
has been removed from the recent Ubuntu images, which is why the example specifies 14.04).
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.