Creating Static IP addresses in a Docker Network

Creating Static IP addresses in a Docker Network

I self host a lot of different software in my network. Databases, applications, and test VM’s that require the use of static ip addresses in Docker. I researched the problem and found out there was no easy way of just assigning a default static ip address. IP’s were given out on a first boot first serve basis.

I workaround I have found is to add docker containers to a second network where you are allowed to assign an ip address to them, thus making them routable.

docker network create --driver bridge --subnet --gateway docker-network

docker network connect --ip docker-network mysql-5.6

docker network connect --ip docker-network mysql-5.7

docker network disconnect docker-network mysql-5.6

docker network disconnect docker-network mysql-5.7

Hopefully this will help you in your efforts to make a self host infrastructure in your homelab.


If you are using portainer then is what it would look like after you set it up. *Note* The name of this network in man-ip (a custom network that is set to bridge). There are ways to make it an internal network that is not accessible to the greater internet, but I chose not to do that.

Portainer view of a custom network

In a future guide I will show how to set up a Portainer instance on a docker setup. For now if you want to read more, try this post out!

How to set up a network wide ad-blocker