<p>Here is my solution: (bitbucket-pipelines.yml)</p>

<pre><code>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 &gt; docker-compose
          - chmod +x docker-compose
          - mv docker-compose /usr/local/bin
          - docker-compose build --force-rm --no-cache --pull
</code></pre>

CC BY-SA 4.0
2017-12-28T22:06:06.267Z
2019-12-20T10:46:00.547Z
2019-12-20T10:46:00.547Z
Maksim Kostromin
<p>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 <a href="https://bitbucket.org/site/master/issues/12757/ability-to-run-multiple-docker-containers" rel="noreferrer">this</a> open issue.</p>

<p>UPDATE: added support for multi-container pipelines, as described in <a href="https://confluence.atlassian.com/bitbucket/service-containers-for-bitbucket-pipelines-874786688.html" rel="noreferrer">documentation</a></p>

CC BY-SA 3.0
2017-04-09T14:37:30.477Z
2017-05-14T13:37:57.247Z
2017-05-14T13:37:57.247Z
rombob
<p>I managed to use docker-compose to push images to a remote host by using the following image.</p>

<p><a href="https://hub.docker.com/r/tmaier/docker-compose/" rel="nofollow noreferrer" title="tmaier/docker-compose">tmaier/docker-compose:latest</a></p>

<p>This is the basic <a href="https://hub.docker.com/r/_/docker/" rel="nofollow noreferrer" title="docker image">docker image</a> with docker-compose installed.</p>

<p>My <code>bitbucket-pipelines.yml</code> looks like this:</p>

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

<p>I have checked-in in my repo the <code>ca.pem</code> and <code>cert.pem</code> needed by docker-compose in the <code>keys</code> 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 <code>keys/key.pem</code> in the pipeline as the first step.</p>

<p>Keep in mind that i used <code>docker login</code> after setting the enviroment variables for the remote host.</p>

CC BY-SA 3.0
2017-12-07T12:35:37.057Z
2017-12-07T12:35:37.057Z
Nikos Anestos
<p><strong>bitbucket-pipelines.yml</strong></p>

<pre><code>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
</code></pre>

CC BY-SA 4.0
2020-01-29T15:14:35.103Z
2020-01-29T15:14:35.103Z
Codler
<p><strong>Aim</strong></p>

<p>The aim is to run docker-compose in BitBucket pipelines</p>

<p><strong>Attempt</strong></p>

<p><em>bitbucket-pipelines.yml</em></p>

<pre><code>image: docker/compose:1.12.0

pipelines:
  default:
    - step:
        script:
          - docker-compose up --build
</code></pre>

<p><strong>Outcome</strong></p>

<pre><code>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.
</code></pre>

<p><strong>Discussion</strong></p>

<p>According to <a href="https://community.atlassian.com/t5/Bitbucket-questions/Docker-compose-and-pipelines/qaq-p/67913" rel="noreferrer">this</a> post it is not supported?</p>

<bitbucket><docker-compose>
Is running docker-compose not supported in BitBucket?
030
# Is running docker-compose not supported in BitBucket?

(Asked by: username_0 on 2017-04-06)

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?

**Tags:** bitbucket, docker-compose


---

## 4 answers

### Answer by username_1 on 2017-12-28. Score: 11 | Accepted answer

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


---

### Answer by username_2 on 2017-04-09. Score: 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](https://bitbucket.org/site/master/issues/12757/ability-to-run-multiple-docker-containers) open issue.

UPDATE: added support for multi-container pipelines, as described in [documentation](https://confluence.atlassian.com/bitbucket/service-containers-for-bitbucket-pipelines-874786688.html)


---

### Answer by username_3 on 2017-12-07. Score: 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://:2376
        - docker login --username $DOCKER_HUB_USERNAME --password $DOCKER_HUB_PASSWORD
        - docker-compose up -d 

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.


---

### Answer by username_4 on 2020-01-29. Score: 2

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


---

