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-12-13 05:10:41 -05:00
|
|
|
exec "$DOCKER" daemon $DOCKER_OPTS --raw-logs
|
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=
|
2015-12-08 21:55:17 -05:00
|
|
|
DOCKER_SOCKET=
|
2014-11-22 03:25:57 -05:00
|
|
|
if [ -f /etc/default/$UPSTART_JOB ]; then
|
|
|
|
. /etc/default/$UPSTART_JOB
|
|
|
|
fi
|
2015-12-08 21:55:17 -05:00
|
|
|
|
2014-11-22 03:25:57 -05:00
|
|
|
if ! printf "%s" "$DOCKER_OPTS" | grep -qE -e '-H|--host'; then
|
2015-12-08 21:55:17 -05:00
|
|
|
DOCKER_SOCKET=/var/run/docker.sock
|
|
|
|
else
|
|
|
|
DOCKER_SOCKET=$(printf "%s" "$DOCKER_OPTS" | grep -oP -e '(-H|--host)\W*unix://\K(\S+)')
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -n "$DOCKER_SOCKET" ]; then
|
|
|
|
while ! [ -e "$DOCKER_SOCKET" ]; do
|
2015-03-30 20:33:27 -04:00
|
|
|
initctl status $UPSTART_JOB | grep -qE "(stop|respawn)/" && exit 1
|
2015-12-08 21:55:17 -05:00
|
|
|
echo "Waiting for $DOCKER_SOCKET"
|
2014-11-22 03:25:57 -05:00
|
|
|
sleep 0.1
|
|
|
|
done
|
2015-12-08 21:55:17 -05:00
|
|
|
echo "$DOCKER_SOCKET is up"
|
2014-11-22 03:25:57 -05:00
|
|
|
fi
|
|
|
|
end script
|