Does the Docker container restart the “remember” startup arguments?

I launched the Docker container using a very long list of arguments (8 lines):

docker run -d -p 5000:5000 --restart=always --name registry \ -v `pwd`/auth:/auth \ -e "REGISTRY_AUTH_HTPASSWD_REALM=Registry Realm" \ -e REGISTRY_AUTH_HTPASSWD_PATH=/auth/htpasswd \ -v `pwd`/certs:/certs \ -e REGISTRY_HTTP_TLS_CERTIFICATE=/certs/registry.crt \ -e REGISTRY_HTTP_TLS_KEY=/certs/registry.key \ registry:2 

I confirmed that this works through docker ps :

 CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES ff9c654bfc39 registry:2 "/bin/registry /etc/d" 2 days ago Up 13 minutes 0.0.0.0:5000->5000/tcp registry 

Then I stopped this container through docker stop ff9c654bfc39 . Then I tried to restart the container by issuing the same docker run ... (8 liner), as I did the first time:

 Error response from daemon: Conflict. The name "registry" is already in use by container ff9c654bfc39. You have to delete (or rename) that container to be able to reuse that name. 

So, I just tried docker restart ff9c654bfc39 and it seemed to work, but I'm not 100% sure that Docker “remembered” my 8 lines of arguments when I initially started the container. Any ideas on whether he remembers? If not, what is the correct restart command to include these 8 lines?

+7
docker
source share
1 answer

As @gabowsky explains in the comments, yes, Docker will remember.

Using start , stop and restart will NOT destroy the container, therefore, remembering everything, including data (even between rebooting the host). What stop means is to stop the process running inside the container. It's all.

In addition, Docker saves the entire context, variables, etc. in the internal format. You do not need to specify command line arguments again. To find out what Docker knows about your container, you can run docker inspect .

On the contrary, rm destroy everything, including the data that has not been saved, and the container will need to be recreated again (give arguments again this time).

As a final note, you should use names instead of SHA1 when accessing containers on the command line

+5
source share

All Articles