12

Aim

The aim is to run docker-compose in BitBucket pipelines

Attempt

bitbucket-pipelines.yml

image: docker/compose:1.12.0

pipelines:
  default:
    - step:
        script:
          - docker-compose up --build

Outcome

The Docker Engine version is less than the minimum required by Compose.
Your current project requires a Docker Engine of version 1.13.0 or greater.

Discussion

According to this post it is not supported?

10

Here is my solution: (bitbucket-pipelines.yml)

pipelines:
  default:
    - step:
        script:
          - export DOCKER_COMPOSE_VERSION=1.18.0
          - export DOCKER_COMPOSE_URL=https://github.com/docker/compose/releases/download/${DOCKER_COMPOSE_VERSION}/docker-compose-$(uname -s)-$(uname -m)
          - curl -L $DOCKER_COMPOSE_URL > docker-compose
          - chmod +x docker-compose
          - mv docker-compose /usr/local/bin
          - docker-compose build --force-rm --no-cache --pull
| improve this answer | |
6

We are less likely to see support of native docker-compose integration because pipelines API is a custom implementation of similar functionality, and also because possible security issues, but looks like more features are currently in development to implement more docker-compose-like features in this open issue.

UPDATE: added support for multi-container pipelines, as described in documentation

| improve this answer | |
3

I managed to use docker-compose to push images to a remote host by using the following image.

tmaier/docker-compose:latest

This is the basic docker image with docker-compose installed.

My bitbucket-pipelines.yml looks like this:

- step:
    image: tmaier/docker-compose:latest
    script:
        - (umask  077 ; echo $DOCKER_PRIVATE_KEY | base64 -d > ./keys/key.pem)
        - export DOCKER_CERT_PATH=./keys/
        - export DOCKER_TLS_VERIFY="1"
        - export DOCKER_HOST=tcp://<DOCKER_HOST_IP>:2376
        - docker login --username $DOCKER_HUB_USERNAME --password $DOCKER_HUB_PASSWORD
        - docker-compose up -d <service>

I have checked-in in my repo the ca.pem and cert.pem needed by docker-compose in the keys directory. The private key is saved base64encoded, as a secure variable in Bitbucket pipelines environment variables, so I just decode it and paste it to keys/key.pem in the pipeline as the first step.

Keep in mind that i used docker login after setting the enviroment variables for the remote host.

| improve this answer | |
0

bitbucket-pipelines.yml

image: python:3.8.1

pipelines:
  branches:
    "**":
      - step:
          name: Build
          services:
            - docker
          caches:
            - docker
            - pip
          script:
            - pip install docker-compose
            - docker network create dockernet
            - docker-compose build

definitions:
  services:
    docker:
      memory: 2048
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.