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

前端 未结 3 801
醉梦人生
醉梦人生 2020-12-08 02:53

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 A

3条回答
  •  死守一世寂寞
    2020-12-08 03:11

    There are multiple ways to do this and the simplest answer is to use Docker-Compose. You can use Docker-compose to allow multiple services to run a server.

    If you are not using Docker-Compose and running individual container than expose both services port with host and then use those services on such on links like:

    docker run -p 3306:3306 mysql

    docker run -p 8088:80 nginx

    Now you can communicate as:

    http://hostip:3306 http://hostip:8088 etc. Now you can communicate with container using hostIP.

提交回复
热议问题