Communicate between two containers in Google cloud build

梦想的初衷 提交于 2019-12-03 07:13:05

I had a similar issue setting up integration tests on cloud build. I was trying to run integration tests from another builder (go-builder) against my other containers (started through docker-compose community built containers).

Without specifying any networks on docker-compose.yaml, all containers are started on the default network (https://docs.docker.com/compose/networking/). On cloud build, it creates a new network named cloudbuild_default and places all my containers there. By forcing all containers to join cloudbuild network through my docker-compose.yaml file, I was able to establish communications and run my tests against them.

#docker-compose.yaml

networks:
  default:
    external:
      name: cloudbuild

This might be an alternate configuration for you. Hope it helps

I did an experiment and it looks like (without doing any special setup) you can communicate between build step containers by using the name step_x (0-based numbering).

For example if you have a web-server listening on the endpoint /hello (on port 8081) in the container for the first build step (step_0). You can make requests to that endpoint from another build step container by making a request to http://step_0:8081/hello.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!