Steps To Expose More Than One Port With Docker

Step 1: First, pull the Docker image using the below command. I have here used the jaegartracing Docker image.

docker pull jaegertracing/all-in-one:1.6

Step 2 : Run the docker image using this command .

docker run -d --name jaeger \
-e COLLECTOR_ZIPKIN_HTTP_PORT=9411 \
-p 5775:5775/udp \
-p 6831:6831/udp \
-p 6832:6832/udp \
-p 5778:5778 \
-p 16686:16686 \
-p 14268:14268 \
-p 9411:9411 \
jaegertracing/all-in-one:1.6

Here i am using jaegartracing image , just like this you can use other docker images . The basic command structure to expose multiple ports is :

docker run -d -p <host-port-1>:<container-port-1> -p <host-port-2>:<container-port-2> your-docker-image

Step 3: Now access these ports , and you can see the different website content . For example, at port 16686 you will see :

And at port 5778 you will see :

How Can I Expose More Than 1 Port With Docker ?

Docker is an important tool that simplifies the deployment process by encapsulating applications within a container. To facilitate various types of communication in a Docker container, we need to expose more than one port. Here in this guide, I will first cover what Docker is and how it has become an essential tool among developers. Then I will guide you through the different steps and Docker commands to expose more than one port in the Docker container.

Similar Reads

What is Docker?

Docker is an important tool that is used to encapsulate the application and its dependencies into compact units called Docker containers. This Docker container contains all the application code, runtime, libraries, and other tools that an application needs to run. Here for the application, a Dockerfile is created where the base operating system image, all the other dependencies, installation command, and command to run the application are mentioned. This Dockerfile is then built to generate a Docker image. The Docker image is very lightweight and portable. By using this Docker image, we can run a Docker container on any operating system. This allows developers to run their application code on their operating system without facing any errors related to the operating system or hardware requirements. Developers can run multiple Docker containers on a single host. This results in maximizing resource utilization and reducing infrastructure costs. Docker has overall become a very important and essential tool for developers and organizations to accelerate their software deployment and delivery pipelines....

Pre-requisites

Before moving on to the next section, make sure that you have installed Docker on your system. If you have not installed Docker, then follow these detailed Docker installation geeks for geeks articles to install Docker on your system....

Steps To Expose More Than One Port With Docker

Step 1: First, pull the Docker image using the below command. I have here used the jaegartracing Docker image....

Conclusion

Here in this guide first you have learned what is Docker and why it used . Then you have followed the steps to expose more than one port to access the docker container. And finally you have accessed the ports form your host machine IP and different ports that is associated with the docker container to see all the ports are working properly or not....

How can I expose more than 1 port with Docker – FAQ’s

How to expose ports in a Docker container?...