LinuxCommandLibrary
GitHubF-DroidGoogle Play Store

docker-container-restart

Restart one or more Docker containers

TLDR

Restart a container
$ docker container restart mycontainer
copy
Restart several containers
$ docker container restart container1 container2
copy
Wait longer before SIGKILL
$ docker container restart --timeout 30 mycontainer
copy
Send a specific stop signal
$ docker container restart --signal SIGINT mycontainer
copy

SYNOPSIS

docker container restart [options] container [container...]

DESCRIPTION

docker container restart stops each named container and then starts it again. The stop step sends `SIGTERM` (or the signal from --signal, or the container's configured stop signal) and waits for the timeout. If the process is still running when the timeout ends, `SIGKILL` is sent. The start step is the same as docker container start.The alias docker restart is equivalent. The default timeout is 10 seconds on Linux unless the container was created with a different stop timeout.

PARAMETERS

-t, --timeout seconds

Seconds to wait after the stop signal before `SIGKILL`. `-1` waits until the container exits.
-s, --signal signal
Signal to send when stopping the container, such as `SIGTERM` or `SIGINT`.

INSTALL

sudo apt install docker-cli
copy
sudo dnf install docker-cli
copy
sudo pacman -S docker
copy
sudo apk add docker-cli
copy
sudo zypper install docker
copy
brew install docker
copy
nix profile install nixpkgs#docker
copy

CAVEATS

A container that ignores the stop signal stays up until the timeout, then is killed. Restarting a container that is already stopped only starts it. Anonymous volumes and the container's writable layer are kept.

SEE ALSO

RESOURCES

Copied to clipboard
Kai