[!NOTE]
Archived answers from chatGPT
To make a Docker container start automatically after a system reboot, you need to set its restart policy when running or updating the container. Here's how you can do it:
- Use --restart flag when running a container Run your container with one of the --restart policies:
| |
Restart Policies:
no (default) → Container does not restart.
always → Container always restarts after a reboot or crash.
unless-stopped → Container restarts unless explicitly stopped.
on-failure → Restarts only if the container exits with an error.
👉 Recommended: unless-stopped ensures the container starts again after a reboot but doesn’t restart if you manually stopped it.
- Update an existing container’s restart policy If the container is already running, update its restart policy with:
| |
- Enable Docker service at boot (if needed) Ensure the Docker service itself starts on boot:
| |
To check its status:
| |
- Verify Containers Restart After Reboot Restart your system:
| |
After rebooting, check running containers:
| |
Your container should be running if its restart policy is set correctly.