10

I’d like to do

docker-compose up -d

Seems like plugins/docker is able to do what I want, but it fails if I don’t specify the publish-related stuff. I want to use it without publishing.

Another alternative could be services, but I try always failed

the code from docs.drone.io/docker_dind

kind: pipeline
name: default

steps:
- name: test
  image: docker:dind
  volumes:
  - name: dockersock
    path: /var/run
  commands:
  - sleep 5 # give docker enough time to start
  - docker ps -a
  - docker-compose -v # new

services:
- name: docker
  image: docker:dind
  privileged: true
  volumes:
  - name: dockersock
    path: /var/run

volumes:
- name: dockersock
  temp: {}

Error:

/usr/drone/bin/init: line 23: docker-compose: not found
Custer
  • 145
  • 2
  • 8

2 Answers2

11

The docker:dind container does not seem to have "docker-compose" installed. You can try using the docker/compose:1.23.2 container. You need to mount the docker socket file if you intend on using your host docker resources (ie. images, networks). Otherwise, you need to mount your directory with the docker-compose file to the /code directory.

docker/compose image reference: https://hub.docker.com/r/docker/compose/

See code below for reference:

kind: pipeline
name: default

steps:
- name: test
  image: compose:1.23.2
  volumes:
  - name: docker_sock
    path: /var/run/docker.sock
  commands:
  - up -f /drone/src/docker-compose.yaml
volumes:
  - name: docker_sock
    host:
      path: /var/run/docker.sock
Frank Yucheng Gu
  • 1,807
  • 7
  • 21
  • thank you, I change the image: docker/compose:1.23.2 and commands: - docker-compose -v [docs.drone - Specify the image to start the container from. Drone supports any valid image from any compatible Docker registry, including private registries.](https://docs.drone.io/user-guide/pipeline/steps/) – Custer Mar 22 '19 at 02:15
  • 1
    0 in my case it says: MountVolume.SetUp failed for volume "h6wwnv9s7zdmpdrh2ken9vv1qmj2vzdv" : hostPath type check failed: /var/run/docker.sock is not a directory – Tobias Mar 22 '19 at 09:30
  • ```volumes: - name: docker_sock host: path: /var/run/docker.sock steps: - name: test image: compose:1.23.2 volumes: - name: docker_sock path: /var/run/docker.sock commands:``` – Tobias Mar 22 '19 at 18:45
  • @custer any idea? – Tobias Mar 28 '19 at 06:00
  • When I try out the accepted solution I get the error: 'Invalid or missing pipeline section'. Any ideas? – MrfksIV Apr 30 '19 at 13:19
  • 1
    Pass your YAML through a linter. Many times an extraneous newline or space might wreak havoc. – Frank Yucheng Gu Apr 30 '19 at 15:06
0

you can use this yml for drone run docker compose :

- name: publish
  image: docker/compose:1.25.0-rc2-alpine
  commands:
    - docker-compose -f <docker compose filename>.yml up -d
  volumes:
    - name: dockersock
      path: /var/run/docker.sock
  depends_on:
    - build
hassanzadeh.sd
  • 3,091
  • 1
  • 17
  • 26