Reputation: 1131
I ran a nginx container without specifying the host port.
docker container run -d --name engineone nginx
When I check the running containers it shows that container I ran.
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
d6b1d457b0b1 nginx "nginx -g 'daemon of…" About an hour ago Up 58 minutes 80/tcp engineone
Now I want to know which port has taken by the engineone
container. So I ran..
docker container port engineone
But the output gives nothing. I have some knowledge in how docker networking works but I would like to know how is this possible. Does it really runs without host port?
Upvotes: 0
Views: 403
Reputation: 1131
Done some research throughout the day, In docker docs..
By default, when you create a container, it does not publish any of its ports to the outside world. To make a port available to services outside of Docker, or to Docker containers which are not connected to the container’s network, use the
--publish
or-p
flag. This creates a firewall rule which maps a container port to a port on the Docker host.
So in here docker won't assign a port util we tell it to do.
Upvotes: 1