github.com/demonoid81/moby@v0.0.0-20200517203328-62dd8e17c460/contrib/init/upstart/docker.conf (about)

     1  description "Docker daemon"
     2  
     3  start on (filesystem and net-device-up IFACE!=lo)
     4  stop on runlevel [!2345]
     5  
     6  limit nofile 524288 1048576
     7  
     8  # Having non-zero limits causes performance problems due to accounting overhead
     9  # in the kernel. We recommend using cgroups to do container-local accounting.
    10  limit nproc unlimited unlimited
    11  
    12  respawn
    13  
    14  kill timeout 20
    15  
    16  pre-start script
    17  	# see also https://github.com/tianon/cgroupfs-mount/blob/master/cgroupfs-mount
    18  	if grep -v '^#' /etc/fstab | grep -q cgroup \
    19  		|| [ ! -e /proc/cgroups ] \
    20  		|| [ ! -d /sys/fs/cgroup ]; then
    21  		exit 0
    22  	fi
    23  	if ! mountpoint -q /sys/fs/cgroup; then
    24  		mount -t tmpfs -o uid=0,gid=0,mode=0755 cgroup /sys/fs/cgroup
    25  	fi
    26  	(
    27  		cd /sys/fs/cgroup
    28  		for sys in $(awk '!/^#/ { if ($4 == 1) print $1 }' /proc/cgroups); do
    29  			mkdir -p $sys
    30  			if ! mountpoint -q $sys; then
    31  				if ! mount -n -t cgroup -o $sys cgroup $sys; then
    32  					rmdir $sys || true
    33  				fi
    34  			fi
    35  		done
    36  	)
    37  end script
    38  
    39  script
    40  	# modify these in /etc/default/$UPSTART_JOB (/etc/default/docker)
    41  	DOCKERD=/usr/bin/dockerd
    42  	DOCKER_OPTS=
    43  	if [ -f /etc/default/$UPSTART_JOB ]; then
    44  		. /etc/default/$UPSTART_JOB
    45  	fi
    46  	exec "$DOCKERD" $DOCKER_OPTS --raw-logs
    47  end script
    48  
    49  # Don't emit "started" event until docker.sock is ready.
    50  # See https://github.com/demonoid81/moby/issues/6647
    51  post-start script
    52  	DOCKER_OPTS=
    53  	DOCKER_SOCKET=
    54  	if [ -f /etc/default/$UPSTART_JOB ]; then
    55  		. /etc/default/$UPSTART_JOB
    56  	fi
    57  
    58  	if ! printf "%s" "$DOCKER_OPTS" | grep -qE -e '-H|--host'; then
    59  		DOCKER_SOCKET=/var/run/docker.sock
    60  	else
    61  		DOCKER_SOCKET=$(printf "%s" "$DOCKER_OPTS" | grep -oP -e '(-H|--host)\W*unix://\K(\S+)' | sed 1q)
    62  	fi
    63  
    64  	if [ -n "$DOCKER_SOCKET" ]; then
    65  		while ! [ -e "$DOCKER_SOCKET" ]; do
    66  			initctl status $UPSTART_JOB | grep -qE "(stop|respawn)/" && exit 1
    67  			echo "Waiting for $DOCKER_SOCKET"
    68  			sleep 0.1
    69  		done
    70  		echo "$DOCKER_SOCKET is up"
    71  	fi
    72  end script