Reputation: 129
I can run the following command to make a container using another container's network namespace:
docker run -it --net=container:<container_name> ubuntu:14.04
After running it, the two container have the same IP address. I want to know how to use the docker remote api or other client api to do it.
My docker server&client version is 1.10.3
Upvotes: 1
Views: 1761
Reputation: 28987
docker run
is basically docker create
followed by docker start
. You can find the documentation for the /containers/create
endpoint in the API reference.
The property you're looking for is the NetworkMode
in the HostConfig
;
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.
Upvotes: 5