Docker Port

Docker Port

Docker Port

Docker port is used to expose the running service inside the container to out side network.
Let’s say you have deployed one Nginex or Apache Server container and inside the container one website is running on port 80. Now, you went to access the web page from out side of the container, then in this case, Port will useful for you. You need to expose or map a port out side running port.

Docker Port commands

To Check which port is exposed on a container

$ sudo docker container ls
or
$ sudo docker port <container-id/name>

In above image, you can see nothing is exposed on a container port.

To Expose Port on container and run container in background

$ sudo docker run -td –name <container-name> -p 80:80 <image-type>

Example

Now check the exposed port

$ sudo docker port <container-name>

Example

Leave a Comment

Your email address will not be published. Required fields are marked *

wpChatIcon