Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Docker: how to route path to port?

I am running 2 applications using separate Docker containers on the same server.
The first application uses the port 8000. Dockerfile:

EXPOSE 8000

docker-compose.yml:

command: uvicorn app.main:app --host 0.0.0.0 --port 8000
ports:
  - "8000:8000"

The second application uses the port 8001. Dockerfile:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

EXPOSE 8001

docker-compose.yml:

command: uvicorn app.main:app --host 0.0.0.0 --port 8001
ports:
  - "8001:8001"

I have created DNS type A record:

api.mydomain.com to 123.123.123.123

api.mydomain.com:8000 and api.mydomain.com:8001 are both functioning. I want to route url path to port. For example:

api.mydomain.com/appone/ to api.mydomain.com:8000
api.mydomain.com/apptwo/ to api.mydomain.com:8001

Is it possible to do this using Docker? If yes, how can I do it?

>Solution :

Is it possible to do this using Docker?

Directly no, indirectly yes. Docker runs applications.

how can I do it?

You can run a proxy HTTP server that forwards domains to specific ports. Nginx and Apache are the most popular HTTP servers. There is also Fabio proxy.

You can run that server inside docker.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading