From 0d67ba76dee563418962fd69c961f77ac2f6f1a2 Mon Sep 17 00:00:00 2001 From: Laurent Goderre Date: Tue, 1 Nov 2016 14:41:24 -0400 Subject: [PATCH] Added a variant of Docker-in-Docker with docker compose --- 1.11/dind-compose/Dockerfile | 15 +++++++++++++++ 1.11/dind-compose/dockerd-entrypoint.sh | 21 +++++++++++++++++++++ 1.12/dind-compose/Dockerfile | 15 +++++++++++++++ 1.12/dind-compose/dockerd-entrypoint.sh | 21 +++++++++++++++++++++ 4 files changed, 72 insertions(+) create mode 100644 1.11/dind-compose/Dockerfile create mode 100755 1.11/dind-compose/dockerd-entrypoint.sh create mode 100644 1.12/dind-compose/Dockerfile create mode 100755 1.12/dind-compose/dockerd-entrypoint.sh diff --git a/1.11/dind-compose/Dockerfile b/1.11/dind-compose/Dockerfile new file mode 100644 index 000000000..88152620e --- /dev/null +++ b/1.11/dind-compose/Dockerfile @@ -0,0 +1,15 @@ +FROM docker:1.11-dind + +RUN apk add --no-cache \ + 'py-pip==8.1.2-r0' + +RUN set -x \ + && pip install 'docker-compose' + +COPY dockerd-entrypoint.sh /usr/local/bin/ + +VOLUME /var/lib/docker +EXPOSE 2375 + +ENTRYPOINT ["dockerd-entrypoint.sh"] +CMD [] diff --git a/1.11/dind-compose/dockerd-entrypoint.sh b/1.11/dind-compose/dockerd-entrypoint.sh new file mode 100755 index 000000000..95680bd4a --- /dev/null +++ b/1.11/dind-compose/dockerd-entrypoint.sh @@ -0,0 +1,21 @@ +#!/bin/sh +set -e + +# no arguments passed +# or first arg is `-f` or `--some-option` +if [ "$#" -eq 0 -o "${1#-}" != "$1" ]; then + # add our default arguments + set -- docker daemon \ + --host=unix:///var/run/docker.sock \ + --host=tcp://0.0.0.0:2375 \ + --storage-driver=vfs \ + "$@" +fi + +if [ "$1" = 'docker' -a "$2" = 'daemon' ]; then + # if we're running Docker, let's pipe through dind + # (and we'll run dind explicitly with "sh" since its shebang is /bin/bash) + set -- sh "$(which dind)" "$@" +fi + +exec "$@" diff --git a/1.12/dind-compose/Dockerfile b/1.12/dind-compose/Dockerfile new file mode 100644 index 000000000..f7f4ff514 --- /dev/null +++ b/1.12/dind-compose/Dockerfile @@ -0,0 +1,15 @@ +FROM docker:1.12-dind + +RUN apk add --no-cache \ + 'py-pip==8.1.2-r0' + +RUN set -x \ + && pip install 'docker-compose' + +COPY dockerd-entrypoint.sh /usr/local/bin/ + +VOLUME /var/lib/docker +EXPOSE 2375 + +ENTRYPOINT ["dockerd-entrypoint.sh"] +CMD [] diff --git a/1.12/dind-compose/dockerd-entrypoint.sh b/1.12/dind-compose/dockerd-entrypoint.sh new file mode 100755 index 000000000..95680bd4a --- /dev/null +++ b/1.12/dind-compose/dockerd-entrypoint.sh @@ -0,0 +1,21 @@ +#!/bin/sh +set -e + +# no arguments passed +# or first arg is `-f` or `--some-option` +if [ "$#" -eq 0 -o "${1#-}" != "$1" ]; then + # add our default arguments + set -- docker daemon \ + --host=unix:///var/run/docker.sock \ + --host=tcp://0.0.0.0:2375 \ + --storage-driver=vfs \ + "$@" +fi + +if [ "$1" = 'docker' -a "$2" = 'daemon' ]; then + # if we're running Docker, let's pipe through dind + # (and we'll run dind explicitly with "sh" since its shebang is /bin/bash) + set -- sh "$(which dind)" "$@" +fi + +exec "$@"