从现有容器中剥离主机上的另一个容器

Spin off another container on host machine from an existing container

我目前正在为 Mac 使用 Docker 桌面。

我的要求是从另一个容器中分离出一个容器

情况:

容器 A 有一个服务 运行,它根据请求寻找群管理器并分离出另一个容器 B。我已经在我的机器上启动了单节点群管理器。我不能使用主机 network_mode,因为 docker for MAC 将轻量级 linux 虚拟机暴露为主机,而不是我实际的本地主机。我也试过这个:https://forums.docker.com/t/access-host-not-vm-from-inside-container/11747/7

任何可能的解决方案?

想法是您的容器可以访问您的主机。因此,使用 Docker:

提供的 Engine API
POST /containers/create

您必须 post json 包含新容器的详细信息。

Engine API v1.24

The daemon listens on unix:///var/run/docker.sock but you can Bind Docker to another host/port or a Unix socket.

You can listen on port 2375 on all network interfaces with -H tcp://0.0.0.0:2375, or on a particular network interface using its IP address: -H tcp://192.168.59.103:2375. It is conventional to use port 2375 for un-encrypted, and port 2376 for encrypted communication with the daemon.