Skip to main content
RunBook Academy

← All labs in Docker & Containers

Lab · foundation · ~15 min

Lab 27: Host reboot — what comes back and what does not

C · Simulation

Objectives

  • Predict container behaviour after reboot
  • Verify against actual behaviour

Prerequisites

  • A test VM with Docker; ability to reboot

Objective

Document the difference between restart: always and restart: unless-stopped after a host reboot.

Tasks

Task 1: Set up containers with each policy

docker run -d --name reboot-always  --restart always        nginx:1.27
docker run -d --name reboot-unless  --restart unless-stopped nginx:1.27
docker run -d --name reboot-onfail  --restart on-failure     nginx:1.27
docker run -d --name reboot-no      --restart no             nginx:1.27

docker stop reboot-unless   # Mark as "manually stopped"
docker ps --format '{{.Names}}\t{{.Status}}'

Task 2: Predict

Before rebooting, predict what each container will look like after the host comes back.

Task 3: Reboot

sudo reboot

Task 4: Observe

After reboot:

docker ps -a --format '{{.Names}}\t{{.Status}}\t{{.Image}}'

Expected:

ContainerRestart policyStatus after reboot
reboot-alwaysalwaysRunning
reboot-unlessunless-stoppedExited (manually stopped)
reboot-onfailon-failureRunning (only if exited non-zero pre-reboot)
reboot-nonoExited (or never started)

Task 5: Cleanup

docker rm -f reboot-always reboot-unless reboot-onfail reboot-no

Verification status

Last reviewed
2026-08-09
Executed end to end
not yet run on hardware

The commands and configuration here have been reviewed against the verified software versions, but nobody has run this lab start to finish on a system meeting its prerequisites. Treat the Expected Outcome as the intended result rather than an observed one, and keep the Cleanup section to hand.