Skip to content

Instantly share code, notes, and snippets.

@stefanahman
Created January 22, 2017 15:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stefanahman/e835eb3302ab081297168f7790dcdc2c to your computer and use it in GitHub Desktop.
Save stefanahman/e835eb3302ab081297168f7790dcdc2c to your computer and use it in GitHub Desktop.
Docker service template
[Unit]
Description=<user> docker container
After=docker.service
Requires=docker.service
[Service]
User=<user>
TimeoutStartSec=0
ExecStartPre=-/usr/bin/docker kill <user>
ExecStartPre=-/usr/bin/docker rm <user>
ExecStartPre=/usr/bin/docker pull docker pull <repo>
ExecStart=/usr/bin/docker run \
--name <user> \
--privileged \
-e PGID=<pgid> -e PUID=<puid> \
-e TZ=Europe/Berlin \
-p <port>:<port> \
<repo>
Restart=always
RestartSec=5
[Install]
WantedBy=multi-user.target
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment