Skip to content

Instantly share code, notes, and snippets.

@abhilashshettigar
Created March 27, 2023 05:51
Show Gist options
  • Save abhilashshettigar/800af757fd37783802388e7ec26c97e2 to your computer and use it in GitHub Desktop.
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
#!/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