Last active
August 29, 2015 14:01
-
-
Save zilin/4994db87e41de1c35364 to your computer and use it in GitHub Desktop.
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
############################# | |
# apache.service | |
############################# | |
[Unit] | |
Description=My Apache Frontend | |
After=docker.service | |
Requires=docker.service | |
[Service] | |
ExecStart=/usr/bin/docker run --name apache -p 80:80 coreos/apache /usr/sbin/apache2ctl -D FOREGROUND | |
ExecStop=/usr/bin/docker stop apache | |
[X-Fleet] | |
X-Conflicts=apache@*.service | |
############################# | |
# apache-discovery.service | |
############################# | |
[Unit] | |
Description=Announce Apache 1 | |
[email protected] | |
[Service] | |
ExecStart=/bin/bash -c "HOST_IP=$(/bin/ifconfig enp0s8 | awk '/inet /{print $2}') && CONTAINER_PORT=$(docker inspect apache | grep -m 1 HostPort | tr -d ' ' | cut -d: -f2 | tr -d '\"') && while true; do etcdctl set /services/web/%H \"{ \\\"host\\\": \\\"$HOST_IP\\\", \\\"port\\\": \\\"$CONTAINER_PORT\\\"}\" --ttl 60;sleep 45;done" | |
ExecStop=/usr/bin/etcdctl rm /services/web/%H | |
[X-Fleet] | |
[email protected] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment