Docker: kill / stop / restart container, save options?

I run a specific docker image for the first time:

docker run [OPTIONS] image [CMD]

Some of the options I supply include --link

(communication with other containers) and -p

(expose ports)

I noticed that if I kill this container and just do it docker start <container-id>

, Docker will honor all the parameters I specified during the command run

, including links and ports.

Is this behavior explicitly documented and can I always count on a command start

to reincarnate the container with all the parameters I provided in the command run

?


Also, I noticed that destroying / starting a container linked to another container automatically updates the contents of the container /etc/hosts

:

A--(link)-->B

(A has an entry in /etc/hosts

for B)

If I am kill

B, B will usually get a new IP address. I notice that when I am start

B, the entry for B in file A is /etc/hosts

automatically updated ... This is very nice.

I read here that --link

doesn't handle container reloads ... Has this been updated recently? If not, why am I seeing this behavior?

(I'm using Docker version 1.7.1 build 786b29d)

+3


source to share


1 answer


Yes, everything works as you describe :)

You can rely on behavior docker start

as it doesn't really "reincarnate" your container; it was always on disk, only stopped. It will also save any changes to files, but changes to RAM such as process state will be lost. (Note that kill

does not delete the container, it just stops it with SIGKILL

, not SIGTERM

, use docker rm

to actually delete the container).



Links are now updated when container changes IP due to reboot. This is not true. However, that's not what the linked question is about - they are discussing if you can replace the container with a new container with the same name and still work with links. This is not possible, but this scenario will be covered by the new networking features and "service" objects that are currently in the experimental Docker channel.

+2


source







All Articles