docker/restart

Restart Container

Restart one or more containers.

container
lifecycle

Command

docker restart

Explanation

docker restart is useful for quickly applying configuration changes or recovering from issues without recreating containers. It sends a stop signal, waits for the timeout, and then starts the container again.

Common Use Cases

  • Apply configuration changes in a running container
  • Recover containers stuck in an error state

Best Practices

  • Use restart to refresh environment variables or connections

Common Mistakes to Avoid

  • Using restart expecting rebuild of image layers

Troubleshooting

Problem: Container fails to restart

Solution: Check logs and container exit codes with docker logs and docker inspect.

Examples

Restart a container

docker restart my_container