How to Restart Docker on Ubuntu 26.04

Restarting Docker on Ubuntu 26.04 is a common task when applying configuration changes, recovering from an unresponsive daemon, or troubleshooting container issues. This guide covers every method for a docker restart ubuntu 26.04 scenario: restarting the Docker service itself via systemd, restarting individual containers, and performing a graceful restart to minimise downtime. Whether you are running a development workstation or a production server, understanding these methods ensures you can keep your Docker environment healthy and responsive.

In this tutorial you will learn:

  • How to restart the Docker daemon using systemd
  • How to restart individual Docker containers by name or ID
  • How to restart all running containers at once
  • How to configure automatic restart policies for containers
  • How to verify Docker is healthy after a restart
  • How to diagnose and fix common Docker restart failures

[IMAGE PLACEHOLDER: Header image – abstract illustration representing Docker container restart operations on Ubuntu Linux]

Software Requirements

Software Requirements and Linux Command Line Conventions
Category Requirements, Conventions or Software Version Used
System Ubuntu 26.04 Resolute Raccoon
Software Docker Engine 27.x or later
Other Privileged access to your Linux system as root or via the sudo command.
Conventions # – requires given linux commands to be executed with root privileges either directly as a root user or by use of sudo command
$ – requires given linux commands to be executed as a regular non-privileged user
TL;DR
To perform a docker restart on Ubuntu 26.04, use systemctl to restart the daemon and docker restart to restart individual containers.

Quick Steps to Restart Docker on Ubuntu 26.04
Step Command/Action
1. Restart Docker daemon sudo systemctl restart docker
2. Restart a specific container docker restart <container_name>
3. Verify daemon is running sudo systemctl status docker

Restart the Docker Service on Ubuntu 26.04

The Docker service on Ubuntu 26.04 is managed by systemd, which means the standard systemctl commands apply. Restarting the Docker daemon is necessary when you edit the Docker configuration file (/etc/docker/daemon.json), upgrade the Docker Engine, or experience a frozen or unresponsive daemon. To restart the server service in general, the same systemd pattern applies.

  1. Restart the Docker daemon: Run the following command to stop and then start the Docker service in one operation:
    $ sudo systemctl restart docker

    This command sends a stop signal to the daemon, waits for it to shut down cleanly, and then starts it again. All containers that do not have a restart policy set will remain stopped after this operation.

  2. Reload the Docker daemon without a full restart (optional): If you only changed certain daemon options, you can attempt a soft reload:
    $ sudo systemctl reload docker

    Note that not all configuration changes are applied via reload. A full restart is always the safest option after editing daemon.json.

IMPORTANT
Restarting the Docker daemon stops all running containers unless they have been configured with a restart policy such as always or unless-stopped. Plan maintenance accordingly in production environments.

Restart a Docker Container on Ubuntu 26.04

A docker restart ubuntu 26.04 operation does not always require touching the daemon. More commonly, you need to restart an individual container after a configuration change, a crash, or a code update. The docker restart command handles this cleanly without affecting other running containers.

  1. Identify the container name or ID: List all containers, including stopped ones, to find the target:
    $ docker ps -a

    The output shows the container ID, image name, status, and the assigned name in the rightmost column. You can use either the container ID or the name in subsequent commands.

  2. Restart the container: Pass the container name or ID to the restart subcommand:
    $ docker restart linuxconfig_container

    Docker sends a SIGTERM signal to the main process inside the container, waits for a grace period (10 seconds by default), and then sends SIGKILL if the process has not exited. The container is then started fresh.

  3. Adjust the stop timeout (optional): For containers that need more time to shut down gracefully, use the -t flag to specify a timeout in seconds:
    $ docker restart -t 30 linuxconfig_container

    This example gives the container 30 seconds to exit cleanly before Docker forcefully kills it.

You can also reference Docker images to better understand the relationship between images and the containers you are restarting.

Terminal showing docker ps -a output before and after running docker restart linuxconfig_container on Ubuntu 26.04
Running docker restart linuxconfig_container and verifying the container is back up with docker ps -a

Restart All Running Containers on Ubuntu 26.04

There are situations where you need to restart every container simultaneously, for example after changing DNS settings that affect all containers, or after updating shared environment variables. Docker does not provide a single command for this purpose, but you can combine docker ps with docker restart to achieve it efficiently.

  1. Restart all currently running containers: Use command substitution to pass all running container IDs to docker restart:
    $ docker restart $(docker ps -q)

    The -q flag on docker ps outputs only container IDs, which are then passed as arguments. If no containers are running, the command exits without error.

  2. Restart all containers including stopped ones (use with caution): To include every container regardless of state, add the -a flag:
    $ docker restart $(docker ps -aq)

    This starts previously stopped containers as well, so review the list with docker ps -a first to avoid starting containers unintentionally.

IMPORTANT
If you are working with Docker Compose, a more controlled approach is to run docker compose restart from the project directory. This restarts only the containers defined in that specific Compose file.

Configure Container Restart Policies on Ubuntu 26.04

Restart policies determine what Docker does automatically when a container exits. Configuring a policy is the recommended approach for any container that should survive a Docker daemon restart or host reboot. To get started with Docker, understanding restart policies is an essential early step.

The four available restart policies are described below:

 

