Skip to content

Instantly share code, notes, and snippets.

@rayspock
Created July 27, 2019 01:44
Show Gist options
  • Save rayspock/a62c2aeb61fb93d090b99744f515188a to your computer and use it in GitHub Desktop.
Save rayspock/a62c2aeb61fb93d090b99744f515188a to your computer and use it in GitHub Desktop.
Service Unit Configuration for Docker
[Unit]
Description=Rapid Issuer Process
Requires=docker.service
After=docker.service
[Service]
Restart=always
User=ubuntu
Group=docker
Environment=DOCKER_COMPOSE=/home/ubuntu/build/watch/docker-compose.yml
# Shutdown container (if running) when unit is stopped
ExecStartPre=/usr/bin/docker-compose -f ${DOCKER_COMPOSE} down -v
# Start container when unit is started
ExecStart=/usr/bin/docker-compose -f ${DOCKER_COMPOSE} up
# Stop container when unit is stopped
ExecStop=/usr/bin/docker-compose -f ${DOCKER_COMPOSE} down -v
[Install]
WantedBy=multi-user.target
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment