Server AdministrationUpdated November 24, 2026·7 min read

How to Restart Docker and Its Containers

"Restart Docker" has two meanings. Restarting the Docker daemon on Linux is sudo systemctl restart docker; restarting one container is docker restart <container>. Mixing them up is costly, since a daemon restart stops every running container on the server by default. This article explains both, along with Compose services, the restart policies that bring containers back automatically, and live restore, which keeps containers up while the daemon restarts.

Goal Command
Restart the Docker service sudo systemctl restart docker
Check the service sudo systemctl status docker
Restart one container docker restart web
Restart all running containers docker restart $(docker ps -q)
Restart one Compose service docker compose restart api
Make a container restart automatically docker update --restart unless-stopped web

Restart Docker daemon with systemctl

On Ubuntu, Debian and other systemd-based distributions:

sudo systemctl restart docker
sudo systemctl status docker

Look for active (running) in the status output. If it's not there, check the daemon log:

sudo journalctl -u docker --since "10 min ago"

Restarts most often fail because of a syntax error in /etc/docker/daemon.json, typically a missing comma or an extra one at the end. Check the file is valid before you restart:

python3 -m json.tool /etc/docker/daemon.json

When a daemon restart is needed. Edits to /etc/docker/daemon.json, for log rotation, a new data directory or registry mirrors, only apply once the service restarts or reloads. An apt upgrade of Docker restarts it automatically.

What happens to your containers. Docker's documentation states that, by default, running containers are shut down when the daemon terminates. Once it is back:

  • containers whose restart policy is always or unless-stopped start up again;
  • containers set to no (the default) or on-failure stay stopped until you start them yourself.

On a server with real workloads, treat a daemon restart as a brief planned outage, or turn on live restore beforehand (see below).

To stop the daemon and start it again as separate steps, say while you change files in its data directory:

sudo systemctl stop docker docker.socket
sudo systemctl start docker

Stop docker.socket too. Otherwise systemd brings the daemon straight back the moment a docker command touches the socket.

Reload instead of restart

Certain daemon settings take effect without a full restart:

sudo systemctl reload docker

Reloading sends SIGHUP to the daemon, which then re-reads daemon.json. Only a subset of options can change this way, live-restore and debug logging among them. Others, like the storage driver or the data directory, still require a full restart.

Restart Docker on other systems

  • Older init systems: sudo service docker restart
  • Docker Desktop on Windows or macOS: choose "Restart" from the Docker Desktop menu. Windows users can also restart the Docker Desktop service in Services.

Docker restart container: one, several or all

docker restart web

docker restart shuts the container down exactly like docker stop, with SIGTERM first and SIGKILL after a timeout (10 seconds by default on Linux), then starts it up again. ID, name, configuration and the contents of its writable layer all stay the same.

Allow slow services more time to exit:

docker restart -t 30 db

Name several containers to restart them together, or restart everything that is running:

docker restart web api worker
docker restart $(docker ps -q)

There's no special reboot command for containers: rebooting one is the same as restarting it. Watch out for addressing, though. On Docker's default bridge network, nothing promises a container the same IP after it comes back, so connect services by container name on a user-defined network, or via published ports, and never hard-code IPs.

Restart does not apply new settings

Restarting brings the container back with the configuration it was created with. Change the image, environment variables, ports or volumes and a restart won't apply it; the container has to be recreated:

docker pull nginx:1.27
docker stop web && docker rm web
docker run -d --name web --restart unless-stopped -p 127.0.0.1:8080:80 nginx:1.27

That's the strongest argument for using Compose with anything long-lived: it figures out for you which containers need recreating. Our guide to stopping and removing Docker containers goes through the first two steps in detail.

Restart Docker Compose services

From the folder with your compose.yaml:

docker compose restart          # every service
docker compose restart api      # one service

Just like docker restart, it ignores edits to the Compose file and newer images. To apply them:

docker compose up -d            # recreates only services whose config changed
docker compose pull && docker compose up -d   # update images, then recreate
docker compose up -d --force-recreate api      # recreate even if nothing changed

What each of these does is explained in our guide to Docker Compose up and down.

Make containers restart automatically

Restart policies decide how Docker reacts when a container exits or when the daemon starts. Set one at creation time with --restart, or change it on an existing container with docker update:

docker run -d --name web --restart unless-stopped nginx:1.27
docker update --restart unless-stopped web
Policy Restarts when the process exits After you stop it by hand
no (default) Never Stays stopped
on-failure[:N] Only on a non-zero exit code, up to N times if set Stays stopped; not restarted when the daemon restarts
always Always Starts again when the daemon restarts
unless-stopped Always Stays stopped, even after a daemon restart

For most server workloads, unless-stopped is the one to pick: crashes and reboots bring the container back, while a container you stopped deliberately stays stopped. In a Compose file, give every service restart: unless-stopped.

On Ubuntu the Docker service already starts at boot, so always or unless-stopped is all a container needs to come back after a reboot.

Keep containers running during a daemon restart: live restore

With live restore, containers stay up while the Docker daemon is stopped, restarted or upgraded. Switch it on in /etc/docker/daemon.json:

{
  "live-restore": true
}

Apply it without restarting anything:

sudo systemctl reload docker

After that, sudo systemctl restart docker reattaches to running containers rather than stopping them. Docker's documentation lists some limits:

  • It handles patch upgrades within one release line; a major version upgrade can still stop containers.
  • Swarm services aren't covered, only standalone containers and Compose.
  • Containers may fail to reconnect if certain daemon settings, such as the bridge IP or the storage driver, change across the restart.

Restarting the whole server

A sudo reboot stops every container together with the Docker service. Once the server is up, Docker starts and brings back each container set to always or unless-stopped. Confirm with:

docker ps

If one is missing, docker ps -a shows its exit status and docker logs <container> shows what it printed.

Frequently asked questions

Does restarting Docker delete my containers?

No. By default a service restart stops running containers, but it never deletes them, their volumes or their images. Anything with a restart policy of always or unless-stopped comes back on its own.

What is the difference between docker restart and docker start?

docker start starts a container that is stopped. docker restart stops a running container and starts it again, and on a stopped container it just starts it.

How do I restart Docker without stopping containers?

Add "live-restore": true to /etc/docker/daemon.json and run sudo systemctl reload docker. From then on, restarting the daemon leaves running containers untouched, within the limits listed above.

Why does my container keep restarting?

Its restart policy brings it back after every crash. docker logs <container> tells you why the process exits, and docker inspect -f '{{.RestartCount}}' <container> tells you how many times it has happened.

Do I need to restart Docker after adding a user to the docker group?

No. The user only has to log out and in again, or run newgrp docker; the daemon can keep running.

Related guides

Planning maintenance on a bare metal server or VPS? Turn on live restore first. Starting from a blank server? Work through how to install Docker on Ubuntu, with the Docker commands cheat sheet close at hand.

Was this article helpful?

Written by Julius · Product Manager