Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

drone (Docker-Compose in docker?)

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
like image 782
Custer Avatar asked Mar 21 '19 18:03

Custer


People also ask

Is Docker compose the same as Docker compose?

The key difference between docker run versus docker-compose is that docker run is entirely command line based, while docker-compose reads configuration data from a YAML file. The second major difference is that docker run can only start one container at a time, while docker-compose will configure and run multiple.

What is Docker compose with example?

Docker Compose is used to run multiple containers as a single service. For example, suppose you had an application which required NGNIX and MySQL, you could create one file which would start both the containers as a service without the need to start each one separately.

Does Docker compose include Docker?

If you installed Docker Desktop/Toolbox for either Windows or Mac, you already have Docker Compose!


1 Answers

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
like image 61
Frank Yucheng Gu Avatar answered Sep 23 '22 21:09

Frank Yucheng Gu