How can I expose more than 1 port with Docker?
You can expose more than one port in a Docker container by using the -p
option when starting the container. The -p
option maps a port on the host machine to a port in the container. You can specify multiple port mappings by using multiple -p
options.
Here's an example of how to expose two ports, port 80 and port 443:
docker run -d -p 80:80 -p 443:443 my-image
In this example, the -p 80:80
option maps port 80 on the host machine to port 80 in the container, and the -p 443:443
option maps port 443 on the host machine to port 443 in the container.
Note that when you expose multiple ports in a Docker container, the container must be configured to listen on those ports.
-
How to Mount a Host Directory in a Docker Container?
If you want to mound a host directory in a Docker container, you have to main ways to do that: Using the ADD command: The simplest way is to use the dockers ADD command as shown below: ADD . /path/...
Questions -
How Do I Pass Environment Variables to Docker Containers?
It is always a good practice to separate the app from its configuration. It is not a good idea to have a database login credential defined as variables in the code of the application. This is why w...
Questions -
What is the runtime performance cost of a Docker container
The runtime performance cost of a Docker container can depend on a variety of factors, such as the host system's hardware resources, the size and complexity of the container, the workload running i...
Questions -
How to Run a Docker Image as a Container?
Docker runs processes in isolated containers. A container is a process that runs on a host. The host may be local or remote. When an operator executes docker run, the container process that runs is...
Questions
Make your mark
Join the writer's program
Are you a developer and love writing and sharing your knowledge with the world? Join our guest writing program and get paid for writing amazing technical guides. We'll get them to the right readers that will appreciate them.
Write for usBuild on top of Better Stack
Write a script, app or project on top of Better Stack and share it with the world. Make a public repository and share it with us at our email.
community@betterstack.comor submit a pull request and help us build better products for everyone.
See the full list of amazing projects on github