Restart a container
Medium risk
What do risk levels mean?
- Read-only
- Inspects state without changing anything.
- Low risk
- Reversible with a routine follow-up command.
- Medium risk
- Changes state; undo path documented.
- Destructive
- Deletes or overwrites; confirmation required.
Stops and starts a container in place, keeping its configuration, network settings, and volumes. Useful to recover a hung service or apply an updated file mounted from the host.
dockerrestartcontainers
Parameters
Name or ID of the container to restart.
Commands
Check the container's current status before restarting
docker ps --all --filter name=<container>Stop the container's process and start it again with the same configuration
docker restart <container>Verification
docker ps --filter name=<container>The container is Up with a recent uptime, indicating a fresh start.
Undo
Not undoable
The restart itself cannot be reversed; the previous process's in-memory state is gone. The container's files, configuration, and volumes are unchanged.
Pitfalls
- Any in-memory state (caches, sessions, unsaved data) is lost across the restart.
- The service is briefly unavailable; docker restart waits 10 seconds before force-killing a process that ignores SIGTERM.
- Restarting does not pick up a new image version; recreate the container to upgrade.