├── .gitignore ├── .github ├── FUNDING.yml ├── dependabot.yml └── workflows │ ├── latest-changes.yml │ ├── issue-manager.yml │ ├── test.yml │ └── deploy.yml ├── requirements.txt ├── scripts ├── docker-login.sh ├── build.sh └── build-push.sh ├── Dockerfile ├── LICENSE └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | .vscode 2 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | github: [tiangolo] 2 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | docker-compose==1.29.2 2 | -------------------------------------------------------------------------------- /scripts/docker-login.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | 5 | echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin 6 | -------------------------------------------------------------------------------- /scripts/build.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | 5 | basename="tiangolo/docker-with-compose" 6 | latest_tag="${basename}:latest" 7 | 8 | docker build -t "$latest_tag" . 9 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM docker:latest 2 | 3 | COPY requirements.txt /tmp/requirements.txt 4 | 5 | RUN apk add --no-cache py3-pip python3-dev libffi-dev openssl-dev curl gcc libc-dev rust cargo make && \ 6 | pip3 install --no-cache-dir -r /tmp/requirements.txt 7 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | # GitHub Actions 4 | - package-ecosystem: "github-actions" 5 | directory: "/" 6 | schedule: 7 | interval: "daily" 8 | # Docker image dependencies 9 | - package-ecosystem: "pip" 10 | directory: "/" 11 | schedule: 12 | interval: "daily" 13 | -------------------------------------------------------------------------------- /scripts/build-push.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | 5 | basename="tiangolo/docker-with-compose" 6 | latest_tag="${basename}:latest" 7 | dated_tag="${basename}:$(date -I)" 8 | 9 | bash scripts/build.sh 10 | 11 | docker tag "$latest_tag" "$dated_tag" 12 | 13 | bash scripts/docker-login.sh 14 | 15 | docker push "$latest_tag" 16 | docker push "$dated_tag" 17 | -------------------------------------------------------------------------------- /.github/workflows/latest-changes.yml: -------------------------------------------------------------------------------- 1 | name: Latest Changes 2 | 3 | on: 4 | pull_request_target: 5 | branches: 6 | - master 7 | types: 8 | - closed 9 | workflow_dispatch: 10 | inputs: 11 | number: 12 | description: PR number 13 | required: true 14 | 15 | jobs: 16 | latest-changes: 17 | runs-on: ubuntu-latest 18 | steps: 19 | - uses: actions/checkout@v3.3.0 20 | with: 21 | # To allow latest-changes to commit to master 22 | token: ${{ secrets.DOCKER_WITH_COMPOSE_LATEST_CHANGES }} 23 | - uses: docker://tiangolo/latest-changes:0.0.3 24 | with: 25 | token: ${{ secrets.GITHUB_TOKEN }} 26 | -------------------------------------------------------------------------------- /.github/workflows/issue-manager.yml: -------------------------------------------------------------------------------- 1 | name: Issue Manager 2 | 3 | on: 4 | schedule: 5 | - cron: "0 0 * * *" 6 | issue_comment: 7 | types: 8 | - created 9 | - edited 10 | issues: 11 | types: 12 | - labeled 13 | 14 | jobs: 15 | issue-manager: 16 | runs-on: ubuntu-latest 17 | steps: 18 | - uses: tiangolo/issue-manager@0.4.0 19 | with: 20 | token: ${{ secrets.GITHUB_TOKEN }} 21 | config: > 22 | { 23 | "answered": { 24 | "message": "Assuming the original issue was solved, it will be automatically closed now. But feel free to add more comments or create new issues." 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /.github/workflows/test.yml: -------------------------------------------------------------------------------- 1 | name: Test 2 | 3 | on: 4 | push: 5 | branches: 6 | - master 7 | pull_request: 8 | types: 9 | - opened 10 | - synchronize 11 | schedule: 12 | # cron every week on monday 13 | - cron: "0 0 * * 1" 14 | 15 | jobs: 16 | build: 17 | runs-on: ubuntu-latest 18 | steps: 19 | - uses: actions/checkout@v3.3.0 20 | - name: Build Image 21 | run: bash scripts/build.sh 22 | check: 23 | if: always() 24 | needs: 25 | - build 26 | runs-on: ubuntu-latest 27 | steps: 28 | - name: Decide whether the needed jobs succeeded or failed 29 | uses: re-actors/alls-green@release/v1 30 | with: 31 | jobs: ${{ toJSON(needs) }} 32 | -------------------------------------------------------------------------------- /.github/workflows/deploy.yml: -------------------------------------------------------------------------------- 1 | name: Deploy 2 | 3 | on: 4 | push: 5 | branches: 6 | - master 7 | schedule: 8 | # cron every week on monday 9 | - cron: "0 0 * * 1" 10 | 11 | jobs: 12 | deploy: 13 | runs-on: ubuntu-latest 14 | steps: 15 | - uses: actions/checkout@v3.3.0 16 | - name: Build and Deploy Image 17 | run: bash scripts/build-push.sh 18 | env: 19 | DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} 20 | DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} 21 | - name: Docker Hub Description 22 | uses: peter-evans/dockerhub-description@v3 23 | with: 24 | username: ${{ secrets.DOCKER_USERNAME }} 25 | password: ${{ secrets.DOCKER_PASSWORD }} 26 | repository: tiangolo/docker-with-compose 27 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 Sebastián Ramírez 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## 🚨 DEPRECATION WARNING 🚨 2 | 3 | As [Docker now has `compose` built in](https://github.com/docker-library/docker/pull/361) there's no longer need for this Docker image. 4 | 5 | You should use the official [Docker image](https://hub.docker.com/_/docker/) instead. 6 | 7 | --- 8 | 9 | [![Test](https://github.com/tiangolo/docker-with-compose/workflows/Test/badge.svg)](https://github.com/tiangolo/docker-with-compose/actions?query=workflow%3ATest) [![Deploy](https://github.com/tiangolo/docker-with-compose/workflows/Deploy/badge.svg)](https://github.com/tiangolo/docker-with-compose/actions?query=workflow%3ADeploy) 10 | 11 | ## Supported tags and respective `Dockerfile` links 12 | 13 | * [`latest` _(Dockerfile)_](https://github.com/tiangolo/docker-with-compose/blob/master/Dockerfile) 14 | 15 | **Note**: There are [tags for each build date](https://hub.docker.com/r/tiangolo/docker-with-compose/tags). 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`. 16 | 17 | # Docker with Docker Compose image 18 | 19 | [Docker image](https://hub.docker.com/_/docker/) with [Docker Compose](https://github.com/docker/compose) installed for CI. 20 | 21 | ## Description 22 | 23 | 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`. 24 | 25 | It includes both programs (`docker` and `docker-compose`) and allows to run arbitrary shell scripts (contrary to the official Docker Compose image). 26 | 27 | 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. 28 | 29 | **GitHub repo**: 30 | 31 | **Docker Hub image**: 32 | 33 | ## Usage 34 | 35 | Pull the image: 36 | 37 | ```console 38 | $ docker pull tiangolo/docker-with-compose 39 | ``` 40 | 41 | Then run a container of this image **mounting the Docker sock** as a host volume. 42 | 43 | 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. 44 | 45 | This way, you can send Docker commands, like pulling, running, or building a new Docker image, from inside this container. 46 | 47 | You might also want to mount a host volume with the files that you need to use. 48 | 49 | --- 50 | 51 | For example, let's say you have a `Dockerfile` like: 52 | 53 | ```Dockerfile 54 | FROM nginx 55 | 56 | RUN echo "Hello World" > /usr/share/nginx/html/index.html 57 | ``` 58 | 59 | You could: 60 | 61 | * Mount the local directory containing that `Dockerfile`. 62 | * Mount the local Docker sock. 63 | * Build that Nginx image from inside of container running this image. 64 | 65 | ```console 66 | $ 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 ." 67 | ``` 68 | 69 | ## Problem description 70 | 71 | There is an official [Docker image](https://hub.docker.com/_/docker/) that contains the `docker` binary. And there is a [Docker Compose image](https://hub.docker.com/r/docker/compose/). 72 | 73 | But the Docker Compose image has `docker-compose` as the entrypoint. 74 | 75 | So, it's not possible to run other commands on that image, like installing something, e.g. `apt-get install -y curl`. 76 | 77 | And it's also not possible to run `docker` commands directly, e.g. `docker login -u ci-user -p $CI_JOB_TOKEN $CI_REGISTRY`. 78 | 79 | This image allows running arbitrary commands like shell scripts, `docker` commands and also Docker Compose commands like `docker-compose build` and `docker-compose push`. 80 | 81 | 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. 82 | 83 | For example, a very simple GitLab CI file `.gitlab-ci.yml` could look like: 84 | 85 | ```yml 86 | # Do not use this file example 87 | image: docker:latest 88 | 89 | before_script: 90 | - apk add --no-cache py-pip 91 | - pip install docker-compose 92 | - docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY 93 | 94 | ci: 95 | script: 96 | - docker-compose build 97 | - docker-compose up -d 98 | - docker-compose exec -T tests run-tests.sh 99 | - docker-compose down -v 100 | - docker stack deploy -c docker-compose.prod.yml --with-registry-auth prod-example-com 101 | ``` 102 | 103 | 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: 104 | 105 | ```yml 106 | ... 107 | 108 | - apk add --no-cache py-pip 109 | - pip install docker-compose 110 | 111 | ... 112 | ``` 113 | 114 | ## This image's solution 115 | 116 | This image includes Docker Compose and allows you to run any other arbitrary command. 117 | 118 | So your GitLab CI `.gitlab-ci.yml` file could then look like: 119 | 120 | ```yml 121 | image: tiangolo/docker-with-compose 122 | 123 | before_script: 124 | - docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY 125 | 126 | ci: 127 | script: 128 | - docker-compose build 129 | - docker-compose up -d 130 | - docker-compose exec -T tests run-tests.sh 131 | - docker-compose down -v 132 | - docker stack deploy -c docker-compose.prod.yml --with-registry-auth prod-example-com 133 | ``` 134 | 135 | And it would run faster as it doesn't have to install Docker Compose every time. 136 | 137 | And you could start that initial GitLab Runner following the [GitLab CI runner for CI/CD guide on DockerSwarm.rocks](https://dockerswarm.rocks/gitlab-ci/). 138 | 139 | The same would apply for Travis, Jenkins or whichever CI system you use. 140 | 141 | ## Release Notes 142 | 143 | ### Latest Changes 144 | 145 | * 🗑️ Deprecate this project, use official Docker instead 🎉. PR [#47](https://github.com/tiangolo/docker-with-compose/pull/47) by [@tiangolo](https://github.com/tiangolo). 146 | * ⬆️ Bump actions/checkout from 3.1.0 to 3.3.0. PR [#44](https://github.com/tiangolo/docker-with-compose/pull/44) by [@dependabot[bot]](https://github.com/apps/dependabot). 147 | * 👷 Update Latest Changes token. PR [#46](https://github.com/tiangolo/docker-with-compose/pull/46) by [@tiangolo](https://github.com/tiangolo). 148 | * 👷 Add GitHub Action for Docker Hub description. PR [#41](https://github.com/tiangolo/docker-with-compose/pull/41) by [@tiangolo](https://github.com/tiangolo). 149 | * ⬆️ Upgrade CI OS. PR [#40](https://github.com/tiangolo/docker-with-compose/pull/40) by [@tiangolo](https://github.com/tiangolo). 150 | * 🔧 Add funding config. PR [#39](https://github.com/tiangolo/docker-with-compose/pull/39) by [@tiangolo](https://github.com/tiangolo). 151 | * 👷 Add automatic scheduled CI every monday. PR [#38](https://github.com/tiangolo/docker-with-compose/pull/38) by [@tiangolo](https://github.com/tiangolo). 152 | * 👷 Add automatic scheduled CI every Monday. PR [#37](https://github.com/tiangolo/docker-with-compose/pull/37) by [@tiangolo](https://github.com/tiangolo). 153 | * 📝 Update README, replace bash with shell, as Bash itself is not installed. PR [#36](https://github.com/tiangolo/docker-with-compose/pull/36) by [@tiangolo](https://github.com/tiangolo). 154 | * 👷 Add alls-green GitHub Action. PR [#35](https://github.com/tiangolo/docker-with-compose/pull/35) by [@tiangolo](https://github.com/tiangolo). 155 | * 👷 Do not run double CI for PRs, run on push only on master. PR [#34](https://github.com/tiangolo/docker-with-compose/pull/34) by [@tiangolo](https://github.com/tiangolo). 156 | * ⬆️ Bump tiangolo/issue-manager from 0.3.0 to 0.4.0. PR [#28](https://github.com/tiangolo/docker-with-compose/pull/28) by [@dependabot[bot]](https://github.com/apps/dependabot). 157 | * Bump actions/checkout from 2 to 3.1.0. PR [#31](https://github.com/tiangolo/docker-with-compose/pull/31) by [@dependabot[bot]](https://github.com/apps/dependabot). 158 | * 🐛 Fix deployment. PR [#26](https://github.com/tiangolo/docker-with-compose/pull/26) by [@tiangolo](https://github.com/tiangolo). 159 | * 🐛 Fix GitHub Actions and latest requirements. PR [#25](https://github.com/tiangolo/docker-with-compose/pull/25) by [@tiangolo](https://github.com/tiangolo). 160 | * 👷 Move from Travis to GitHub Actions. PR [#23](https://github.com/tiangolo/docker-with-compose/pull/23) by [@tiangolo](https://github.com/tiangolo). 161 | * ✨ Add external dependencies and Dependabot to get automated upgrade PRs. PR [#27](https://github.com/tiangolo/docker-with-compose/pull/27) by [@tiangolo](https://github.com/tiangolo). 162 | * 👷 Add Latest Changes GitHub Action. PR [#24](https://github.com/tiangolo/docker-with-compose/pull/24) by [@tiangolo](https://github.com/tiangolo). 163 | * Upgrade Python to use version 3.x. PR [#15](https://github.com/tiangolo/docker-with-compose/pull/15). 164 | * Add `curl` to the installed and available packages. PR [#14](https://github.com/tiangolo/docker-with-compose/pull/14) by [@stratosgear](https://github.com/stratosgear). 165 | * Add Travis CI. PR [#4](https://github.com/tiangolo/docker-with-compose/pull/4). 166 | * Upgrade Docker Compose installation. PR [#3](https://github.com/tiangolo/docker-with-compose/pull/3) by [@boskiv](https://github.com/boskiv). 167 | 168 | ## License 169 | 170 | This project is licensed under the terms of the MIT license. 171 | --------------------------------------------------------------------------------