Reputation: 25282
unless-stopped
Similar to always, except that when the container is stopped (manually or otherwise), it is not restarted even after Docker daemon restarts.
Ok. I understand what manually
means: docker stop container_name
. But what or otherwise
stands for?
Upvotes: 0
Views: 665
Reputation: 160063
The paragraph after the table clarifies (emphasis mine):
configures it to always restart unless it is explicitly stopped or Docker is restarted.
One example is if the host reboots. Containers will be implicitly stopped (the container metadata and filesystems exist but the main container process does not), and at this point restart policies apply as well.
Event | no |
on-failure |
unless-stopped |
always |
---|---|---|---|---|
docker stop |
Stopped | Stopped | Stopped | Stopped |
Host reboot | Stopped | Stopped | Stopped | Restarted |
Process exits (code=0) | Stopped | Stopped | Restarted | Restarted |
Process exits (code≠0) | Stopped | Restarted | Restarted | Restarted |
The documentation hints that this also applies if the Docker daemon is restarted, but this is a somewhat unusual case. My memory is that this event frequently seems to not affect running containers at all.
Upvotes: 2