Docker Container Restart Policy Options
Policy Behaviour
no Default. Docker never automatically restarts the container.
on-failure[:max-retries] Restarts only if the container exits with a non-zero exit code. Optionally limits the number of retries.
always Always restarts the container regardless of exit code, including after a daemon restart.
unless-stopped Same as always but does not restart if the container was manually stopped before the daemon restarted.
  1. Set a restart policy when creating a container: Pass the --restart flag to docker run:
    $ docker run -d --restart unless-stopped --name web nginx

    This starts an Nginx container that restarts automatically unless you explicitly stop it with docker stop.

  2. Update the restart policy on an existing container: Use docker update to change the policy without recreating the container:
    $ docker update --restart always linuxconfig_container

    The new policy takes effect immediately and persists across daemon and host restarts.

Terminal showing docker inspect output before and after running docker update --restart always linuxconfig_container on Ubuntu 26.04
Using docker update to change the restart policy from “no” to “always” on linuxconfig_container

Verify Docker Status After Restart on Ubuntu 26.04

After any docker restart ubuntu 26.04 operation, confirming that everything is healthy is important. The following commands give you a complete picture of the daemon and container states.

  1. Check the Docker daemon status:
    $ sudo systemctl status docker

    Look for Active: active (running) in the output. If the daemon failed to start, the status will show failed and the journal entries below will indicate the cause.

  2. Check Docker daemon info:
    $ docker info

    This command outputs the number of running and stopped containers, the storage driver in use, and other daemon-level diagnostics. Consequently, it is one of the fastest ways to confirm the daemon is functioning correctly.

  3. List running containers:
    $ docker ps

    Verify that all expected containers are in the Up state. Any containers that exited unexpectedly will appear in docker ps -a with their exit code.

  4. Review container logs after restart:
    $ docker logs linuxconfig_container

    Check application logs to confirm the process inside the container started without errors following the restart.

Additionally, if you need to restart the network stack on Ubuntu, the same systemd patterns used for Docker apply equally to NetworkManager and other services.

Troubleshooting Docker Restart Issues on Ubuntu 26.04

Sometimes a docker restart ubuntu 26.04 operation does not go as expected. The following covers the most common issues and their solutions.

  1. Docker daemon fails to start after restart: A syntax error in /etc/docker/daemon.json is the most frequent cause. Validate the file before restarting:
    $ cat /etc/docker/daemon.json | python3 -m json.tool

    If the command reports an error, correct the JSON and then retry sudo systemctl restart docker.

  2. Containers do not come back after daemon restart: This happens when no restart policy is set. Containers with the default no policy remain stopped after the daemon restarts. Set an appropriate policy with docker update --restart unless-stopped <container> and they will recover automatically in the future.
  3. Container is stuck in a restart loop: A container configured with on-failure or always that keeps crashing will enter a restart loop. Inspect the logs to find the root cause:
    $ docker logs --tail 50 linuxconfig_container

    Additionally, check the restart count with docker inspect linuxconfig_container | grep -i restartcount.

  4. Permission denied when running docker commands: If your user is not in the docker group, add them and apply the change:
    $ sudo usermod -aG docker linuxconfig
    $ newgrp docker

    After this, Docker commands work without sudo in new shell sessions.

COMPLETED
You now know all the primary methods to restart Docker and individual containers on Ubuntu 26.04. For official reference documentation, see the Docker CLI restart reference.

Conclusion

This guide covered the complete docker restart ubuntu 26.04 workflow, including restarting the Docker daemon via systemd, restarting individual containers and all containers at once, configuring restart policies for automatic recovery, verifying system health post-restart, and resolving common failure scenarios. Combining systemctl restart docker for daemon-level control with docker restart for container-level control gives you precise management over your Docker environment on Ubuntu 26.04. Moreover, setting appropriate restart policies ensures your workloads recover automatically from both application crashes and planned maintenance restarts.

If you also want to restart Ubuntu itself, the same systemd-based approach used here will feel familiar.

Frequently Asked Questions

  1. Does restarting the Docker daemon stop all my containers? Yes, restarting the Docker daemon stops all running containers unless they have a restart policy of always or unless-stopped configured. Containers with those policies restart automatically once the daemon is back up. Containers using the default no policy, or those that were manually stopped, remain stopped.
  2. What is the difference between docker restart and docker stop followed by docker start? The docker restart command is functionally equivalent to running docker stop and docker start in sequence, but it is a single atomic command. The key difference is that docker restart preserves the container’s existing configuration, environment variables, and volume mounts without requiring you to specify them again.
  3. How do I restart Docker automatically on boot in Ubuntu 26.04? The Docker service is enabled at boot by default when installed via the official repository. You can verify this with sudo systemctl is-enabled docker. If it returns disabled, enable it with sudo systemctl enable docker. For containers to also restart on boot, configure them with the --restart always or --restart unless-stopped policy.
  4. Can I restart a Docker container without root privileges? Yes, provided your user is a member of the docker group. Run groups to check your current group memberships. If docker is not listed, add yourself with sudo usermod -aG docker $USER and log out and back in for the change to take effect. After that, docker restart works without sudo.
  5. What happens to container data when I restart Docker? Data stored in Docker volumes is preserved across container and daemon restarts. Data written to the container’s writable layer (non-volume paths) is also preserved across restarts, because a restart does not recreate the container. However, if the container is removed and recreated from its image, only volume data persists.