Docker Community Forums

Share and learn in the Docker community.

Getting crazy setting static ip-address on the docker compose


(Guyman2) #1

Hi,
I read now for 1 day and played around how to set a static ip to each container on the compose file.

However, things do not work as wanted :(.

I created a custom bridge on my docker host, and if I run docker run --ip x.x.x.x this is working perfectly.
On the docker compose, when I understand this right, with “networks” I can only created a new network which then overlays with the concurrent one and this fails.
I just want to assign a static ip from my custom bridge like when I run docker run.
Is this possible, or do I think false ?

Thanks for any help!
best,
Ronny


(Jica) #2

Why do you need to set a static IP to a container?

if this is to setup other containers, you can use the service name from inside other containers, iex: I have a mysql service, then I configure my wordpress to use “mysql” instead of a static IP.

If this is to have access to a specific container from outside, you can port-forward a specific port, so you can access using your host ip and that port.