How do I give a docker container its own routable IP on the original network?

This tends to be an anti-pattern in the container space. One common solution instead of externally accessing the container directly, is to setup a load balancer per IP that you need to expose, and that load balancer maps a well known port to the unique port. In the cloud space, this is often cheaper than allocating multiple VM's with different IP's.


You can publish directly to a single IP address with docker. e.g.:

docker run -p 192.168.0.3:22:22 sshd

This requires that the host have each of the IP addresses configured which has been described in other SE Q&A's.


If you still need the original request, directly exposing the container, you can use macvlan or ipvlan network drivers to give the container an externally reachable IP. I tend to avoid this since it's often the symptom of trying to manage a container as if it is a VM. Documentation on macvlan is at: https://docs.docker.com/network/macvlan/