Code Monkey home page Code Monkey logo

docker-with-compose's Introduction

Build Status

Supported tags and respective Dockerfile links

Docker with Docker Compose image

Docker image with Docker Compose installed for CI.

Description

The main purpose of this image is to help in Continuous Integration environments that need the docker binary, the docker-compose binary and posibly require doing other things, like running Bash scripts.

It includes both programs and allows to run arbitrary bash scripts (contrary to the official Docker Compose image).

By not having to install docker-compose on top of a docker:latest image it can reduce the building time about 10 / 15 seconds in a cloud data center for each build. In environments in where the Internet connection is less good than a cloud provider, the time saved would be more.

GitHub repo: https://github.com/tiangolo/docker-with-compose

Docker Hub image: https://hub.docker.com/r/tiangolo/docker-with-compose/

Usage

docker pull tiangolo/docker-with-compose

Problem description

There is an official Docker image that contains the docker binary. And there is a Docker Compose image.

But the Docker Compose image has docker-compose as the entrypoint.

So, it's not possible to run other commands on that image, like installing something, e.g. apt-get install -y curl.

And it's also not possible to run docker commands directly, e.g. docker login -u ci-user -p $CI_JOB_TOKEN $CI_REGISTRY.

This image allows running arbitrary commands like Bash scripts, docker commands and also Docker Compose commands like docker-compose build and docker-compose push.

As several Continuous Integration systems allow doing previous steps, like installing packages before running the actual main script, those steps could be used to install Docker Compose. But by downloading and installing Docker Compose every time, the builds would be slower.

For example, a very simple GitLab CI file .gitlab-ci.yml could look like:

# Do not use this file example
image: docker:latest

before_script:
  - apk add --no-cache py-pip
  - pip install docker-compose
  - docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY

ci:
  script:
    - docker-compose build
    - docker-compose up -d
    - docker-compose exec -T tests run-tests.sh
    - docker-compose down -v
    - docker stack deploy -c docker-compose.prod.yml --with-registry-auth prod-example-com

But when the base image has to download and install Docker Compose every time, that's time added to the process. Specifically the lines in:

...

  - apk add --no-cache py-pip
  - pip install docker-compose

...

This image's solution

This image includes Docker Compose and allows you to run any other arbitrary command.

So your GitLab CI .gitlab-ci.yml file could then look like:

image: tiangolo/docker-with-compose

before_script:
  - docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY

ci:
  script:
    - docker-compose build
    - docker-compose up -d
    - docker-compose exec -T tests run-tests.sh
    - docker-compose down -v
    - docker stack deploy -c docker-compose.prod.yml --with-registry-auth prod-example-com

And it would run faster as it doesn't have to install Docker Compose every time.

The same would apply for Travis, Jenkins or whichever CI system you use.

Release Notes

Next Release

  • Add Travis CI. PR #4.

  • Upgrade Docker Compose installation. PR #3 by @boskiv.

License

This project is licensed under the terms of the MIT license.

docker-with-compose's People

Contributors

boskiv avatar tiangolo avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.