Yes, it’s perfectly possible to run two Docker daemons on a single host even without Docker Machine. As of Docker 18.09.0-ce, the following dockerd flags are the ones that could cause conflicts if two daemons used the defaults:
-b, --bridge string Attach containers to a network bridge
--exec-root string Root directory for execution state files (default "/var/run/docker")
--data-root string Root directory of persistent Docker state (default "/var/lib/docker")
-H, --host list Daemon socket(s) to connect to
-p, --pidfile string Path to use for daemon PID file (default "/var/run/docker.pid")
-
The default for
--bridgeisdocker0, and if you’re not using the default, you must create and configure the bridge manually (Docker won’t create/manage it for you). More details below. -
--exec-rootis where container state is stored (default:/var/run/docker). -
--data-rootis where images are stored (default:/var/lib/docker). -
--hostspecifies where the Docker daemon will listen for client connections. If unspecified, it defaults to/var/run/docker.sock. -
--pidfileis where the process ID of the daemon is stored (default:/var/run/docker.pid).
So, as long as your two daemons use different values for these flags, you can run them on the same host. Example script (including network setup):
#!/bin/sh
## name: altdocker.sh
set -e -x
: ${bridge=altdocker}
: ${base=$HOME/$bridge}
# Set up bridge network:
if ! ip link show $bridge > /dev/null 2>&1
then
sudo ip link add name $bridge type bridge
sudo ip addr add ${net:-"10.20.30.1/24"} dev $bridge
sudo ip link set dev $bridge up
fi
sudo dockerd \
--bridge=$bridge \
--data-root=$base.data \
--exec-root=$base.exec \
--host=unix://$base.socket \
--pidfile=$base.pid
Example usage:
## in one terminal
$ env net=10.9.8.7/24 /bin/sh altdocker.sh
# ... log output ...
## in another terminal
$ docker -H unix://$HOME/altdocker.socket run --rm -i -t alpine sh
/ # echo hereiam
hereiam
Updated for changes from Docker 1.9.1 to 18.09.0-ce, in case anyone is using a very old version:
┌───────────────┬─────────────┐
│ 1.9.1 │ 18.09.0-ce │
├───────────────┼─────────────┤
│ docker daemon │ dockerd │
│ -g / --graph │ --exec-root │
└───────────────┴─────────────┘