Docker Community Forums

Share and learn in the Docker community.

(Newbie) How to get Docker containers to talk to each other while running on my local host?

I have a Webapp running completely locally on my MacBook.

The Webapp has a Front End (Angular/Javascript) and a Back End (Python/Django) which implements a RESTful API.

I have Dockerized the Back End so that it is completely self-contained in a Docker Container and exposes port 8000. I map this port locally to 4026.

Now I need to Dockerize the Front End. But if I have these two docker containers running on my localhost, how can I get the FE to send HTTP requests to the BE? The FE container won’t know anything that exists outside of it. Right?

This is how I run the FE:

$ http-server
Starting up http-server, serving ./
Available on:
Hit CTRL-C to stop the server

Please provide references explaining how I can achieve this.

Basically the container you are running for BE is listening on port 4026. so from FE call http://localhost:4026 or On top that container can talk to each other by name. Let’s say your FE container name is FE_cont and BE container is BE_cont. if you make any call from FE to BE like this BE_cont:8000 they should be able to talk to one another if everything is fine.