• This repository has been archived on 09/Jul/2023
  • Stars
    star
    159
  • Rank 227,410 (Top 5 %)
  • Language
    Shell
  • License
    MIT License
  • Created about 6 years ago
  • Updated 10 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Docker image with Docker Compose installed for CI.

🚨 DEPRECATION WARNING 🚨

As Docker now has compose built in there's no longer need for this Docker image.

You should use the official Docker image instead.


Test Deploy

Supported tags and respective Dockerfile links

Note: There are tags for each build date. If you need to "pin" the Docker image version you use, you can select one of those tags. E.g. tiangolo/docker-with-compose:2021-09-17.

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 possibly require doing other small things, like running shell scripts or notifying some API with curl.

It includes both programs (docker and docker-compose) and allows to run arbitrary shell 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

Pull the image:

$ docker pull tiangolo/docker-with-compose

Then run a container of this image mounting the Docker sock as a host volume.

By mounting the Docker sock as a volume you allow the docker client inside of the container to communicate with your Docker (the Docker daemon/service) on your machine directly.

This way, you can send Docker commands, like pulling, running, or building a new Docker image, from inside this container.

You might also want to mount a host volume with the files that you need to use.


For example, let's say you have a Dockerfile like:

FROM nginx

RUN echo "Hello World" > /usr/share/nginx/html/index.html

You could:

  • Mount the local directory containing that Dockerfile.
  • Mount the local Docker sock.
  • Build that Nginx image from inside of container running this image.
$ docker run -v $(pwd):/app -v /var/run/docker.sock:/var/run/docker.sock tiangolo/docker-with-compose sh -c "cd /app/ && docker build -t custom-nginx ."

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 shell 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.

And you could start that initial GitLab Runner following the GitLab CI runner for CI/CD guide on DockerSwarm.rocks.

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

Release Notes

Latest Changes

  • 🗑️ Deprecate this project, use official Docker instead 🎉. PR #47 by @tiangolo.
  • ⬆️ Bump actions/checkout from 3.1.0 to 3.3.0. PR #44 by @dependabot[bot].
  • 👷 Update Latest Changes token. PR #46 by @tiangolo.
  • 👷 Add GitHub Action for Docker Hub description. PR #41 by @tiangolo.
  • ⬆️ Upgrade CI OS. PR #40 by @tiangolo.
  • 🔧 Add funding config. PR #39 by @tiangolo.
  • 👷 Add automatic scheduled CI every monday. PR #38 by @tiangolo.
  • 👷 Add automatic scheduled CI every Monday. PR #37 by @tiangolo.
  • 📝 Update README, replace bash with shell, as Bash itself is not installed. PR #36 by @tiangolo.
  • 👷 Add alls-green GitHub Action. PR #35 by @tiangolo.
  • 👷 Do not run double CI for PRs, run on push only on master. PR #34 by @tiangolo.
  • ⬆️ Bump tiangolo/issue-manager from 0.3.0 to 0.4.0. PR #28 by @dependabot[bot].
  • Bump actions/checkout from 2 to 3.1.0. PR #31 by @dependabot[bot].
  • 🐛 Fix deployment. PR #26 by @tiangolo.
  • 🐛 Fix GitHub Actions and latest requirements. PR #25 by @tiangolo.
  • 👷 Move from Travis to GitHub Actions. PR #23 by @tiangolo.
  • ✨ Add external dependencies and Dependabot to get automated upgrade PRs. PR #27 by @tiangolo.
  • 👷 Add Latest Changes GitHub Action. PR #24 by @tiangolo.
  • Upgrade Python to use version 3.x. PR #15.
  • Add curl to the installed and available packages. PR #14 by @stratosgear.
  • 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.

More Repositories

1

fastapi

FastAPI framework, high performance, easy to learn, fast to code, ready for production
Python
69,216
star
2

full-stack-fastapi-postgresql

Full stack, modern web application generator. Using FastAPI, PostgreSQL as database, Docker, automatic HTTPS and more.
TypeScript
14,514
star
3

typer

Typer, build great CLIs. Easy to code. Based on Python type hints.
Python
13,112
star
4

sqlmodel

SQL databases in Python, designed for simplicity, compatibility, and robustness.
Python
12,169
star
5

uwsgi-nginx-flask-docker

Docker image with uWSGI and Nginx for Flask applications in Python running in a single container. Optionally with Alpine Linux.
Python
2,926
star
6

uvicorn-gunicorn-fastapi-docker

Docker image with Uvicorn managed by Gunicorn for high-performance FastAPI web applications in Python with performance auto-tuning. Optionally with Alpine Linux.
Python
2,468
star
7

asyncer

Asyncer, async and await, focused on developer experience.
Python
1,329
star
8

