Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

272
Vistas
How to expose ports only within the docker network?

I have a few apps running in a Docker network with their ports (3000,4200, etc) exposed. I also have an nginx container running within the same Docker network which hosts these apps on port 80 with different domain names (site1.com, site2.com).

But right now if I go directly to the ports the apps are running on (localhost:3000) I can access them that way too.

How do I expose those ports only to the nginx container and not the host system?

about 4 years ago · Santiago Trujillo
2 Respuestas
Responde la pregunta

0

But right now if I go directly to the ports the apps are running on (localhost:3000) I can access them that way too.

Thats because you are using -p aka --publish command in your docker run

Explanation:

If you want to expose ports between containers only, Do Not use -p or --publish just put them on the same docker network.

Example:

Lets create a new user-defined network:

sudo docker network create appnet

Lets create nginx container for reverse proxy, It should be available to outside world so we use publish.

sudo docker run --name nginx -d --network appnet nginx

Now put your apps in the same network but do not expose ports.

sudo docker run --name app1 -d --network appnet <app image name/id>
about 4 years ago · Santiago Trujillo Denunciar

0

You have to use Docker networks.

The default network is shared with host, thus accessible from localhost. You can either configure Docker, creating a network manually, or let tools like docker-compose or Kubernetes to do it for you.

about 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda