Created
January 20, 2019 05:48
-
-
Save achimnol/707987379a529c6f8627312db2e61064 to your computer and use it in GitHub Desktop.
Running alternative Docker daemon on the same host
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/bash | |
# References: | |
# - https://stackoverflow.com/questions/32334167/is-it-possible-to-start-multiple-docker-daemons-on-the-same-machine | |
# - https://docs.docker.com/engine/reference/commandline/dockerd/ | |
# First you need to have Docker 18.09+ and the bridge-utils package installed. | |
ROOT=/opt/altdocker | |
: ${bridge=altdocker0} | |
: ${base=$ROOT/$bridge} | |
if ! ip link show $bridge > /dev/null 2>&1 | |
then | |
brctl addbr $bridge | |
ip addr add ${net:-"10.9.0.1/24"} dev $bridge | |
ip link set dev $bridge up | |
fi | |
# NOTE: "--config-file" must be specified to avoid conflicts with system Docker. | |
dockerd \ | |
--exec-root=$ROOT/docker/run \ | |
--data-root=$ROOT/docker/data \ | |
--config-file=$ROOT/docker/etc/daemon.json \ | |
--storage-driver=overlay2 \ | |
--bridge=altdocker0 \ | |
--host=unix://$ROOT/docker.sock \ | |
--pidfile=$ROOT/docker.pid | |
# To use this Docker daemon, | |
# DOCKER_HOST=unix:///opt/altdocker/docker.sock docker run --rm -it alpine:3.8 sh -c "hello world" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment