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]
|
2016-07-12 16:54:56 -04:00
|
|
|
|
2014-03-18 16:26:21 -04:00
|
|
|
limit nofile 524288 1048576
|
2016-07-12 16:54:56 -04:00
|
|
|
|
|
|
|
# Having non-zero limits causes performance problems due to accounting overhead
|
|
|
|
# in the kernel. We recommend using cgroups to do container-local accounting.
|
|
|
|
limit nproc unlimited unlimited
|
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)
|
2016-04-24 08:27:19 -04:00
|
|
|
DOCKERD=/usr/bin/dockerd
|
2013-11-11 13:13:16 -05:00
|
|
|
DOCKER_OPTS=
|
|
|
|
if [ -f /etc/default/$UPSTART_JOB ]; then
|
|
|
|
. /etc/default/$UPSTART_JOB
|
|
|
|
fi
|
2016-04-24 08:27:19 -04:00
|
|
|
exec "$DOCKERD" $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
|
2016-07-29 09:04:43 -04:00
|
|
|
DOCKER_SOCKET=$(printf "%s" "$DOCKER_OPTS" | grep -oP -e '(-H|--host)\W*unix://\K(\S+)' | sed 1q)
|
2015-12-08 21:55:17 -05:00
|
|
|
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
|