How to set a restart policy?

To set a restart policy for a container in Podman, you can use the --restart flag when you create the container with the podman run command. Here’s the syntax:

podman run --restart=<policy> --name <container_name> <image_name>

Example Restart Policies

  1. Always Restart:

    podman run --restart=always --name my_container my_image
  2. Restart Unless Stopped:

    podman run --restart=unless-stopped --name my_container my_image
  3. Restart on Failure (with a maximum retry count):

    podman run --restart=on-failure:5 --name my_container my_image
  4. No Restart (default behavior):

    podman run --restart=no --name my_container my_image

Notes

  • Replace <policy> with the desired restart policy.
  • Replace <container_name> with your desired name for the container.
  • Replace <image_name> with the name of the image you want to run.

This will set the specified restart policy for the container when it is created.

0 Comments

no data
Be the first to share your comment!