By Cláudio
Hello! How can I configure Docker to exclusively use this private network? How to make the network interface that the docker creates docker0 only use the private network?
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
At its simplest, you can bind a container to a specific network at runtime. For example, the nginx container exposes port 80. To bind that to port 8080 on your Droplet’s private network, run:
docker run -p priv.net.ip.addr:8080:80 nginx
Docker also provides many more complex networking options. For a high level overview, see:
For a deeper dive, take a look at “Understand Docker container networks” from the Docker docs.
Using some of the concepts covered there, you could also create a new bridge network that is available over your private IP address. For example,
docker network create -o "com.docker.network.bridge.host_binding_ipv4"="priv.net.ip.addr" privnet
Now to specify that a container should use this new bridge network instead of using docker0, run it with:
docker run --net=privnet -p 8080:80 nginx
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.