Last active
June 16, 2017 07:09
-
-
Save r7vme/ee0ca68023e912aba3f8502efd5a14d3 to your computer and use it in GitHub Desktop.
systemd unit for haproxy running in docker container
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Unit] | |
Description=Haproxy container | |
After=docker.service | |
Requires=docker.service | |
ConditionFileNotEmpty=/etc/haproxy/haproxy.cfg | |
[Service] | |
TimeoutStartSec=0 | |
Restart=always | |
Environment=CONFIG_DIR=/etc/haproxy | |
ExecStartPre=-/usr/bin/docker stop %n | |
ExecStartPre=-/usr/bin/docker rm %n | |
ExecStartPre=/usr/bin/docker pull haproxy | |
ExecStart=/usr/bin/docker run \ | |
--rm \ | |
--name %n \ | |
--net=host \ | |
-v ${CONFIG_DIR}:${CONFIG_DIR} \ | |
haproxy \ | |
haproxy -f ${CONFIG_DIR}/haproxy.cfg | |
[Install] | |
WantedBy=multi-user.target | |
# To reload config use "docker kill -s HUP haproxy.service" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment