如何使用 docker remote api 使用另一个容器的网络命名空间创建容器
How to use docker remote api to create a container using another container's network namespace
我可以运行以下命令来使用另一个容器的网络命名空间创建一个容器:
docker run -it --net=container:<container_name> ubuntu:14.04
运行ning之后,两个容器的IP地址相同。我想知道如何使用 docker 远程 api 或其他客户端 api 来做到这一点。
我的docker服务器&客户端版本是1.10.3
docker run
基本上是 docker create
其次是 docker start
。您可以在 API reference.
中找到 /containers/create
端点的文档
您要查找的属性是HostConfig
中的NetworkMode
;
NetworkMode - Sets the networking mode for the container. Supported standard values are: bridge
, host
, none
, and container:<name|id>
. Any other value is taken as a custom network’s name to which this container should connect to.
我可以运行以下命令来使用另一个容器的网络命名空间创建一个容器:
docker run -it --net=container:<container_name> ubuntu:14.04
运行ning之后,两个容器的IP地址相同。我想知道如何使用 docker 远程 api 或其他客户端 api 来做到这一点。
我的docker服务器&客户端版本是1.10.3
docker run
基本上是 docker create
其次是 docker start
。您可以在 API reference.
/containers/create
端点的文档
您要查找的属性是HostConfig
中的NetworkMode
;
NetworkMode - Sets the networking mode for the container. Supported standard values are:
bridge
,host
,none
, andcontainer:<name|id>
. Any other value is taken as a custom network’s name to which this container should connect to.