Hello I am currently planning out some server architecture with Docker. (I'm fairly new to Docker)
My goals are:
- To have multiple docker containers running on a single ubuntu machine.
- Each container uses the same ports for each process: (e.g.) localhost:8080 for frontend, localhost:3000 for backend.
How each container works:
Right now I'm using docker compose to run both frontend and backend.
docker-compose.yml
version: '3'
services:
frontend:
build: ./frontend
ports:
- 8080:80
networks:
- app-network
backend:
build: ./backend
ports:
- 3000:3000
working_dir: /usr/src/server
command: node server.bundle.js
networks:
- app-network
networks:
app-network:
driver: bridge
This works fine. I can visit localhost:8080 for webpage and localhost:3000 for backend.
Note: Front end container uses NGINX docker image, and backend uses NODE:10 docker image.
What I want to accomplish
On my server I will have another instance of NGINX. I would like to somehow containerize each docker-compose setup under one port like localhost:5000.
This way when I get a request from www.example-website1.com it redirects to localhost:5000, which then loads localhost:8080 from that docker-compose setup.
Again when I get a request from www.example-website2.com it redirects to localhost:5001, which then loads localhost:8080 from another docker-compose setup.
Is this possible? Or is there another way I should be approaching this problem?