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

470
Views
Best way to run two docker compose apps behind nginx on one host machine?

I have two docker-compose apps:

  • a.com
  • b.com

I want to run them both on the same host machine and put an nginx container proxy to route incoming requests to the correct services within each of the docker-compose apps.

I think I need to have a single nginx container running separately from the two docker-compose apps. I previously used nginx-proxy, but my routing has got more complex, so I want to run my own nginx instance now.

  • I can't work out how to network the two apps and the nginx container to make this all work in a sane way.
  • When I docker run the nginx container I'm getting: host not found in upstream "MY_CONTAINER_HOST_NAME", which suggests my app hostname isn't resolving from within the nginx container.
  • I can post my nginx config if need be, but this is really a docker networking/ best-practice question.
about 4 years ago · Santiago Trujillo
2 answers
Answer question

0

nginx-proxy should be good enough, provided it supports a docker swarm attached network (issue 520, still pending)

You could also consider vfarcic/docker-flow-proxy, an easy way to reconfigure proxy every time a new service is deployed, or when a service is scaled.

See "Integrating Proxy With Docker Swarm (Tour Around Docker 1.12 Series)" for a concrete example.

about 4 years ago · Santiago Trujillo Report

0

I can think of 2 options for this:

First:

Run both apps and nginx in the same docker user-defined network. In order to do this you need to create a user-defined network first:

docker network create appnet

Then change your docker-files to use the appnet network as external (external networks wont create network and use existing)

Second:

Create 2 user-defined networks, named appnet1 and appnet2, attach a.com to appnet1 and b.com to appnet2 marked as external network in docker-compose. Then bring up the nginx and attach it to both appnet1 and appnet2.

When I docker run the nginx container I'm getting: host not found in upstream "MY_CONTAINER_HOST_NAME", which suggests my app hostname isn't resolving from within the nginx container.

Please note: User defined networks will provide internal DNS so you can call containers on the same network by container name.

External network example:

If you want your containers to join a pre-existing network, use the external option:

networks:
  default:
    external:
      name: my-pre-existing-network

Instead of attempting to create a network called [projectname]_default, Compose will look for a network called my-pre-existing-network and connect your app’s containers to it

about 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!