Skip to content
Related Articles

Related Articles

How to Map Ports in Docker?

View Discussion
Improve Article
Save Article
Like Article
  • Last Updated : 22 Jun, 2021

In docker, all the application in the container runs on particular ports when you run a container. If you want to access the particular application with the help of port number you need to map the port number of the container with the port number of the docker host.


In the implementation, we are going to download a Jenkins container from the docker hub and map the Jenkins container port number with the docker host port number.

Step 1:

Sign-up to your docker hub repository.

docker sign in page

Sign-up in docker hub

Step 2:

Search for the Jenkins image and use the docker pull command to download the Jenkins image on your local server.

docker console

Step 3:

Download Jenkins’s image using the below command:

sudo docker pull jenkins

downloading jenkins

Step 4:

To see the ports exposed by the Jenkins container type docker inspect command.

docker inspect Container/image


Step 5:

In this step, we run Jenkins and map the port by changing the docker run command by adding the p option which specifies the port mapping.

sudo docker run -p 8080:8080 50000:500000 jenkins

On the left-hand side, it is the Docker host port number and on the right-hand side Docker container number.

mapping port

These are all the steps required to map the port number of the container to the port number of the docker host. 

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!