How to access docker-compose containers in later steps?

I’m trying to build a container from docker-compose (which contains nginx) and then access that container in a later step. I can’t figure out where I’m going wrong.

What I’m expecting is that my curl step will return headers for the default “Welcome to Nginx” page. But instead I’m getting “Could not resolve host: docker-build”.

I can make this work if my service uses image: nginx, but creating an nginx container via docker-compose seems to be breaking somehow. (There will be more stuff in my compose file…this is just to get the initial plumbing connected.)

What am I doing wrong? Thanks so much!

My drone file:

kind: pipeline
type: docker
name: test-run

volumes:
  - name: service_dockersock
    temp: {}

services:
  - name: docker-daemon
    image: docker:19-dind
    privileged: true
    volumes:
      - name: service_dockersock
        path: /var/run

  - name: docker-builder
    image: docker/compose
    commands:
      - while ! docker system info > /dev/null 2>&1; do sleep 1; done # Wait for docker-daemon to be ready.
      - docker-compose up -d
    volumes:
      - name: service_dockersock
        path: /var/run

steps:
  - name: curl
    image: curlimages/curl
    commands:
      - sleep 15 # Wait for docker-builder to be ready. There is probably a better way?
      - curl -I http://docker-builder <--- This is returning a "Could not resolve host: docker-build" error.

My docker-compose.yml:

version: "3"

services:
  nginx:
    image: nginx

I think you maybe need to expose the port to route traffic on the host (or in this case, the host container) into the nginx container?

version: "3"

services:
  nginx:
    image: nginx
    ports:
      - "80:80"

I also recommend reading the below thread if you are planning on using docker-compose with drone:

Thanks for your response. Unfortunately, specifying the ports doesn’t work as expected. I’ll look into the exec runner.

Thanks.