Files
linuxkit/alpine/packages/docker/etc/init.d/docker
Justin Cormack 9a96f5da8c Add support for running a development bundle of Docker
Add a database key `bundle` that contains a path to a Docker dev
bundle eg `/.../docker/bundles/1.13.0-dev` where the docker
binaries to run can be found. This will be paired with a script
in `docker/docker` to set this key, so users can easily help
contribute to Docker development.

The change will be permanent until the key is removed or a factory
reset is done, or the bundle cannot be found.

Signed-off-by: Justin Cormack <justin.cormack@docker.com>
2016-09-13 22:46:27 +01:00

127 lines
3.4 KiB
Plaintext
Executable File

#!/sbin/openrc-run
depend()
{
after transfused
}
start()
{
ebegin "Starting Docker"
# check if overriding Docker with a dev bundle
if mobyconfig exists bundle
then
bundle=$(mobyconfig get bundle)
[ -n "$bundle" -a -d "$bundle" -a -h "$bundle/binary-client/docker" ] && \
# note we copy all the symlinks, in case layout changes
cp -a $bundle/binary-client/* \
$bundle/binary-daemon/* \
/usr/bin
printf "Overriding Docker with provided bundle: $bundle\n"
fi
command="${DOCKER_BINARY:-/usr/bin/dockerd}"
pidfile="/run/docker.pid"
# mount /run shared eg for volume drivers
mount --make-shared /run
# create cgroups mount for systemd containers
if [ ! -d /sys/fs/cgroup/systemd ]
then
mkdir -p /sys/fs/cgroup/systemd
mount -t cgroup -o none,name=systemd cgroup /sys/fs/cgroup/systemd
fi
# Only start with networking on cloud editions
DOCKER_OPTS="${DOCKER_OPTS} -H unix:///var/run/docker.sock"
if [ "$(mobyplatform)" = "aws" ] || [ "$(mobyplatform)" = "azure" ]
then
# TODO: Don't do this
DOCKER_OPTS="${DOCKER_OPTS} -H 0.0.0.0:2375"
fi
# On desktop editions, force swarm advertise address to be on eth0
# Currently we do not support multi node swarm on these editions
# for cloud plartforms the init scripts set this up
case "$(mobyplatform)" in
windows|mac)
DOCKER_OPTS="${DOCKER_OPTS} --swarm-default-advertise-addr=eth0"
;;
esac
# some config is always in /etc/docker cannot specify alternative eg certs
mkdir -p /etc/docker
if mobyconfig exists etc/docker
then
for f in $(mobyconfig find etc/docker)
do
mkdir -p $(dirname $f)
mobyconfig get $f > $f
done
fi
if mobyconfig exists network
then
NETWORK_MODE="$(mobyconfig get network | tr -d '[[:space:]]')"
NATIVE_PORT_FORWARDING="$(mobyconfig get native/port-forwarding | tr -d '[[:space:]]')"
if [ "${NETWORK_MODE}" = "slirp" -o "${NATIVE_PORT_FORWARDING}" = "true" ]; then
cp /usr/bin/slirp-proxy /usr/bin/docker-proxy
fi
fi
if mobyconfig exists proxy
then
export http_proxy="$(mobyconfig get proxy/http)"
export https_proxy="$(mobyconfig get proxy/https)"
export no_proxy="$(mobyconfig get proxy/exclude)"
fi
# Set Docker to debug debug if not specified in daemon.json
([ -f /etc/docker/daemon.json ] && cat /etc/docker/daemon.json | jq -e .debug > /dev/null) || DOCKER_OPTS="${DOCKER_OPTS} --debug"
# shift logs onto host before docker starts
# busybox reopens its log files every second
if cat /proc/cmdline | grep -q 'com.docker.driver'
then
DRIVERDIR="/host_docker_app/$(cat /proc/cmdline | sed -e 's/.*com.docker.driver="//' -e 's/".*//')"
if ! grep -q "osxfs on /var/log" /proc/mounts ; then
mkdir -p /run/log
mount -o bind /var/log /run/log
mount --bind "${DRIVERDIR}/log" /var/log
fi
fi
# set ulimits as high as possible
ulimit -n 1048576
ulimit -p unlimited
DOCKER_LOGFILE="/var/log/docker.log"
# Allow iptables to be overriden
export PATH=/usr/local/sbin:$PATH
start-stop-daemon --start --quiet \
--background \
--exec ${command} \
--pidfile ${pidfile} \
--stderr "${DOCKER_LOGFILE}" \
--stdout "${DOCKER_LOGFILE}" \
-- --pidfile=${pidfile} ${DOCKER_OPTS}
ewaitfile 20 ${pidfile} /var/run/docker.sock /var/run/docker/libcontainerd/docker-containerd.sock
eend $? "Failed to start docker"
}
stop()
{
# stop docker
einfo "Stopping docker"
pidfile="/run/docker.pid"
start-stop-daemon --stop --quiet --pidfile ${pidfile} --retry 15
return 0
}