Can't resolve running Docker container (brought up with docker-compose) in a subsequent build step

262 views
Skip to first unread message

Bernhard Vollnhofer

unread,
Aug 8, 2019, 12:11:17 PM8/8/19
to Google Cloud Developers
Hi!

In Cloud Build I want to access a NATS Streaming Server running in a Docker container from inside a Gradle container (the Gradle container is building my Java application).
I have therefore read the official tutorial at https://cloud.google.com/cloud-build/docs/configuring-builds/build-test-deploy-artifacts#running_unit_tests_and_integration_tests and I'm now trying to implement a little proof-of-concept project.
Unfortunately the NATS Streaming Server isn't visible from another build step. Maybe you can help me to see where I err.

This is my docker-compose.yaml file:
version: '3.7'

services:
  nats-streaming:
    container_name: nats-streaming
    image: nats-streaming:latest
    ports:
      - 4222:4222

This is my cloudbuild.yaml file:
steps:
  - name: 'docker/compose:1.24.1'
    args: ['up', '-d']
  - name: 'gcr.io/cloud-builders/gcloud'
    entrypoint: /bin/sh
    args:
      - '-c'
      - |
        set -x && \
        curl nats-streaming:4222

And this is the error message I'm getting:
Step #1: + curl nats-streaming:4222
Step #1:   % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
Step #1:                                  Dload  Upload   Total   Spent    Left  Speed
Step #1:
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0curl: (6) Could not resolve host: nats-streaming
Finished Step #1
ERROR
ERROR: build step 1 "gcr.io/cloud-builders/gcloud" failed: exit status 6
Step #0:
Creating nats-streaming ... done


According to the tutorial the Docker container should be accessible via it's name. But nats-streaming can't be resolved.

Do you have any ideas what I'm doing wrong?

Greetings
Lionel

Nicolas (Google Cloud Platform Support)

unread,
Aug 8, 2019, 3:32:42 PM8/8/19
to Google Cloud Developers

Hi Lionel,

This discussion group is oriented more towards general opinions, trends, and issues of general nature touching GCP Developer tools. For technical implementation, such as running unit tests, you may be better served in dedicated forums such as Stack Overflow, where experienced programmers are within reach and ready to help.


Reply all
Reply to author
Forward
0 new messages