Docker Community Forums

Share and learn in the Docker community.

Map port of container to another container

(Krommel) #1

Hi, I’m new to docker and and created three containers (web,db,solr) with cocker-compose.
These containers are linked to each other. E.g. web can connect to solr.
Although I have a port mapping, that the host can reach container “web” on port 80.

Now I want the web container to be able to reach the solr container on localhost:8080.
I need something like the port mapping from container to host between containers.

Is this possible?

(Nathan Le Claire) #2

I’d recommend to use Compose V2 format: and put the containers on the same network.

Then, when you need to access one container from another, you can simply make a request to the DNS entry of the container’s name, e.g. if the container is called solr and you want to hit its port 8080, you simply call solr:8080 from within the client container.