mirror of
https://github.com/linuxkit/linuxkit.git
synced 2025-12-08 05:57:53 +00:00
I had occasion to use a Moby build of 1.12 on Docker for Mac today and I had to patch this in. Given that we re-added support for 1.12 for cloud, for CS, may as well support on OSX too as we are still doing releases. The fix is a bit messy (hence the flag), as it writes to the file system but we will remove it later, or work around the write if we need to continue to support 1.12 outside the 1.12.x branch. Signed-off-by: Justin Cormack <justin.cormack@docker.com>
132 lines
3.5 KiB
Plaintext
Executable File
132 lines
3.5 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" ] && \
|
|
export PATH=$bundle/binary-client:$bundle/binary-daemon:$PATH && \
|
|
printf "Overriding Docker with provided bundle: $bundle\n"
|
|
fi
|
|
|
|
command="${DOCKER_BINARY:-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"
|
|
|
|
# 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
|
|
|
|
[ -f /etc/docker/daemon.json ] || printf '{}' > /etc/docker/daemon.json
|
|
|
|
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
|
|
if dockerd --help | grep -q -- --userland-proxy-path; then
|
|
DOCKER_OPTS="${DOCKER_OPTS} --userland-proxy-path /usr/bin/slirp-proxy"
|
|
else
|
|
cp /usr/bin/slirp-proxy /usr/bin/docker-proxy
|
|
fi
|
|
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
|
|
cat /etc/docker/daemon.json | jq -e 'has("debug")' > /dev/null || DOCKER_OPTS="${DOCKER_OPTS} --debug"
|
|
|
|
# Set experimental=true if not specified in daemon.json and on 1.13+
|
|
if dockerd --help | grep -q -- --experimental
|
|
then
|
|
cat /etc/docker/daemon.json | jq -e 'has("experimental")' > /dev/null || DOCKER_OPTS="${DOCKER_OPTS} --experimental"
|
|
fi
|
|
|
|
# choose storage driver
|
|
if ! $(cat /etc/docker/daemon.json | jq -e '."storage-driver"' > /dev/null)
|
|
then
|
|
STORAGE_DRIVER="overlay2"
|
|
[ -d /var/lib/docker/aufs ] && STORAGE_DRIVER="aufs"
|
|
DOCKER_OPTS="${DOCKER_OPTS} --storage-driver ${STORAGE_DRIVER}"
|
|
fi
|
|
|
|
# set ulimits as high as possible
|
|
ulimit -n 1048576
|
|
ulimit -p unlimited
|
|
# set locked memory higher for varnish
|
|
ulimit -l 82000
|
|
|
|
DOCKER_LOGFILE="/var/log/docker.log"
|
|
|
|
case "$(mobyplatform)" in
|
|
windows|mac)
|
|
# Allow iptables to be overriden
|
|
export PATH=/usr/local/sbin:$PATH
|
|
;;
|
|
esac
|
|
|
|
start-stop-daemon --start --quiet \
|
|
--background \
|
|
--startas /bin/sh \
|
|
--pidfile ${pidfile} \
|
|
-- -c "exec ${command} --pidfile=${pidfile} ${DOCKER_OPTS} 2>&1 | logger -p local0.info"
|
|
|
|
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
|
|
}
|