1

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

1 Answer 1

5

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, and container:<name|id>. Any other value is taken as a custom network’s name to which this container should connect to.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.