Docker Community Forums

Share and learn in the Docker community.

Set a container with a static IP from the local network

Is it possible to set a container with an static IP different from the host?

For example:
host’s IP: 10.180.160.3

Could I set a cointainer inside that host with an IP like: 10.180.160.4.

And an external service get recognize both IPs when an HTTP request is made from them?

Yes and no: not by only using containers.
Though, why not add another virtual interface to your host interface and assign it the ip you want? Publised ports will always listen on all interfaces…

The other alternative is to use macvlan, which allows to hook a macvlan client interface in your lan. Though you container will only bound to this ip.