Reputation: 1148
The docker docs just say this command will "restart one or more containers". But that isn't clear enough for me.
Is this effectively;
if (container.isRunning) {
docker stop container
docker start container
} else {
docker start container
}
?
ie. if the container isn't running, it will be docker start
'ed, and if it is it will be stopped and then started again?
Upvotes: 1
Views: 57
Reputation: 26374
Effectively, yes, with some additional considerations to care for interactions between different features such as to avoid deleting a container started with AutoRemove --rm
(normally they are autoremoved on stop but should not be on restart)
See the implementation here: https://github.com/moby/moby/blob/de7172b600d5fbdf6d8861116bf5491d17d609be/daemon/restart.go#L37
Upvotes: 4