Forrest logo
back to the docker tool

docker:tldr:41f1e

docker: Update the policy to restart up to three times a specific container when it exits with non-zero exit status.
$ docker update --restart=on-failure:3 ${container_name}
try on your machine

This command is used to update the configuration of a running Docker container and specify a restart policy.

Let's break down the command:

  • docker update: This is the Docker command used to update container configuration.
  • --restart=on-failure:3: This is an option provided to docker update to specify the restart policy. In this case, it means that the container should be automatically restarted if it exits with a non-zero exit code (failure). The number 3 represents the maximum number of restart attempts. Once the container has failed and restarted 3 times, it will not be automatically restarted again.
  • ${container_name}: This is a placeholder for the name or ID of the Docker container you want to update. You should replace ${container_name} with the actual name or ID of the container you want to apply the restart policy to.

Overall, this command sets a restart policy for a Docker container that automatically restarts the container if it fails, with a maximum of 3 restart attempts.

This explanation was created by an AI. In most cases those are correct. But please always be careful and never run a command you are not sure if it is safe.
back to the docker tool