Created
November 3, 2015 08:10
-
-
Save jperville/5a5f9205e42b36bf0492 to your computer and use it in GitHub Desktop.
Docker upstart config
This file contains 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
description "Docker daemon" | |
start on (local-filesystems and net-device-up IFACE!=lo) | |
stop on runlevel [!2345] | |
limit nofile 524288 1048576 | |
limit nproc 524288 1048576 | |
respawn | |
respawn limit 2 10 | |
pre-start script | |
[ -x /sbin/sysctl ] || exit 6 | |
/sbin/sysctl -w net.ipv4.ip_forward=1 > /dev/null 2>&1 | |
/sbin/sysctl -w net.ipv6.conf.all.forwarding=1 > /dev/null 2>&1 | |
# see also https://github.com/tianon/cgroupfs-mount/blob/master/cgroupfs-mount | |
if grep -v '^#' /etc/fstab | grep -q cgroup \ | |
|| [ ! -e /proc/cgroups ] \ | |
|| [ ! -d /sys/fs/cgroup ]; then | |
exit 0 | |
fi | |
if ! mountpoint -q /sys/fs/cgroup; then | |
mount -t tmpfs -o uid=0,gid=0,mode=0755 cgroup /sys/fs/cgroup | |
fi | |
( | |
cd /sys/fs/cgroup | |
for sys in $(awk '!/^#/ { if ($4 == 1) print $1 }' /proc/cgroups); do | |
mkdir -p $sys | |
if ! mountpoint -q $sys; then | |
if ! mount -n -t cgroup -o $sys cgroup $sys; then | |
rmdir $sys || true | |
fi | |
fi | |
done | |
) | |
end script | |
script | |
# modify these in /etc/default/$UPSTART_JOB (/etc/default/docker) | |
DOCKER=/usr/bin/$UPSTART_JOB | |
DOCKER_DAEMON_OPTS= | |
if [ -f /etc/default/$UPSTART_JOB ]; then | |
. /etc/default/$UPSTART_JOB | |
fi | |
exec /usr/bin/docker daemon --dns=8.8.8.8 --group=docker --log-driver=fluentd --log-opt=fluentd-address=127.0.0.1:24224 --pidfile=/var/run/docker.pid --storage-driver=btrfs --userland-proxy=false >> /var/log/docker.log | |
end script | |
# Don't emit "started" event until docker.sock is ready. | |
# See https://github.com/docker/docker/issues/6647 | |
post-start script | |
running() { | |
RUNNING=1 | |
RESPONSE=`/usr/bin/docker ps 2>&1 | head -n 1` | |
local mret=$? | |
if [ $mret -eq 0 ] \ | |
|| [ `echo $RESPONSE | grep -q "Is your docker"` ]; then | |
RUNNING=0 | |
fi | |
return $RUNNING | |
} | |
while ! running ; do | |
initctl status $UPSTART_JOB | grep -q "stop/" && exit 1 | |
echo "Waiting for Docker" | |
sleep 0.1 | |
done | |
echo "Docker is up" | |
fi | |
end script |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment