github.com/fcwu/docker@v1.4.2-0.20150115145920-2a69ca89f0df/contrib/init/upstart/docker.conf (about)

     1  description "Docker daemon"
     2  
     3  start on (local-filesystems and net-device-up IFACE!=lo)
     4  stop on runlevel [!2345]
     5  limit nofile 524288 1048576
     6  limit nproc 524288 1048576
     7  
     8  respawn
     9  
    10  pre-start script
    11  	# see also https://github.com/tianon/cgroupfs-mount/blob/master/cgroupfs-mount
    12  	if grep -v '^#' /etc/fstab | grep -q cgroup \
    13  		|| [ ! -e /proc/cgroups ] \
    14  		|| [ ! -d /sys/fs/cgroup ]; then
    15  		exit 0
    16  	fi
    17  	if ! mountpoint -q /sys/fs/cgroup; then
    18  		mount -t tmpfs -o uid=0,gid=0,mode=0755 cgroup /sys/fs/cgroup
    19  	fi
    20  	(
    21  		cd /sys/fs/cgroup
    22  		for sys in $(awk '!/^#/ { if ($4 == 1) print $1 }' /proc/cgroups); do
    23  			mkdir -p $sys
    24  			if ! mountpoint -q $sys; then
    25  				if ! mount -n -t cgroup -o $sys cgroup $sys; then
    26  					rmdir $sys || true
    27  				fi
    28  			fi
    29  		done
    30  	)
    31  end script
    32  
    33  script
    34  	# modify these in /etc/default/$UPSTART_JOB (/etc/default/docker)
    35  	DOCKER=/usr/bin/$UPSTART_JOB
    36  	DOCKER_OPTS=
    37  	if [ -f /etc/default/$UPSTART_JOB ]; then
    38  		. /etc/default/$UPSTART_JOB
    39  	fi
    40  	exec "$DOCKER" -d $DOCKER_OPTS
    41  end script
    42  
    43  # Don't emit "started" event until docker.sock is ready.
    44  # See https://github.com/docker/docker/issues/6647
    45  post-start script
    46  	DOCKER_OPTS=
    47  	if [ -f /etc/default/$UPSTART_JOB ]; then
    48  		. /etc/default/$UPSTART_JOB
    49  	fi
    50  	if ! printf "%s" "$DOCKER_OPTS" | grep -qE -e '-H|--host'; then
    51  		while ! [ -e /var/run/docker.sock ]; do
    52  			initctl status $UPSTART_JOB | grep -q "stop/" && exit 1
    53  			echo "Waiting for /var/run/docker.sock"
    54  			sleep 0.1
    55  		done
    56  		echo "/var/run/docker.sock is up"
    57  	fi
    58  end script