Skip to content

Instantly share code, notes, and snippets.

Last active May 12, 2023 06:49
What would you like to do?
Restart a docker container periodically with docker-compose
version: '3'
image: nginx:alpine
ports: ["80:80"]
restart: unless-stopped
image: docker:cli
volumes: ["/var/run/docker.sock:/var/run/docker.sock"]
command: ["/bin/sh", "-c", "while true; do sleep 86400; docker restart app_app_1; done"]
restart: unless-stopped
Copy link

Example for restart with docker compose -p

command: ["/bin/sh", "-c", "while true; do sleep 86400; docker compose -p app restart app; done"]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment