Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to connect Docker Machine to a remote Docker VirtualBox

I'm trying to use Docker Machine to connect to a Docker VirtualBox VM on a different host. At my local host, the setup is successful, including examples installing Busybox and echo a 'hello world' from a VM called 'dev', like this:

$ docker $(docker-machine config dev) run busybox echo hello world

I can create as many comparable local Docker VirtualBox VMs I like with Docker Machine and the result is similar succesful.

Now I would like to do the same using my local Docker Machine and execute docker commands on a different physical host where I installed Docker Machine and Boot2Docker as well. In other words: I would like to use my local Docker Machine CLI and remotely command to e.g. pull an image and run a container on that different host. Is that possible, and if so, how?

like image 447
cvuijst Avatar asked Oct 20 '22 18:10

cvuijst


1 Answers

I just tested with dind (Docker-in-Docker) here is the link So all you have to do is run this in your host: Docker Host IP: 172.17.42.1

  1. docker run --rm swarm create #get cluster_id
  2. docker run --privileged -d -p 1234:1234 -e PORT=1234 jpetazzo/dind
  3. docker -H tcp://DOCKER_HOST:1234 run -d swarm join --addr=DOCKER_HOST:1234 token://cluster_id

you can create another node by

  1. docker run --privileged -d -p 1235:1235 -e PORT=1235 jpetazzo/dind
  2. docker -H tcp://DOCKER_HOST:1235 run -d swarm join --addr=DOCKER_HOST:1235 token://cluster_id

  3. docker run -d -p 2375:2375 swarm manage token://cluster_id

Check is everything OK docker -H tcp://DOCKER_HOST:2375 info

If you see 2 container, you are successfully created swarm cluster and docker machines as docker container.

like image 124
user212806 Avatar answered Oct 22 '22 21:10

user212806