Communicate between two containers in Google cloud build

后端 未结 3 1224
醉话见心
醉话见心 2021-02-04 08:20

I am running my CI/CD pipeline in Google cloud build. My app has web and wget containers. I am trying to reach web from wget<

3条回答
  •  长情又很酷
    2021-02-04 08:33

    From the docs:

    Each build step is run with its container attached to a local Docker network named cloudbuild. This allows build steps to communicate with each other and share data.

    You can use docker compose and using cloudbuild network, for example:

    #docker-compose.yml
    app-workspace:
      ...
      network_mode: cloudbuild
    db-mysql:
      ...
      network_mode: cloudbuild
    ...
    networks:
      default:
        external:
          name: cloudbuild
    

    Or if you are using docker run, add option --network cloudbuild.

    After that, you can communicate to other services you defined in the previous step as you expect. For example:

    #steps
    - id: 'Ping to other container'
      name: gcr.io/cloud-builders/curl
      args: ["app-workspace:your-service-port"]
    

    Hope this helps.

提交回复
热议问题