如何将 docker-machine 连接到我的虚拟机 docker-daemon 端口?

how to connect docker-machine to my VMs docker-daemon port?

鉴于这两个系统:

两个虚拟机都通过网桥连接。我可以从 jenkins 容器中卷曲 VM#2 上的 Docker-Host。

现在我想告诉 docker-machine 在我的 jenkins 容器中使用 VM#2 Docker-Host.

构建一个镜像(位于 jenkins 工作区内)

所有关于此的文档仅向我显示像 virtualbox 或 aws 这样的驱动程序,但我想连接到我自己创建的 Docker-Host。

我试过的:

在我的 Jenkins 容器中 我创建了两个环境变量:

$ export DOCKER_HOST=tcp://192.168.0.102:2375 
$ export DOCKER_MACHINE_NAME=dev

curl 192.168.0.102:2375 产生 {"message":"page not found"}

运行 docker-machine env dev 给我 Host does not exist: "dev"

PS:

I do not want to install docker-engine into my jenkins image. I want to use the thin-client docker-machine to delegate the image build over to VM#2 and nothing more

假设 VM#1 是 192.168.33.100,VM#2 是 192.168.33.101。两者可以相互联系。现在你根本不需要 docker-machine 进入画面。你可以按照下面的方式做

export DOCKER_HOST=tcp://192.168.33.101:2375/
docker build ....

假设您为 docker 主机打开了端口 2375。有关此环境变量的详细信息,请参阅下面的 url

https://docs.docker.com/engine/reference/commandline/cli/#environment-variables

编辑-1

如果您想将现有机器添加到 docker-machine,您可以使用下面的方法

docker-machine create --driver none -url=tcp://VM2:2376 VM2

Note: You would also need to setup TLS for this else it would not work with Docker-machine directly because of the open issue https://github.com/docker/machine/issues/1532