Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

268
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda