Skip to content

Instantly share code, notes, and snippets.

@arkadijs
Last active August 29, 2015 14:10
Show Gist options
  • Save arkadijs/e14b2fb4e1d8afc51223 to your computer and use it in GitHub Desktop.
Save arkadijs/e14b2fb4e1d8afc51223 to your computer and use it in GitHub Desktop.
Docker with Flannel overlay network
[Unit]
Description=Docker Application Container Engine
Documentation=http://docs.docker.io
After=docker.socket
Requires=docker.socket
Requires=flannel.service
After=flannel.service
[Service]
Environment="TMPDIR=/var/tmp/"
EnvironmentFile=/run/flannel/subnet.env
EnvironmentFile=-/run/docker_opts.env
ExecStartPre=/bin/mount --make-rprivate /
# no-COW flag will propagate down the tree as directories are created by Docker - this is only important on first run
ExecStartPre=/usr/bin/chattr +C /var/lib/docker
LimitNOFILE=1048576
LimitNPROC=1048576
ExecStart=/bin/sh -c 'exec /usr/bin/docker --daemon --storage-driver=btrfs --host=fd:// --bip=${FLANNEL_SUBNET} --mtu=${FLANNEL_MTU} $DOCKER_OPTS'
[Unit]
Description=Flannel overlay network
Requires=etcd.service
After=etcd.service
Wants=network-online.target
After=network-online.target
[Service]
TimeoutStartSec=300
ExecStartPre=/bin/sh -c 'test -x /opt/bin/flanneld || wget -nv -O /opt/bin/flanneld deis-acp-aws-eu-west-1.s3-eu-west-1.amazonaws.com/bin/flanneld && chmod +x /opt/bin/flanneld'
ExecStartPre=/bin/sh -c 'i=0; while sleep 1; do i=$((i+1)); test $i -gt 20 && exit 1; etcdctl mk /coreos.com/network/config {\\"Network\\":\\"10.42.0.0/16\\"}; test $? -eq 0 -o $? -eq 4 && exit 0; done'
ExecStart=/opt/bin/flanneld
Restart=always
[Install]
RequiredBy=docker.service
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment