How to reach a container from another container without IP of dockerNAT?

@boistordu, do you want this to be available from another container or from the host?

if it’s from the host, run -p hostport:containerport should work fine to route containerport to 0.0.0.0 (localhost included here)

if it’s from container to container, put them on the same docker network

$ docker network create mynet

$ docker run --name foo --net mynet img

$ docker run --name bar --net mynet img

You will be able to reach foo and bar from each other using DNS entries corresponding to the container name, e.g. curl foo should work from bar if you’re serving something on port 80/443 in foo

1 Like