Created
March 27, 2023 05:51
-
-
Save abhilashshettigar/800af757fd37783802388e7ec26c97e2 to your computer and use it in GitHub Desktop.
This is a simple script to AutoStart the docker container if the docker restart policy is not working properly
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
CONTAINER_NAME="your-container-name" | |
if [ ! "$(docker ps -q -f name=$CONTAINER_NAME)" ]; then | |
if [ "$(docker ps -aq -f status=exited -f name=$CONTAINER_NAME)" ]; then | |
# Start the container if it is stopped | |
docker start $CONTAINER_NAME | |
fi | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment