How to save ubuntu image?

I am trying to start a container with the following command

sudo docker run ubuntu

after that i checked with

sudo docker ps -a

found that the container has already exited

why is he coming out?

How can I save it in backgroud without specifying -it and attach it to the requirement?

+4
source share
4 answers

Having decided for himself, an elegant way to keep the container running and waiting for further attach or exec is as follows (to keep STDIN open with the -i option)

sudo docker -i -d run ubuntu
+10
source

You need to run the application with the docker launch command, which will not work.

Example:

docker run -d --entrypoint '/bin/bash cat' ubuntu

+1
source

(from docker run --help)

docker run [OPTIONS] IMAGE [COMMAND] [ARG...]

.

https://registry.hub.docker.com/

, nginx,

https://hub.docker.com/_/nginx/

docker run --name some-nginx -v /some/nginx.conf:/etc/nginx/nginx.conf:ro -d nginx

https://github.com/nginxinc/docker-nginx/blob/7f3ef0927ec619d20181e677c97f991df0d7d446/Dockerfile

you will notice that the last line of the docker file

CMD ["nginx", "-g", "daemon off;"]

This means that when you run the nginx docker image, the nginx action is implied.

0
source

If you want the container not to exist, you must use the argument -d

So it looks like this:

docker run -d ubuntu
0
source

Source: https://habr.com/ru/post/1607290/


All Articles