TechBuzzPro

Docker Host Offline: What Happens to Containers?

· 5 min read · Apps & Browsers

In this article
  1. What Happens to Running Containers
  2. What Happens to Container Data
  3. Restart Policies and What They Actually Do
  4. Orchestration: Swarm and Kubernetes
  5. Common Misconceptions
  6. How to Prepare for Host Outages
  7. Frequently Asked Questions

When a Docker host goes offline, every container running on it stops immediately, and all services those containers provided become unavailable until the host is restored or the workloads are moved elsewhere. This article explains exactly what happens to your containers, data, and configurations during an outage, and what you can do to prepare for it.

What Happens to Running Containers

When a Docker host loses power, crashes, or is shut down gracefully, the Docker daemon stops. All containers on that host are terminated. If the host was shut down gracefully (docker stop or systemctl stop docker), Docker sends a SIGTERM to the main process in each container, waits for a grace period (default 10 seconds), then sends SIGKILL. If the host crashes or loses power, containers are killed instantly with no cleanup.

Containers do not “pause” or “hibernate.” They are processes on the host kernel. When the kernel stops, they stop. There is no built-in mechanism for a container to survive a host outage on its own.

What Happens to Container Data

The data inside a container’s writable layer is lost when the host goes offline permanently. However, most real deployments use volumes or bind mounts, which store data on the host filesystem or an external storage system. That data survives the host going offline, but it is inaccessible until the host is back or the volume is mounted elsewhere.

  • Named volumes – stored under /var/lib/docker/volumes/ on the host. They survive a reboot but are tied to that host unless you migrate them manually.
  • Bind mounts – point to a directory on the host. If the host is gone, the directory is gone unless it’s on shared storage (NFS, iSCSI, etc.).
  • tmpfs mounts – stored in memory. They are wiped on host shutdown.

If you used a container without volumes and the host is permanently lost, all data inside that container is gone. That is why stateless containers are recommended for anything that can be rebuilt.

Restart Policies and What They Actually Do

Docker’s --restart flag controls what happens when the container exits or the daemon restarts. It does not move containers to another host. The policies are:

  • no – never restart automatically.
  • on-failure[:max-retries] – restart if the container exits with a non-zero code, up to a maximum number of retries.
  • always – always restart the container when it stops, including after the daemon starts.
  • unless-stopped – restart unless the container was explicitly stopped by a user.

When the host comes back online, the Docker daemon starts and applies these policies. Containers with always or unless-stopped will start again automatically. Containers with no or on-failure will not.

Orchestration: Swarm and Kubernetes

If you run Docker Swarm or Kubernetes, the behavior is different. These tools are designed to handle host failures.

  • Docker Swarm – when a node goes offline, the swarm manager marks it as down. Services running on that node are rescheduled to other healthy nodes, provided the service has replicas and the tasks are not constrained to that node.
  • Kubernetes – the kubelet on each node reports to the control plane. If a node stops reporting (default timeout ~40 seconds), the control plane marks it NotReady and reschedules pods after a grace period (default 5 minutes).

In both cases, the containers themselves are not moved—they are killed and recreated on another node. Any data in local volumes is lost unless you use shared storage or replicated volumes.

Common Misconceptions

“Docker will restart my containers when the host comes back.” Only if you set a restart policy. By default (no), containers do not restart.

“My data is safe because I used a volume.” Volumes survive a reboot, but not a disk failure or a host that is never recovered. Back up volumes or use external storage.

“A container is a lightweight VM.” Containers share the host kernel. They do not have the same isolation or migration capabilities as VMs.

How to Prepare for Host Outages

You can reduce the impact of a host going offline:

  1. Set --restart=unless-stopped on critical containers so they come back automatically.
  2. Use a multi-node orchestration platform (Swarm, Kubernetes) for high availability.
  3. Store persistent data on networked storage (NFS, Ceph, cloud volumes) so it can be attached to a new host.
  4. Test your recovery procedure: shut down a host and verify services come back elsewhere.
  5. Monitor host health with tools like Prometheus or Uptime Robot so you know when a host is down.

Frequently Asked Questions

Will my containers restart automatically after a power outage?

Only if you configured a restart policy of always or unless-stopped. Otherwise, you must start them manually with docker start or docker-compose up.

Can I move a container to another host while the original is offline?

No. A container is tied to the host it was created on. You can, however, recreate the container from an image on another host, provided you have the image and any configuration files (e.g., environment variables, volumes).

What happens to my Docker volumes if the host is permanently lost?

If the volumes are on the host’s local disk and the disk is unrecoverable, the data is lost. If the volumes are on external storage, you can mount them on a new host and recreate the containers.

Does Docker Swarm automatically move my services to another node?

Yes, for services with replicas. When a node goes offline, the swarm manager reschedules the tasks to other healthy nodes. The new tasks start fresh—they do not migrate the container state.

How long does Kubernetes take to reschedule pods after a node failure?

By default, the control plane waits for the node to be marked NotReady (about 40 seconds) and then gives the pod a grace period (default 5 minutes) before rescheduling. This can be tuned with --pod-eviction-timeout on the controller manager.