×
Configure port mapping for windows container
Blog Containers

Configure port mapping for windows container

Configure port mapping for windows container

In this blog, we will show you configure port mapping for windows container using docker commands.

 

INTRODUCTION

We need to configure the port mapping to access the web application inside the container. Need to specify the source and destination port while creating the containers.

 

PORT MAPPING

  • To configure the port mapping while creating the container, use the below command.

 

SYNTAX: docker run -it -p <source port of windows container host>:<destination port in the container> <container image>

Example : docker run -it -p 80:80 azcontainerr/web

 

docker – Base command for docker CLI

run – To start a new container

-it – Run in interactive mode

-p – Specify the port mapping

80 (left hand side) source port– Map the windows container host port.

80(right hand side) Destination port – Map the container port.

azcontainerr/web – Container Image.

 

Configure port mapping for windows container

 

  • Once the container is up and running, type ipconfig to view the IP details.

Configure port mapping for windows container

 

  • We got an IP as 10.0.0.190. Now the NAT translation has been set from the host IP to container IP.

 

  • Press CTRL+PQ to disconnect from the container.

Configure port mapping for windows container

 

  • Type docker ps command.

Configure port mapping for windows container

 

  • You can see our port mapping has been shown above.

 

  • Now we use the windows container host IP (192.168.232.80) to access the container web application.

 

  • We cannot access the web application using container host IP from container host itself. This limitation is how windows NAT works. We hope microsoft will fix in the future version. If we try to browse the container host IP through web browser, will receive the below output.

Configure port mapping for windows container

 

  • You can able to access the container application using container IP (10.0.0.190).

Configure port mapping for windows container

 

  • Able to access the windows container host IP from the client machine.

Configure port mapping for windows container

VIDEO

Thanks for reading this blog. We hope it was useful for you to learn to configure port mapping for windows container.

5 thoughts on “Configure port mapping for windows container”

  1. Hi Loges
    I am currently working for one of the biggest companies in Africa but i am based in South Africa, I have validated my skills in Windows 10 (MCSA). I am busy with server 2016, I have so far passed 1 module (70-740). I am busy with 70-741 which is not an easy one. So when i have obtained MCSE 2016, i want to resign and go back to my home town to provide cloud services there, so I would like to find out what do i need to have to start a Cloud consulting company, is it only my skills or there are other compulsory equipment i need for starting this kind of a company? Thank you for reading and reply.

  2. Hi Sindisa,

    Thanks for contacting us. Actually, MCSE is not sufficient to start the cloud consulting company. You need to learn about cloud stack, OpenStack, AWS, Azure and Google Kubernetes.

    Make sure that you have enough knowledge of these cloud technologies before starting the company. Also, keep watching the current technology on the market. So that you can travel along with them.

    Regards,
    Loges

  3. Hi Lozes,

    Thanks a lot, i was really struggling to understand this functionality. This article helps me in understanding the Port functionality verywell

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.