2013-10-15 11:37:18 -04:00
|
|
|
description "Docker daemon"
|
|
|
|
|
2015-11-05 14:35:45 -05:00
|
|
|
start on (filesystem and net-device-up IFACE!=lo)
|
2013-10-15 11:37:18 -04:00
|
|
|
stop on runlevel [!2345]
|
2014-03-18 16:26:21 -04:00
|
|
|
limit nofile 524288 1048576
|
|
|
|
limit nproc 524288 1048576
|
2013-10-15 11:37:18 -04:00
|
|
|
|
|
|
|
respawn
|
|
|
|
|
2015-05-20 14:15:47 -04:00
|
|
|
kill timeout 20
|
|
|
|
|
2014-03-11 03:21:59 -04:00
|
|
|
pre-start script
|
|
|
|
# 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
|
|
|
|
|
2013-10-15 11:37:18 -04:00
|
|
|
script
|
2014-03-10 01:16:42 -04:00
|
|
|
# modify these in /etc/default/$UPSTART_JOB (/etc/default/docker)
|
2013-11-11 13:13:16 -05:00
|
|
|
DOCKER=/usr/bin/$UPSTART_JOB
|
|
|
|
DOCKER_OPTS=
|
|
|
|
if [ -f /etc/default/$UPSTART_JOB ]; then
|
|
|
|
. /etc/default/$UPSTART_JOB
|
|
|
|
fi
|
2015-07-22 14:24:38 -04:00
|
|
|
exec "$DOCKER" daemon $DOCKER_OPTS
|
2013-10-15 11:37:18 -04:00
|
|
|
end script
|
2014-11-22 03:25:57 -05:00
|
|
|
|
|
|
|
# Don't emit "started" event until docker.sock is ready.
|
|
|
|
# See https://github.com/docker/docker/issues/6647
|
|
|
|
post-start script
|
|
|
|
DOCKER_OPTS=
|
|
|
|
if [ -f /etc/default/$UPSTART_JOB ]; then
|
|
|
|
. /etc/default/$UPSTART_JOB
|
|
|
|
fi
|
|
|
|
if ! printf "%s" "$DOCKER_OPTS" | grep -qE -e '-H|--host'; then
|
|
|
|
while ! [ -e /var/run/docker.sock ]; do
|
2015-03-30 20:33:27 -04:00
|
|
|
initctl status $UPSTART_JOB | grep -qE "(stop|respawn)/" && exit 1
|
2014-11-22 03:25:57 -05:00
|
|
|
echo "Waiting for /var/run/docker.sock"
|
|
|
|
sleep 0.1
|
|
|
|
done
|
|
|
|
echo "/var/run/docker.sock is up"
|
|
|
|
fi
|
|
|
|
end script
|