Docker Community Forums

Share and learn in the Docker community.

Connect to a docker-compose managed container from the host machine

I am running a few services via docker-compose. I can see that a docker network is created and all the containers are added to the network thereby enabling them to communicate with each other using the service name.

I understand that I can map the ports exposed by the container to the host machine. However, I would like to connect directly to the container from the host machine. Specifically, I am connecting to the port 443 exposed on the nginx service container.

When I did docker inspect and tried to connect to the nginxDockerContainerIP:443 from the host machine, I was not successful. I am able to connect to this endpoint from within other containers (as expected).

I am thinking that the former fails because the host machine is not part of the docker network created by compose. Is this intuition right? Is there a way I can connect to the nginx docker container 443 port directly from my browser running on host machine?