• This repository has been archived on 09/Jul/2023
  • Stars
    star
    158
  • Rank 237,131 (Top 5 %)
  • Language
    Shell
  • License
    MIT License
  • Created almost 7 years ago
  • Updated over 1 year 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
73,897
star
2

full-stack-fastapi-template

Full stack, modern web application template. Using FastAPI, React, SQLModel, PostgreSQL, Docker, GitHub Actions, automatic HTTPS and more.
TypeScript
24,890
star
3

typer

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

sqlmodel

SQL databases in Python, designed for simplicity, compatibility, and robustness.
Python
13,694
star
5

uwsgi-nginx-flask-docker

Docker image with uWSGI and Nginx for Flask applications in Python running in a single container.
Python
2,986
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.
Python
2,699
star
7

asyncer

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

pydantic-sqlalchemy

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

nginx-rtmp-docker

Docker image with Nginx using the nginx-rtmp-module module for live multimedia (video) streaming.
Dockerfile
1,110
star
10

dockerswarm.rocks

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

uwsgi-nginx-docker

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

uvicorn-gunicorn-docker

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

full-stack

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

meinheld-gunicorn-flask-docker

Docker image with Meinheld and Gunicorn for Flask applications in Python.
Python
486
star
15

full-stack-fastapi-couchbase

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

typer-cli

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

poetry-version-plugin

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

fastapi-cli

Run and manage FastAPI apps from the command line with FastAPI CLI. 🚀
Python
287
star
19

blog-posts

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

uvicorn-gunicorn-starlette-docker

Docker image with Uvicorn managed by Gunicorn for high-performance Starlette web applications in Python with performance auto-tuning.
Python
182
star
21

latest-changes

A GitHub Action to add latest changes after each PR merged automatically
Python
172
star
22

babun-docker

Use Docker Toolbox with Babun (Cygwin) in Windows
Shell
170
star
23

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.
Python
165
star
24

node-frontend

Instrutctions to buid a frontend Docker image built with Node.js and then served with Nginx. Previously a Docker image.
Dockerfile
137
star
25

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
130
star
26

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
84
star
27

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
67
star
28

issue-manager

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

full-stack-flask-couchbase

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

label-approved

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

full-stack-flask-couchdb

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

tiangolo

16
star
33

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
16
star
34

tiangolo.com

Python
16
star
35

docker-auto-labels

Generate each Docker constraint label in random nodes in the cluster.
Python
15
star
36

angular-docker-multi-stage-example

Angular in Docker with Nginx, supporting environments, built with multi-stage Docker builds
15
star
37

ngx-http-client

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

compose-to-rancher

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

markdown-include-variants

Markdown extension to expand directives to include source example files to also include their variants. Only useful to tiangolo's projets. Don't use it. 😅
Python
9
star
40

wunderlist2csv

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

anaconda_cluster_install

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

bitbucket_issues_to_redmine_csv

Python
3
star