Skip to content

Instantly share code, notes, and snippets.

@tanelmae
Last active August 3, 2019 19:27
Show Gist options
  • Save tanelmae/e0cf3b2b7ea8d94ad62240b56eb0aa4d to your computer and use it in GitHub Desktop.
Save tanelmae/e0cf3b2b7ea8d94ad62240b56eb0aa4d to your computer and use it in GitHub Desktop.
Running CoreDNS docker image with systemd
[Unit]
Description=CoreDNS
Requires=docker.service
After=docker.service
ConditionPathExists=/etc/coredns/Corefile
[Service]
ExecStartPre=/bin/bash -c "/usr/bin/docker container inspect coredns 2> /dev/null || /usr/bin/docker run -d --name coredns -p 53:53/udp --restart unless-stopped -v /etc/coredns:/conf coredns/coredns:1.6.0 -conf /conf/Corefile"
ExecStart=/usr/bin/docker start -a coredns
ExecStop=/usr/bin/docker stop coredns
[Install]
WantedBy=multi-user.target
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment