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.
Sign-up to your docker hub repository.
Search for the Jenkins image and use the docker pull command to download the Jenkins image on your local server.
Download Jenkins’s image using the below command:
sudo docker pull jenkins
To see the ports exposed by the Jenkins container type docker inspect command.
docker inspect Continer/image
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.
These are all the steps required to map the port number of the container to the port number of the docker host.
Attention reader! Don’t stop learning now. Get hold of all the important CS Theory concepts for SDE interviews with the CS Theory Course at a student-friendly price and become industry ready.