In our example, we will download the Jenkins container from Docker Hub. We are then going to map the Jenkins port number to the port number on the Docker host.
Step 1 − First, you want to do a simple sign-up on Docker Hub.
Step 2 −Once you have signed up, you will be logged into Docker Hub.
Step 3 − Next, let's browse and find the Jenkins image.
Step 4 − If you scroll down on the same page, you can see the Docker pull command. This will be used to download the Jenkins Image onto the local Ubuntu server.
Step 5 − Now go to the Ubuntu server and run the command −
sudo docker pull jenkins
Step 6 − To understood ports are exposed by the container, you should use the Docker inspect command to inspect the picture.
This method permits one to return low-level information on the container or image. We should now look further into this inspect command.
docker inspect Container/Image
sudo docker inspect jenkins
The output of the inspect command gives a JSON output. If we notice the output, we can see that there is a section of "ExposedPorts" and see that there are two ports referenced. One is the data port of 8080 and the other is the control port of 50000.