Drone

Docker-compose: not found

Hi,

I am trying to run a build where one of the steps is to clone a git repo which has a couple of docker containers, bring those up using docker-compose up -d. Load some config from another repo, the config is in excel files and I can upload these via api calls.

Once this whole env is up and running, run the tests, upload run report (somewhere) if they are successful tear everything down (docker-compose stop). If not successful break execution and leave everything as is to facilitate debugging.

I have gotten as far as getting docker in docker working, i can’t get docker-compose to work. My drone.yml file so far looks like this

kind: pipeline
type: docker
name: default

clone:
  disable: true
  
steps:
- name: clone
  image: alpine/git
  commands:
  - git clone https://github.com/xxxxxx/xxx-docker.git

- name: build
  image: docker:dind
  commands:
  - sleep 5 # give docker enough time to start
  - cd cop-docker
  - sleep 5
  - pwd
  - docker-compose up -d
  - sleep 5
  - docker ps -a

services:
- name: docker
  image: docker:dind
  privileged: true

- name: docker-compose
  image: docker/compose

  volumes:
  - name: dockersock
    path: /var/run

I keep on getting this error

/usr/drone/bin/init: line 29: docker-compose: not found or the whole thing just hangs

i have tried everything i can find online and nothing seems to work. Things i have tried so far are

  • adding it as a service (docker-compose)
  • adding it to the volume
  • adding as a step (docker-compose step)
  • adding all as one step, clone, docker in docker and docker-compose

any help will be very much appreciated.

Duplicated volumes define, just remove one

Sorry that was a typo in copy paste, I have updated the yml file, it only has one volume across steps and services. Still getting the same error

/usr/drone/bin/init: line 29: docker-compose: not found or the whole thing just hangs

This is because the docker:dind image does not contain docker-compose. We can validate this on any machine with docker installed via:

 docker run --rm -it docker:dind sh
/ # docker-compose --help
sh: docker-compose: not found

The workflow you are trying to accomplish with docker-compose isn’t very standard and users typically spin up everything via services instead since they are native to Drone. I highly recommend you read the documentation for services to better understand how they work.