Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

1.9K
Views
internal and external network with docker-compose?

Suppose I have 2 docker containers: (A) shinyapptest is a front end that needs to communicate with (B) testapi and be accessible to the outside world.

To do this I created a network backend by running the following command:

docker network create -d bridge --subnet 192.168.0.0/24 --gateway 192.168.0.1 backend

Then shinyapptest makes its API calls to "http://192.168.0.1:3098.

To get everything up and running I wrote the following docker-compose:

version: '3.7'
services:
    shinyapptest:
      container_name: testshiny
      image: testshiny
      restart: unless-stopped
      networks:
            - frontend
            - backend
      ports:
          - 80:3838
    testapi:
      container_name: testapi
      image: testapi
      restart: unless-stopped
      networks:
            - backend
      ports:
          - 3098:3098
networks:
  backend:
    external:
      name: backend
  frontend:
    external:
      name: frontend

Is this right? Basically, I want (A) to have access to (B) and the outside world to have access to (A) but not (B). If this is right, how should I create the frontend network? Right now if I try to run docker-compose up I get this error because the network does not exist:

$ docker-compose up
ERROR: Network frontend declared as external, but could not be found. Please create the network manually using `docker network create frontend` and try again.
over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Actually you don't even need the frontend network. If you attach the backend network to both containers they should be able to communicate with each other. Just like 2 computers on the same network.

If you don't want a container to be accessible from outside, simply don't map the respective port back into your host system. That will keep them isolated.

Currently your api has port 3098 exposed. If you remove that, but have the network attached to both containers you would be able to call port 3098 internally from your frontend container, but not from outside.

You may even use the assigned container name for internal communication, like so:

http://testapi:3098/...

I hope that helps.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!