Skip to content

Using Docker-Compose

Docker Compose is an orchestration tool for container-based applications to mimic cluster-based orchestration like Kubernetes and Swarm. It enables developers to be more productive, as they iterate through a code-build-test cycle.

You need to define your application and the services using YAML syntax, usually in docker-compose.yml. Razorops supports Docker and Docker-Compose out of box without any additional configuration required.

It's recommended to use the Linux VM environment because of performance benefits. To know more, please refer to "CI Environment".

How to use

The docker-compose utility is pre-installed in all language based convenience images and Linux-VM environment. It can be used within your pipeline just like you use in your laptop.

Here is an example -

    - commands:
      - docker-compose up -d
      - docker-compose exec web bundle exec rake db:migrate

Note: The Docker daemon runs be running locally for Linux-VM environment and reachable over unix socket (/var/run/docker.sock).

Example pipeline

See the Example docker-compose Project on GitHub for a demonstration and use the full configuration file as a template for your own projects.

The pipeline performs the following tasks:

  • Builds the web docker image.
  • Starts the containers (web and db) in background.
  • Executes the tests suite inside web container.

Using alternative docker-compose version

A recent version of Docker Compose is preinstalled by default. If you'd like to use another version, the first thing that you'll need to do is to delete the existing version.

The Razorops pipeline file should include a step as follows:

    - commands:
      - docker-compose -v
      - |
        curl -L${DOCKER_COMPOSE_VERSION}/docker-compose-`uname -s`-`uname -m` > docker-compose && \
        chmod +x docker-compose && \
        sudo mv docker-compose /usr/bin
      - docker-compose -v