pydantic-sqlalchemy

Tools to convert SQLAlchemy models to Pydantic models
Python
1,075
star
9

dockerswarm.rocks

Docker Swarm mode rocks! Ideas, tools and recipes. Get a production-ready, distributed, HTTPS served, cluster in minutes, not weeks.
Shell
1,054
star
10

nginx-rtmp-docker

Docker image with Nginx using the nginx-rtmp-module module for live multimedia (video) streaming.
Dockerfile
952
star
11

uwsgi-nginx-docker

Docker image with uWSGI and Nginx for applications in Python (as Flask) in a single container. Optionally with Alpine Linux.
Python
627
star
12

uvicorn-gunicorn-docker

Docker image with Uvicorn managed by Gunicorn for high-performance web applications in Python with performance auto-tuning. Optionally with Alpine Linux.
Python
580
star
13

full-stack

Full stack, modern web application generator. Using Flask, PostgreSQL DB, Docker, Swagger, automatic HTTPS and more.
Python
520
star
14

meinheld-gunicorn-flask-docker

Docker image with Meinheld and Gunicorn for Flask applications in Python. Optionally with Alpine Linux.
Python
479
star
15

full-stack-fastapi-couchbase

Full stack, modern web application generator. Using FastAPI, Couchbase as database, Docker, automatic HTTPS and more.
Python
424
star
16

typer-cli

Run Typer scripts with completion, without having to create a package, using Typer CLI.
Python
349
star
17

poetry-version-plugin

Poetry plugin for dynamically extracting the package version from a __version__ variable or a Git tag.
Python
346
star
18

blog-posts

Blog posts and related code by Sebastián Ramírez (@tiangolo)
Python
261
star
19

babun-docker

Use Docker Toolbox with Babun (Cygwin) in Windows
Shell
171
star
20

meinheld-gunicorn-docker

Docker image with Meinheld managed by Gunicorn for high-performance WSGI (Flask, Django, etc) web applications in Python with performance auto-tuning. Optionally with Alpine Linux.
Python
157
star
21

uvicorn-gunicorn-starlette-docker

Docker image with Uvicorn managed by Gunicorn for high-performance Starlette web applications in Python with performance auto-tuning. Optionally with Alpine Linux.
Python
155
star
22

node-frontend

Node.js Docker image with all Puppeteer dependencies installed for frontend Chrome Headless testing and default Nginx config, for multi-stage Docker building
Dockerfile
134
star
23

latest-changes

A GitHub Action to add latest changes after each PR merged automatically
Python
132
star
24

flask-frontend-docker

Minimal project generator with a Flask backend, a modern frontend (Vue, React or Angular), a Traefik load balancer with HTTPS, all based on Docker.
Vue
131
star
25

python-machine-learning-docker

Docker image with Python 3.6 and 3.7 using Conda, with CUDA variants. To serve as base image for Machine Learning projects.
Dockerfile
80
star
26

uvicorn-gunicorn-machine-learning-docker

Docker image for high-performance Machine Learning web applications. With Uvicorn managed by Gunicorn in Python 3.7 and 3.6, using Conda, with CUDA and TensorFlow variants.
Python
64
star
27

full-stack-flask-couchbase

Full stack, modern web application generator. Using Flask, Couchbase as database, Docker, Swagger, automatic HTTPS and more.
Python
57
star
28

issue-manager

Automatically close issues that have a label, after a custom delay, if no one replies back.
Python
54
star
29

full-stack-flask-couchdb

Full stack, modern web application generator. Using Flask, CouchDB as database, Docker, Swagger, automatic HTTPS and more.
Python
30
star
30

label-approved

Label a Pull Request after a number of approvals
Python
21
star
31

angular-docker-multi-stage-example

Angular in Docker with Nginx, supporting environments, built with multi-stage Docker builds
16
star
32

github-actions-sandbox

Not useful for you. It's just a sandbox GitHub repo for me to try out stuff and develop GitHub Actions.
Python
15
star
33

docker-auto-labels

Generate each Docker constraint label in random nodes in the cluster.
Python
14
star
34

tiangolo

12
star
35

compose-to-rancher

Convert Docker Compose V2 to Rancher compatible Docker Compose V1
Python
10
star
36

ngx-http-client

Angular (4.3+) HttpClientModule with parameter encodings compatible with back ends (Node.js, Python, PHP, etc)
TypeScript
10
star
37

tiangolo.com

TypeScript
7
star
38

wunderlist2csv

Convert from Wunderlist backup json file to a CSV file importable by TaskCoach
Python
6
star
39

anaconda_cluster_install

Automatically Install Anaconda Python in a cluster of machines, for a specified user.
Shell
5
star
40

bitbucket_issues_to_redmine_csv

Python
3
star