diff --git a/.architectures-lib b/.architectures-lib deleted file mode 100644 index 88e72f8bb..000000000 --- a/.architectures-lib +++ /dev/null @@ -1,53 +0,0 @@ -#!/usr/bin/env bash - -_awkArch() { - local awkExpr="$1"; shift - awk "$@" "/^#|^\$/ { next } $awkExpr" release-architectures -} - -hasBashbrewArch() { - local bashbrewArch="$1"; shift - _awkArch 'BEGIN { exitCode = 1 } $1 == bashbrewArch { exitCode = 0 } END { exit exitCode }' -v bashbrewArch="$bashbrewArch" -} - -apkArches() { - _awkArch '{ print $2 }' -} - -apkToDockerArch() { - local apkArch="$1"; shift - _awkArch '$2 == apkArch { print $3; exit }' -v apkArch="$apkArch" -} - -apkToBashbrewArch() { - local apkArch="$1"; shift - _awkArch '$2 == apkArch { print $1; exit }' -v apkArch="$apkArch" -} - -_generateParentRepoToArches() { - local repo="$1"; shift - local officialImagesUrl='https://github.com/docker-library/official-images/raw/master/library/' - - eval "declare -g -A parentRepoToArches=( $( - find -name 'Dockerfile' -exec awk ' - toupper($1) == "FROM" && $2 !~ /^('"$repo"'|scratch|.*\/.*)(:|$)/ { - print "'"$officialImagesUrl"'" $2 - } - ' '{}' + \ - | sort -u \ - | xargs bashbrew cat --format '[{{ .RepoName }}:{{ .TagName }}]="{{ join " " .TagEntry.Architectures }}"' - ) )" -} -_generateParentRepoToArches 'docker' - -versionChannel() { - local version="$1"; shift # "17.06", "17.11-rc", etc - local rcVersion="${version%-rc}" - - local channel='stable' - if [ "$rcVersion" != "$version" ]; then - channel='test' - fi - - echo "$channel" -} diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 000000000..c70f75d2c --- /dev/null +++ b/.gitattributes @@ -0,0 +1,5 @@ +/*/**/Dockerfile linguist-generated +/*/**/docker-entrypoint.sh linguist-generated +/*/**/dockerd-entrypoint.sh linguist-generated +/*/**/modprobe.sh linguist-generated +/Dockerfile*.template linguist-language=Dockerfile diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 000000000..264cebf62 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,56 @@ +name: GitHub CI + +on: + pull_request: + push: + workflow_dispatch: + schedule: + - cron: 0 0 * * 0 + +defaults: + run: + shell: 'bash -Eeuo pipefail -x {0}' + +concurrency: + group: ${{ github.ref }} + cancel-in-progress: true + +jobs: + + generate-jobs: + name: Generate Jobs + runs-on: ubuntu-latest + outputs: + strategy: ${{ steps.generate-jobs.outputs.strategy }} + steps: + - uses: actions/checkout@v4 + - uses: docker-library/bashbrew@HEAD + - id: generate-jobs + name: Generate Jobs + run: | + strategy="$("$BASHBREW_SCRIPTS/github-actions/generate.sh")" + + EOF="EOF-$RANDOM-$RANDOM-$RANDOM" + echo "strategy<<$EOF" >> "$GITHUB_OUTPUT" + jq <<<"$strategy" . | tee -a "$GITHUB_OUTPUT" + echo "$EOF" >> "$GITHUB_OUTPUT" + + test: + needs: generate-jobs + strategy: ${{ fromJson(needs.generate-jobs.outputs.strategy) }} + name: ${{ matrix.name }} + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v4 + - name: Prepare Environment + run: ${{ matrix.runs.prepare }} + - name: Pull Dependencies + run: ${{ matrix.runs.pull }} + - name: Build ${{ matrix.name }} + run: ${{ matrix.runs.build }} + - name: History ${{ matrix.name }} + run: ${{ matrix.runs.history }} + - name: Test ${{ matrix.name }} + run: ${{ matrix.runs.test }} + - name: '"docker images"' + run: ${{ matrix.runs.images }} diff --git a/.github/workflows/verify-templating.yml b/.github/workflows/verify-templating.yml new file mode 100644 index 000000000..e822ba6bb --- /dev/null +++ b/.github/workflows/verify-templating.yml @@ -0,0 +1,19 @@ +name: Verify Templating + +on: + pull_request: + push: + workflow_dispatch: + +defaults: + run: + shell: 'bash -Eeuo pipefail -x {0}' + +jobs: + apply-templates: + name: Check For Uncomitted Changes + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - run: ./apply-templates.sh + - run: git diff --exit-code diff --git a/.gitignore b/.gitignore new file mode 100644 index 000000000..d548f66de --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.jq-template.awk diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 2d835907a..000000000 --- a/.travis.yml +++ /dev/null @@ -1,27 +0,0 @@ -language: bash -services: docker - -env: - - VERSION=19.03-rc - - VERSION=19.03 - -install: - - git clone https://github.com/docker-library/official-images.git ~/official-images - -before_script: - - env | sort - - cd "$VERSION" - - image="docker:$VERSION" - -script: - - travis_retry docker build -t "$image" . - - ~/official-images/test/run.sh "$image" - - travis_retry docker build -t "$image-dind" dind - - ~/official-images/test/run.sh "$image-dind" - - travis_retry docker build -t "$image-git" git - - ~/official-images/test/run.sh "$image-git" - -after_script: - - docker images - -# vim:set et ts=2 sw=2: diff --git a/19.03-rc/Dockerfile b/19.03-rc/Dockerfile deleted file mode 100644 index 889eb99e5..000000000 --- a/19.03-rc/Dockerfile +++ /dev/null @@ -1,64 +0,0 @@ -FROM alpine:3.11 - -RUN apk add --no-cache \ - ca-certificates \ -# DOCKER_HOST=ssh://... -- https://github.com/docker/cli/pull/1014 - openssh-client - -# set up nsswitch.conf for Go's "netgo" implementation (which Docker explicitly uses) -# - https://github.com/docker/docker-ce/blob/v17.09.0-ce/components/engine/hack/make.sh#L149 -# - https://github.com/golang/go/blob/go1.9.1/src/net/conf.go#L194-L275 -# - docker run --rm debian:stretch grep '^hosts:' /etc/nsswitch.conf -RUN [ ! -e /etc/nsswitch.conf ] && echo 'hosts: files dns' > /etc/nsswitch.conf - -ENV DOCKER_CHANNEL test -ENV DOCKER_VERSION 19.03.6-rc2 -# TODO ENV DOCKER_SHA256 -# https://github.com/docker/docker-ce/blob/5b073ee2cf564edee5adca05eee574142f7627bb/components/packaging/static/hash_files !! -# (no SHA file artifacts on download.docker.com yet as of 2017-06-07 though) - -RUN set -eux; \ - \ -# this "case" statement is generated via "update.sh" - apkArch="$(apk --print-arch)"; \ - case "$apkArch" in \ -# amd64 - x86_64) dockerArch='x86_64' ;; \ -# arm32v6 - armhf) dockerArch='armel' ;; \ -# arm32v7 - armv7) dockerArch='armhf' ;; \ -# arm64v8 - aarch64) dockerArch='aarch64' ;; \ - *) echo >&2 "error: unsupported architecture ($apkArch)"; exit 1 ;;\ - esac; \ - \ - if ! wget -O docker.tgz "https://download.docker.com/linux/static/${DOCKER_CHANNEL}/${dockerArch}/docker-${DOCKER_VERSION}.tgz"; then \ - echo >&2 "error: failed to download 'docker-${DOCKER_VERSION}' from '${DOCKER_CHANNEL}' for '${dockerArch}'"; \ - exit 1; \ - fi; \ - \ - tar --extract \ - --file docker.tgz \ - --strip-components 1 \ - --directory /usr/local/bin/ \ - ; \ - rm docker.tgz; \ - \ - dockerd --version; \ - docker --version - -COPY modprobe.sh /usr/local/bin/modprobe -COPY docker-entrypoint.sh /usr/local/bin/ - -# https://github.com/docker-library/docker/pull/166 -# dockerd-entrypoint.sh uses DOCKER_TLS_CERTDIR for auto-generating TLS certificates -# docker-entrypoint.sh uses DOCKER_TLS_CERTDIR for auto-setting DOCKER_TLS_VERIFY and DOCKER_CERT_PATH -# (For this to work, at least the "client" subdirectory of this path needs to be shared between the client and server containers via a volume, "docker cp", or other means of data sharing.) -ENV DOCKER_TLS_CERTDIR=/certs -# also, ensure the directory pre-exists and has wide enough permissions for "dockerd-entrypoint.sh" to create subdirectories, even when run in "rootless" mode -RUN mkdir /certs /certs/client && chmod 1777 /certs /certs/client -# (doing both /certs and /certs/client so that if Docker does a "copy-up" into a volume defined on /certs/client, it will "do the right thing" by default in a way that still works for rootless users) - -ENTRYPOINT ["docker-entrypoint.sh"] -CMD ["sh"] diff --git a/19.03-rc/dind-rootless/Dockerfile b/19.03-rc/dind-rootless/Dockerfile deleted file mode 100644 index 47984bd58..000000000 --- a/19.03-rc/dind-rootless/Dockerfile +++ /dev/null @@ -1,73 +0,0 @@ -FROM docker:19.03-rc-dind - -# busybox "ip" is insufficient: -# [rootlesskit:child ] error: executing [[ip tuntap add name tap0 mode tap] [ip link set tap0 address 02:50:00:00:00:01]]: exit status 1 -RUN apk add --no-cache iproute2 - -# "/run/user/UID" will be used by default as the value of XDG_RUNTIME_DIR -RUN mkdir /run/user && chmod 1777 /run/user - -# create a default user preconfigured for running rootless dockerd -RUN set -eux; \ - adduser -h /home/rootless -g 'Rootless' -D -u 1000 rootless; \ - echo 'rootless:100000:65536' >> /etc/subuid; \ - echo 'rootless:100000:65536' >> /etc/subgid - -RUN set -eux; \ - \ -# this "case" statement is generated via "update.sh" - apkArch="$(apk --print-arch)"; \ - case "$apkArch" in \ -# amd64 - x86_64) dockerArch='x86_64' ;; \ -# arm32v6 - armhf) dockerArch='armel' ;; \ -# arm32v7 - armv7) dockerArch='armhf' ;; \ -# arm64v8 - aarch64) dockerArch='aarch64' ;; \ - *) echo >&2 "error: unsupported architecture ($apkArch)"; exit 1 ;;\ - esac; \ - \ - if ! wget -O rootless.tgz "https://download.docker.com/linux/static/${DOCKER_CHANNEL}/${dockerArch}/docker-rootless-extras-${DOCKER_VERSION}.tgz"; then \ - echo >&2 "error: failed to download 'docker-rootless-extras-${DOCKER_VERSION}' from '${DOCKER_CHANNEL}' for '${dockerArch}'"; \ - exit 1; \ - fi; \ - \ - tar --extract \ - --file rootless.tgz \ - --strip-components 1 \ - --directory /usr/local/bin/ \ - 'docker-rootless-extras/vpnkit' \ - ; \ - rm rootless.tgz; \ - \ -# we download/build rootlesskit separately to get a newer release -# rootlesskit --version; \ - vpnkit --version - -# https://github.com/rootless-containers/rootlesskit/releases -ENV ROOTLESSKIT_VERSION 0.9.1 - -RUN set -eux; \ - apk add --no-cache --virtual .rootlesskit-build-deps \ - go \ - libc-dev \ - ; \ - wget -O rootlesskit.tgz "https://github.com/rootless-containers/rootlesskit/archive/v${ROOTLESSKIT_VERSION}.tar.gz"; \ - export GOPATH='/go'; mkdir "$GOPATH"; \ - mkdir -p "$GOPATH/src/github.com/rootless-containers/rootlesskit"; \ - tar --extract --file rootlesskit.tgz --directory "$GOPATH/src/github.com/rootless-containers/rootlesskit" --strip-components 1; \ - rm rootlesskit.tgz; \ - go build -o /usr/local/bin/rootlesskit github.com/rootless-containers/rootlesskit/cmd/rootlesskit; \ - go build -o /usr/local/bin/rootlesskit-docker-proxy github.com/rootless-containers/rootlesskit/cmd/rootlesskit-docker-proxy; \ - rm -rf "$GOPATH"; \ - apk del --no-network .rootlesskit-build-deps; \ - rootlesskit --version - -# pre-create "/var/lib/docker" for our rootless user -RUN set -eux; \ - mkdir -p /home/rootless/.local/share/docker; \ - chown -R rootless:rootless /home/rootless/.local/share/docker -VOLUME /home/rootless/.local/share/docker -USER rootless diff --git a/19.03-rc/dind/Dockerfile b/19.03-rc/dind/Dockerfile deleted file mode 100644 index 768f8c925..000000000 --- a/19.03-rc/dind/Dockerfile +++ /dev/null @@ -1,46 +0,0 @@ -FROM docker:19.03-rc - -# https://github.com/docker/docker/blob/master/project/PACKAGERS.md#runtime-dependencies -RUN set -eux; \ - apk add --no-cache \ - btrfs-progs \ - e2fsprogs \ - e2fsprogs-extra \ - iptables \ - openssl \ - shadow-uidmap \ - xfsprogs \ - xz \ -# pigz: https://github.com/moby/moby/pull/35697 (faster gzip implementation) - pigz \ - ; \ -# only install zfs if it's available for the current architecture -# https://git.alpinelinux.org/cgit/aports/tree/main/zfs/APKBUILD?h=3.6-stable#n9 ("all !armhf !ppc64le" as of 2017-11-01) -# "apk info XYZ" exits with a zero exit code but no output when the package exists but not for this arch - if zfs="$(apk info --no-cache --quiet zfs)" && [ -n "$zfs" ]; then \ - apk add --no-cache zfs; \ - fi - -# TODO aufs-tools - -# set up subuid/subgid so that "--userns-remap=default" works out-of-the-box -RUN set -x \ - && addgroup -S dockremap \ - && adduser -S -G dockremap dockremap \ - && echo 'dockremap:165536:65536' >> /etc/subuid \ - && echo 'dockremap:165536:65536' >> /etc/subgid - -# https://github.com/docker/docker/tree/master/hack/dind -ENV DIND_COMMIT 37498f009d8bf25fbb6199e8ccd34bed84f2874b - -RUN set -eux; \ - wget -O /usr/local/bin/dind "https://raw.githubusercontent.com/docker/docker/${DIND_COMMIT}/hack/dind"; \ - chmod +x /usr/local/bin/dind - -COPY dockerd-entrypoint.sh /usr/local/bin/ - -VOLUME /var/lib/docker -EXPOSE 2375 2376 - -ENTRYPOINT ["dockerd-entrypoint.sh"] -CMD [] diff --git a/19.03-rc/git/Dockerfile b/19.03-rc/git/Dockerfile deleted file mode 100644 index 88183ef05..000000000 --- a/19.03-rc/git/Dockerfile +++ /dev/null @@ -1,3 +0,0 @@ -FROM docker:19.03-rc - -RUN apk add --no-cache git diff --git a/19.03/Dockerfile b/19.03/Dockerfile deleted file mode 100644 index 007d88896..000000000 --- a/19.03/Dockerfile +++ /dev/null @@ -1,64 +0,0 @@ -FROM alpine:3.11 - -RUN apk add --no-cache \ - ca-certificates \ -# DOCKER_HOST=ssh://... -- https://github.com/docker/cli/pull/1014 - openssh-client - -# set up nsswitch.conf for Go's "netgo" implementation (which Docker explicitly uses) -# - https://github.com/docker/docker-ce/blob/v17.09.0-ce/components/engine/hack/make.sh#L149 -# - https://github.com/golang/go/blob/go1.9.1/src/net/conf.go#L194-L275 -# - docker run --rm debian:stretch grep '^hosts:' /etc/nsswitch.conf -RUN [ ! -e /etc/nsswitch.conf ] && echo 'hosts: files dns' > /etc/nsswitch.conf - -ENV DOCKER_CHANNEL stable -ENV DOCKER_VERSION 19.03.8 -# TODO ENV DOCKER_SHA256 -# https://github.com/docker/docker-ce/blob/5b073ee2cf564edee5adca05eee574142f7627bb/components/packaging/static/hash_files !! -# (no SHA file artifacts on download.docker.com yet as of 2017-06-07 though) - -RUN set -eux; \ - \ -# this "case" statement is generated via "update.sh" - apkArch="$(apk --print-arch)"; \ - case "$apkArch" in \ -# amd64 - x86_64) dockerArch='x86_64' ;; \ -# arm32v6 - armhf) dockerArch='armel' ;; \ -# arm32v7 - armv7) dockerArch='armhf' ;; \ -# arm64v8 - aarch64) dockerArch='aarch64' ;; \ - *) echo >&2 "error: unsupported architecture ($apkArch)"; exit 1 ;;\ - esac; \ - \ - if ! wget -O docker.tgz "https://download.docker.com/linux/static/${DOCKER_CHANNEL}/${dockerArch}/docker-${DOCKER_VERSION}.tgz"; then \ - echo >&2 "error: failed to download 'docker-${DOCKER_VERSION}' from '${DOCKER_CHANNEL}' for '${dockerArch}'"; \ - exit 1; \ - fi; \ - \ - tar --extract \ - --file docker.tgz \ - --strip-components 1 \ - --directory /usr/local/bin/ \ - ; \ - rm docker.tgz; \ - \ - dockerd --version; \ - docker --version - -COPY modprobe.sh /usr/local/bin/modprobe -COPY docker-entrypoint.sh /usr/local/bin/ - -# https://github.com/docker-library/docker/pull/166 -# dockerd-entrypoint.sh uses DOCKER_TLS_CERTDIR for auto-generating TLS certificates -# docker-entrypoint.sh uses DOCKER_TLS_CERTDIR for auto-setting DOCKER_TLS_VERIFY and DOCKER_CERT_PATH -# (For this to work, at least the "client" subdirectory of this path needs to be shared between the client and server containers via a volume, "docker cp", or other means of data sharing.) -ENV DOCKER_TLS_CERTDIR=/certs -# also, ensure the directory pre-exists and has wide enough permissions for "dockerd-entrypoint.sh" to create subdirectories, even when run in "rootless" mode -RUN mkdir /certs /certs/client && chmod 1777 /certs /certs/client -# (doing both /certs and /certs/client so that if Docker does a "copy-up" into a volume defined on /certs/client, it will "do the right thing" by default in a way that still works for rootless users) - -ENTRYPOINT ["docker-entrypoint.sh"] -CMD ["sh"] diff --git a/19.03/dind-rootless/Dockerfile b/19.03/dind-rootless/Dockerfile deleted file mode 100644 index e77bcd670..000000000 --- a/19.03/dind-rootless/Dockerfile +++ /dev/null @@ -1,73 +0,0 @@ -FROM docker:19.03-dind - -# busybox "ip" is insufficient: -# [rootlesskit:child ] error: executing [[ip tuntap add name tap0 mode tap] [ip link set tap0 address 02:50:00:00:00:01]]: exit status 1 -RUN apk add --no-cache iproute2 - -# "/run/user/UID" will be used by default as the value of XDG_RUNTIME_DIR -RUN mkdir /run/user && chmod 1777 /run/user - -# create a default user preconfigured for running rootless dockerd -RUN set -eux; \ - adduser -h /home/rootless -g 'Rootless' -D -u 1000 rootless; \ - echo 'rootless:100000:65536' >> /etc/subuid; \ - echo 'rootless:100000:65536' >> /etc/subgid - -RUN set -eux; \ - \ -# this "case" statement is generated via "update.sh" - apkArch="$(apk --print-arch)"; \ - case "$apkArch" in \ -# amd64 - x86_64) dockerArch='x86_64' ;; \ -# arm32v6 - armhf) dockerArch='armel' ;; \ -# arm32v7 - armv7) dockerArch='armhf' ;; \ -# arm64v8 - aarch64) dockerArch='aarch64' ;; \ - *) echo >&2 "error: unsupported architecture ($apkArch)"; exit 1 ;;\ - esac; \ - \ - if ! wget -O rootless.tgz "https://download.docker.com/linux/static/${DOCKER_CHANNEL}/${dockerArch}/docker-rootless-extras-${DOCKER_VERSION}.tgz"; then \ - echo >&2 "error: failed to download 'docker-rootless-extras-${DOCKER_VERSION}' from '${DOCKER_CHANNEL}' for '${dockerArch}'"; \ - exit 1; \ - fi; \ - \ - tar --extract \ - --file rootless.tgz \ - --strip-components 1 \ - --directory /usr/local/bin/ \ - 'docker-rootless-extras/vpnkit' \ - ; \ - rm rootless.tgz; \ - \ -# we download/build rootlesskit separately to get a newer release -# rootlesskit --version; \ - vpnkit --version - -# https://github.com/rootless-containers/rootlesskit/releases -ENV ROOTLESSKIT_VERSION 0.9.1 - -RUN set -eux; \ - apk add --no-cache --virtual .rootlesskit-build-deps \ - go \ - libc-dev \ - ; \ - wget -O rootlesskit.tgz "https://github.com/rootless-containers/rootlesskit/archive/v${ROOTLESSKIT_VERSION}.tar.gz"; \ - export GOPATH='/go'; mkdir "$GOPATH"; \ - mkdir -p "$GOPATH/src/github.com/rootless-containers/rootlesskit"; \ - tar --extract --file rootlesskit.tgz --directory "$GOPATH/src/github.com/rootless-containers/rootlesskit" --strip-components 1; \ - rm rootlesskit.tgz; \ - go build -o /usr/local/bin/rootlesskit github.com/rootless-containers/rootlesskit/cmd/rootlesskit; \ - go build -o /usr/local/bin/rootlesskit-docker-proxy github.com/rootless-containers/rootlesskit/cmd/rootlesskit-docker-proxy; \ - rm -rf "$GOPATH"; \ - apk del --no-network .rootlesskit-build-deps; \ - rootlesskit --version - -# pre-create "/var/lib/docker" for our rootless user -RUN set -eux; \ - mkdir -p /home/rootless/.local/share/docker; \ - chown -R rootless:rootless /home/rootless/.local/share/docker -VOLUME /home/rootless/.local/share/docker -USER rootless diff --git a/19.03/dind/Dockerfile b/19.03/dind/Dockerfile deleted file mode 100644 index eec9871d5..000000000 --- a/19.03/dind/Dockerfile +++ /dev/null @@ -1,46 +0,0 @@ -FROM docker:19.03 - -# https://github.com/docker/docker/blob/master/project/PACKAGERS.md#runtime-dependencies -RUN set -eux; \ - apk add --no-cache \ - btrfs-progs \ - e2fsprogs \ - e2fsprogs-extra \ - iptables \ - openssl \ - shadow-uidmap \ - xfsprogs \ - xz \ -# pigz: https://github.com/moby/moby/pull/35697 (faster gzip implementation) - pigz \ - ; \ -# only install zfs if it's available for the current architecture -# https://git.alpinelinux.org/cgit/aports/tree/main/zfs/APKBUILD?h=3.6-stable#n9 ("all !armhf !ppc64le" as of 2017-11-01) -# "apk info XYZ" exits with a zero exit code but no output when the package exists but not for this arch - if zfs="$(apk info --no-cache --quiet zfs)" && [ -n "$zfs" ]; then \ - apk add --no-cache zfs; \ - fi - -# TODO aufs-tools - -# set up subuid/subgid so that "--userns-remap=default" works out-of-the-box -RUN set -x \ - && addgroup -S dockremap \ - && adduser -S -G dockremap dockremap \ - && echo 'dockremap:165536:65536' >> /etc/subuid \ - && echo 'dockremap:165536:65536' >> /etc/subgid - -# https://github.com/docker/docker/tree/master/hack/dind -ENV DIND_COMMIT 37498f009d8bf25fbb6199e8ccd34bed84f2874b - -RUN set -eux; \ - wget -O /usr/local/bin/dind "https://raw.githubusercontent.com/docker/docker/${DIND_COMMIT}/hack/dind"; \ - chmod +x /usr/local/bin/dind - -COPY dockerd-entrypoint.sh /usr/local/bin/ - -VOLUME /var/lib/docker -EXPOSE 2375 2376 - -ENTRYPOINT ["dockerd-entrypoint.sh"] -CMD [] diff --git a/19.03/dind/dockerd-entrypoint.sh b/19.03/dind/dockerd-entrypoint.sh deleted file mode 100755 index 42aab58a8..000000000 --- a/19.03/dind/dockerd-entrypoint.sh +++ /dev/null @@ -1,186 +0,0 @@ -#!/bin/sh -set -eu - -_tls_ensure_private() { - local f="$1"; shift - [ -s "$f" ] || openssl genrsa -out "$f" 4096 -} -_tls_san() { - { - ip -oneline address | awk '{ gsub(/\/.+$/, "", $4); print "IP:" $4 }' - { - cat /etc/hostname - echo 'docker' - echo 'localhost' - hostname -f - hostname -s - } | sed 's/^/DNS:/' - [ -z "${DOCKER_TLS_SAN:-}" ] || echo "$DOCKER_TLS_SAN" - } | sort -u | xargs printf '%s,' | sed "s/,\$//" -} -_tls_generate_certs() { - local dir="$1"; shift - - # if ca/key.pem || !ca/cert.pem, generate CA public if necessary - # if ca/key.pem, generate server public - # if ca/key.pem, generate client public - # (regenerating public certs every startup to account for SAN/IP changes and/or expiration) - - # https://github.com/FiloSottile/mkcert/issues/174 - local certValidDays='825' - - if [ -s "$dir/ca/key.pem" ] || [ ! -s "$dir/ca/cert.pem" ]; then - # if we either have a CA private key or do *not* have a CA public key, then we should create/manage the CA - mkdir -p "$dir/ca" - _tls_ensure_private "$dir/ca/key.pem" - openssl req -new -key "$dir/ca/key.pem" \ - -out "$dir/ca/cert.pem" \ - -subj '/CN=docker:dind CA' -x509 -days "$certValidDays" - fi - - if [ -s "$dir/ca/key.pem" ]; then - # if we have a CA private key, we should create/manage a server key - mkdir -p "$dir/server" - _tls_ensure_private "$dir/server/key.pem" - openssl req -new -key "$dir/server/key.pem" \ - -out "$dir/server/csr.pem" \ - -subj '/CN=docker:dind server' - cat > "$dir/server/openssl.cnf" <<-EOF - [ x509_exts ] - subjectAltName = $(_tls_san) - EOF - openssl x509 -req \ - -in "$dir/server/csr.pem" \ - -CA "$dir/ca/cert.pem" \ - -CAkey "$dir/ca/key.pem" \ - -CAcreateserial \ - -out "$dir/server/cert.pem" \ - -days "$certValidDays" \ - -extfile "$dir/server/openssl.cnf" \ - -extensions x509_exts - cp "$dir/ca/cert.pem" "$dir/server/ca.pem" - openssl verify -CAfile "$dir/server/ca.pem" "$dir/server/cert.pem" - fi - - if [ -s "$dir/ca/key.pem" ]; then - # if we have a CA private key, we should create/manage a client key - mkdir -p "$dir/client" - _tls_ensure_private "$dir/client/key.pem" - chmod 0644 "$dir/client/key.pem" # openssl defaults to 0600 for the private key, but this one needs to be shared with arbitrary client contexts - openssl req -new \ - -key "$dir/client/key.pem" \ - -out "$dir/client/csr.pem" \ - -subj '/CN=docker:dind client' - cat > "$dir/client/openssl.cnf" <<-'EOF' - [ x509_exts ] - extendedKeyUsage = clientAuth - EOF - openssl x509 -req \ - -in "$dir/client/csr.pem" \ - -CA "$dir/ca/cert.pem" \ - -CAkey "$dir/ca/key.pem" \ - -CAcreateserial \ - -out "$dir/client/cert.pem" \ - -days "$certValidDays" \ - -extfile "$dir/client/openssl.cnf" \ - -extensions x509_exts - cp "$dir/ca/cert.pem" "$dir/client/ca.pem" - openssl verify -CAfile "$dir/client/ca.pem" "$dir/client/cert.pem" - fi -} - -# no arguments passed -# or first arg is `-f` or `--some-option` -if [ "$#" -eq 0 ] || [ "${1#-}" != "$1" ]; then - # set "dockerSocket" to the default "--host" *unix socket* value (for both standard or rootless) - uid="$(id -u)" - if [ "$uid" = '0' ]; then - dockerSocket='unix:///var/run/docker.sock' - else - # if we're not root, we must be trying to run rootless - : "${XDG_RUNTIME_DIR:=/run/user/$uid}" - dockerSocket="unix://$XDG_RUNTIME_DIR/docker.sock" - fi - case "${DOCKER_HOST:-}" in - unix://*) - dockerSocket="$DOCKER_HOST" - ;; - esac - - # add our default arguments - if [ -n "${DOCKER_TLS_CERTDIR:-}" ] \ - && _tls_generate_certs "$DOCKER_TLS_CERTDIR" \ - && [ -s "$DOCKER_TLS_CERTDIR/server/ca.pem" ] \ - && [ -s "$DOCKER_TLS_CERTDIR/server/cert.pem" ] \ - && [ -s "$DOCKER_TLS_CERTDIR/server/key.pem" ] \ - ; then - # generate certs and use TLS if requested/possible (default in 19.03+) - set -- dockerd \ - --host="$dockerSocket" \ - --host=tcp://0.0.0.0:2376 \ - --tlsverify \ - --tlscacert "$DOCKER_TLS_CERTDIR/server/ca.pem" \ - --tlscert "$DOCKER_TLS_CERTDIR/server/cert.pem" \ - --tlskey "$DOCKER_TLS_CERTDIR/server/key.pem" \ - "$@" - DOCKERD_ROOTLESS_ROOTLESSKIT_FLAGS="${DOCKERD_ROOTLESS_ROOTLESSKIT_FLAGS:-} -p 0.0.0.0:2376:2376/tcp" - else - # TLS disabled (-e DOCKER_TLS_CERTDIR='') or missing certs - set -- dockerd \ - --host="$dockerSocket" \ - --host=tcp://0.0.0.0:2375 \ - "$@" - DOCKERD_ROOTLESS_ROOTLESSKIT_FLAGS="${DOCKERD_ROOTLESS_ROOTLESSKIT_FLAGS:-} -p 0.0.0.0:2375:2375/tcp" - fi -fi - -if [ "$1" = 'dockerd' ]; then - # explicitly remove Docker's default PID file to ensure that it can start properly if it was stopped uncleanly (and thus didn't clean up the PID file) - find /run /var/run -iname 'docker*.pid' -delete || : - - uid="$(id -u)" - if [ "$uid" != '0' ]; then - # if we're not root, we must be trying to run rootless - if ! command -v rootlesskit > /dev/null; then - echo >&2 "error: attempting to run rootless dockerd but missing 'rootlesskit' (perhaps the 'docker:dind-rootless' image variant is intended?)" - exit 1 - fi - user="$(id -un 2>/dev/null || :)" - if ! grep -qE "^($uid${user:+|$user}):" /etc/subuid || ! grep -qE "^($uid${user:+|$user}):" /etc/subgid; then - echo >&2 "error: attempting to run rootless dockerd but missing necessary entries in /etc/subuid and/or /etc/subgid for $uid" - exit 1 - fi - : "${XDG_RUNTIME_DIR:=/run/user/$uid}" - export XDG_RUNTIME_DIR - if ! mkdir -p "$XDG_RUNTIME_DIR" || [ ! -w "$XDG_RUNTIME_DIR" ] || ! mkdir -p "$HOME/.local/share/docker" || [ ! -w "$HOME/.local/share/docker" ]; then - echo >&2 "error: attempting to run rootless dockerd but need writable HOME ($HOME) and XDG_RUNTIME_DIR ($XDG_RUNTIME_DIR) for user $uid" - exit 1 - fi - if [ -f /proc/sys/kernel/unprivileged_userns_clone ] && unprivClone="$(cat /proc/sys/kernel/unprivileged_userns_clone)" && [ "$unprivClone" != '1' ]; then - echo >&2 "error: attempting to run rootless dockerd but need 'kernel.unprivileged_userns_clone' (/proc/sys/kernel/unprivileged_userns_clone) set to 1" - exit 1 - fi - if [ -f /proc/sys/user/max_user_namespaces ] && maxUserns="$(cat /proc/sys/user/max_user_namespaces)" && [ "$maxUserns" = '0' ]; then - echo >&2 "error: attempting to run rootless dockerd but need 'user.max_user_namespaces' (/proc/sys/user/max_user_namespaces) set to a sufficiently large value" - exit 1 - fi - # TODO overlay support detection? - exec rootlesskit \ - --net="${DOCKERD_ROOTLESS_ROOTLESSKIT_NET:-vpnkit}" \ - --mtu="${DOCKERD_ROOTLESS_ROOTLESSKIT_MTU:-1500}" \ - --disable-host-loopback \ - --port-driver=builtin \ - --copy-up=/etc \ - --copy-up=/run \ - ${DOCKERD_ROOTLESS_ROOTLESSKIT_FLAGS:-} \ - "$@" --userland-proxy-path=rootlesskit-docker-proxy - elif [ -x '/usr/local/bin/dind' ]; then - # if we have the (mostly defunct now) Docker-in-Docker wrapper script, use it - set -- '/usr/local/bin/dind' "$@" - fi -else - # if it isn't `dockerd` we're trying to run, pass it through `docker-entrypoint.sh` so it gets `DOCKER_HOST` set appropriately too - set -- docker-entrypoint.sh "$@" -fi - -exec "$@" diff --git a/19.03/docker-entrypoint.sh b/19.03/docker-entrypoint.sh deleted file mode 100755 index d41cef8e3..000000000 --- a/19.03/docker-entrypoint.sh +++ /dev/null @@ -1,61 +0,0 @@ -#!/bin/sh -set -eu - -# first arg is `-f` or `--some-option` -if [ "${1#-}" != "$1" ]; then - set -- docker "$@" -fi - -# if our command is a valid Docker subcommand, let's invoke it through Docker instead -# (this allows for "docker run docker ps", etc) -if docker help "$1" > /dev/null 2>&1; then - set -- docker "$@" -fi - -_should_tls() { - [ -n "${DOCKER_TLS_CERTDIR:-}" ] \ - && [ -s "$DOCKER_TLS_CERTDIR/client/ca.pem" ] \ - && [ -s "$DOCKER_TLS_CERTDIR/client/cert.pem" ] \ - && [ -s "$DOCKER_TLS_CERTDIR/client/key.pem" ] -} - -# if we have no DOCKER_HOST but we do have the default Unix socket (standard or rootless), use it explicitly -if [ -z "${DOCKER_HOST:-}" ] && [ -S /var/run/docker.sock ]; then - export DOCKER_HOST=unix:///var/run/docker.sock -elif [ -z "${DOCKER_HOST:-}" ] && XDG_RUNTIME_DIR="${XDG_RUNTIME_DIR:-/run/user/$(id -u)}" && [ -S "$XDG_RUNTIME_DIR/docker.sock" ]; then - export DOCKER_HOST="unix://$XDG_RUNTIME_DIR/docker.sock" -fi - -# if DOCKER_HOST isn't set (no custom setting, no default socket), let's set it to a sane remote value -if [ -z "${DOCKER_HOST:-}" ]; then - if _should_tls || [ -n "${DOCKER_TLS_VERIFY:-}" ]; then - export DOCKER_HOST='tcp://docker:2376' - else - export DOCKER_HOST='tcp://docker:2375' - fi -fi -if [ "${DOCKER_HOST#tcp:}" != "$DOCKER_HOST" ] \ - && [ -z "${DOCKER_TLS_VERIFY:-}" ] \ - && [ -z "${DOCKER_CERT_PATH:-}" ] \ - && _should_tls \ -; then - export DOCKER_TLS_VERIFY=1 - export DOCKER_CERT_PATH="$DOCKER_TLS_CERTDIR/client" -fi - -if [ "$1" = 'dockerd' ]; then - cat >&2 <<-'EOW' - - 📎 Hey there! It looks like you're trying to run a Docker daemon. - - You probably should use the "dind" image variant instead, something like: - - docker run --privileged --name some-docker ... docker:dind ... - - See https://hub.docker.com/_/docker/ for more documentation and usage examples. - - EOW - sleep 3 -fi - -exec "$@" diff --git a/19.03/git/Dockerfile b/19.03/git/Dockerfile deleted file mode 100644 index 2c8edb9f8..000000000 --- a/19.03/git/Dockerfile +++ /dev/null @@ -1,3 +0,0 @@ -FROM docker:19.03 - -RUN apk add --no-cache git diff --git a/19.03/modprobe.sh b/19.03/modprobe.sh deleted file mode 100755 index b357d893f..000000000 --- a/19.03/modprobe.sh +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/sh -set -eu - -# "modprobe" without modprobe -# https://twitter.com/lucabruno/status/902934379835662336 - -# this isn't 100% fool-proof, but it'll have a much higher success rate than simply using the "real" modprobe - -# Docker often uses "modprobe -va foo bar baz" -# so we ignore modules that start with "-" -for module; do - if [ "${module#-}" = "$module" ]; then - ip link show "$module" || true - lsmod | grep "$module" || true - fi -done - -# remove /usr/local/... from PATH so we can exec the real modprobe as a last resort -export PATH='/usr/sbin:/usr/bin:/sbin:/bin' -exec modprobe "$@" diff --git a/29/cli/Dockerfile b/29/cli/Dockerfile new file mode 100644 index 000000000..a4c408851 --- /dev/null +++ b/29/cli/Dockerfile @@ -0,0 +1,180 @@ +# +# NOTE: THIS DOCKERFILE IS GENERATED VIA "apply-templates.sh" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# + +FROM alpine:3.24 + +RUN apk add --no-cache \ + ca-certificates \ +# DOCKER_HOST=ssh://... -- https://github.com/docker/cli/pull/1014 + openssh-client \ +# https://github.com/docker-library/docker/issues/482#issuecomment-2197116408 + git + +# ensure that nsswitch.conf is set up for Go's "netgo" implementation (which Docker explicitly uses) +# - https://github.com/moby/moby/blob/v24.0.6/hack/make.sh#L111 +# - https://github.com/golang/go/blob/go1.19.13/src/net/conf.go#L227-L303 +# - docker run --rm debian:stretch grep '^hosts:' /etc/nsswitch.conf +RUN [ -e /etc/nsswitch.conf ] && grep '^hosts: files dns' /etc/nsswitch.conf + +# pre-add a "docker" group for socket usage +RUN set -eux; \ + addgroup -g 2375 -S docker + +ENV DOCKER_VERSION 29.10.0 + +RUN set -eux; \ + \ + apkArch="$(apk --print-arch)"; \ + case "$apkArch" in \ + 'x86_64') \ + url='https://download.docker.com/linux/static/stable/x86_64/docker-29.10.0.tgz'; \ + sha256='7c1ebadc65c716cdc6d35fc78759ed0e4317debf43c21dd12f066f2006999def'; \ + ;; \ + 'armhf') \ + url='https://download.docker.com/linux/static/stable/armel/docker-29.10.0.tgz'; \ + sha256='b3e626f7560728eb601687da86c27edf9b7dd71f6a0f00737baeeb607c0f1d68'; \ + ;; \ + 'armv7') \ + url='https://download.docker.com/linux/static/stable/armhf/docker-29.10.0.tgz'; \ + sha256='08757af1f923c25d170211a1de8acc4e69e9cfbe7b5af63dd787afe2057efd5f'; \ + ;; \ + 'aarch64') \ + url='https://download.docker.com/linux/static/stable/aarch64/docker-29.10.0.tgz'; \ + sha256='6e5159e8b5615e0c0c2954a2a1a2a12bc65f5d9b603595dba24a10cb367408cd'; \ + ;; \ + 'ppc64le') \ + url='https://download.docker.com/linux/static/stable/ppc64le/docker-29.10.0.tgz'; \ + sha256='f07fe44072d1614de38effa6492f840653dfbf9e5a7d3a0a1dab4c2dad257190'; \ + ;; \ + 's390x') \ + url='https://download.docker.com/linux/static/stable/s390x/docker-29.10.0.tgz'; \ + sha256='09c4a2ec475121fe9c1485c65e9f54f1fa20aa4d68d0c4b271005db3943a763b'; \ + ;; \ + *) echo >&2 "error: unsupported 'docker.tgz' architecture ($apkArch)"; exit 1 ;; \ + esac; \ + \ + wget -O 'docker.tgz' "$url"; \ + echo "$sha256 *"'docker.tgz' | sha256sum -c -; \ + \ + tar --extract \ + --file docker.tgz \ + --strip-components 1 \ + --directory /usr/local/bin/ \ + --no-same-owner \ + 'docker/docker' \ + ; \ + rm docker.tgz; \ + \ + docker --version + +ENV DOCKER_BUILDX_VERSION 0.39.1 +RUN set -eux; \ + \ + apkArch="$(apk --print-arch)"; \ + case "$apkArch" in \ + 'x86_64') \ + url='https://github.com/docker/buildx/releases/download/v0.39.1/buildx-v0.39.1.linux-amd64'; \ + sha256='903090816da68f8bc1a2ff5346dd163a5adacfce4548d003c75df42cd47a9bf4'; \ + ;; \ + 'armhf') \ + url='https://github.com/docker/buildx/releases/download/v0.39.1/buildx-v0.39.1.linux-arm-v6'; \ + sha256='3675402568ec1a5b96792d6bde9ebdafb9d29e9681b7ff747e97d54c2198a735'; \ + ;; \ + 'armv7') \ + url='https://github.com/docker/buildx/releases/download/v0.39.1/buildx-v0.39.1.linux-arm-v7'; \ + sha256='e6c51234507ef11ea661a8f714412a5eb9abeba586da73dca82ad89410f03b13'; \ + ;; \ + 'aarch64') \ + url='https://github.com/docker/buildx/releases/download/v0.39.1/buildx-v0.39.1.linux-arm64'; \ + sha256='05c88e0f9152825e609a1cdb391faf14d5f94d23d071eaecb87bae69d98da8b8'; \ + ;; \ + 'ppc64le') \ + url='https://github.com/docker/buildx/releases/download/v0.39.1/buildx-v0.39.1.linux-ppc64le'; \ + sha256='69713727c669ca87660c2197a5b97389cbad189120ee405f801986e8459ef83b'; \ + ;; \ + 'riscv64') \ + url='https://github.com/docker/buildx/releases/download/v0.39.1/buildx-v0.39.1.linux-riscv64'; \ + sha256='b0af9b8cf5e8e244ea4049b4ca897c77a0b8b0d78c1b1cd7b8324d451de71ed8'; \ + ;; \ + 's390x') \ + url='https://github.com/docker/buildx/releases/download/v0.39.1/buildx-v0.39.1.linux-s390x'; \ + sha256='f611aa33cd5290ad1e2ca6d5357a06123541643698d729392d05a20d527e526e'; \ + ;; \ + *) echo >&2 "warning: unsupported 'docker-buildx' architecture ($apkArch); skipping"; exit 0 ;; \ + esac; \ + \ + wget -O 'docker-buildx' "$url"; \ + echo "$sha256 *"'docker-buildx' | sha256sum -c -; \ + \ + plugin='/usr/local/libexec/docker/cli-plugins/docker-buildx'; \ + mkdir -p "$(dirname "$plugin")"; \ + mv -vT 'docker-buildx' "$plugin"; \ + chmod +x "$plugin"; \ + \ + docker buildx version + +ENV DOCKER_COMPOSE_VERSION 5.8.0 +RUN set -eux; \ + \ + apkArch="$(apk --print-arch)"; \ + case "$apkArch" in \ + 'x86_64') \ + url='https://github.com/docker/compose/releases/download/v5.8.0/docker-compose-linux-x86_64'; \ + sha256='b8840f5008c447f41fce0a57ae3adeab42c89b1eb6e6012524bcabbfb4ffbaf6'; \ + ;; \ + 'armhf') \ + url='https://github.com/docker/compose/releases/download/v5.8.0/docker-compose-linux-armv6'; \ + sha256='c88658466ae9a4dadae64e6a4ec125202212bd460934537bd482bcd5e313f57b'; \ + ;; \ + 'armv7') \ + url='https://github.com/docker/compose/releases/download/v5.8.0/docker-compose-linux-armv7'; \ + sha256='a7a79755648b975b66df08b4bfbe12b29f113d5dd8c7cd5b6b53b69efff2f422'; \ + ;; \ + 'aarch64') \ + url='https://github.com/docker/compose/releases/download/v5.8.0/docker-compose-linux-aarch64'; \ + sha256='1a9c918b2fb49b9c87f0018c64b5abd0d30715155e98dc939779fbaee6c414d3'; \ + ;; \ + 'ppc64le') \ + url='https://github.com/docker/compose/releases/download/v5.8.0/docker-compose-linux-ppc64le'; \ + sha256='921437ba1fe9b5f7e3146c74c4d6c56673881741561c71bc23106b1e45886b1d'; \ + ;; \ + 'riscv64') \ + url='https://github.com/docker/compose/releases/download/v5.8.0/docker-compose-linux-riscv64'; \ + sha256='0af052a262dcf3a28214c7c86442046fc5e50b698e838d1904395d7a5333b142'; \ + ;; \ + 's390x') \ + url='https://github.com/docker/compose/releases/download/v5.8.0/docker-compose-linux-s390x'; \ + sha256='444af1a82eb51edd4a2aa5b1a209724f2acd19644e488fbd8c1dc8fd7d477f97'; \ + ;; \ + *) echo >&2 "warning: unsupported 'docker-compose' architecture ($apkArch); skipping"; exit 0 ;; \ + esac; \ + \ + wget -O 'docker-compose' "$url"; \ + echo "$sha256 *"'docker-compose' | sha256sum -c -; \ + \ + plugin='/usr/local/libexec/docker/cli-plugins/docker-compose'; \ + mkdir -p "$(dirname "$plugin")"; \ + mv -vT 'docker-compose' "$plugin"; \ + chmod +x "$plugin"; \ + \ + ln -sv "$plugin" /usr/local/bin/; \ + docker-compose --version; \ + docker compose version + +COPY modprobe.sh /usr/local/bin/modprobe +COPY docker-entrypoint.sh /usr/local/bin/ + +# https://github.com/docker-library/docker/pull/166 +# dockerd-entrypoint.sh uses DOCKER_TLS_CERTDIR for auto-generating TLS certificates +# docker-entrypoint.sh uses DOCKER_TLS_CERTDIR for auto-setting DOCKER_TLS_VERIFY and DOCKER_CERT_PATH +# (For this to work, at least the "client" subdirectory of this path needs to be shared between the client and server containers via a volume, "docker cp", or other means of data sharing.) +ENV DOCKER_TLS_CERTDIR=/certs +# also, ensure the directory pre-exists and has wide enough permissions for "dockerd-entrypoint.sh" to create subdirectories, even when run in "rootless" mode +RUN mkdir /certs /certs/client && chmod 1777 /certs /certs/client +# (doing both /certs and /certs/client so that if Docker does a "copy-up" into a volume defined on /certs/client, it will "do the right thing" by default in a way that still works for rootless users) + +ENTRYPOINT ["docker-entrypoint.sh"] +CMD ["sh"] diff --git a/19.03-rc/docker-entrypoint.sh b/29/cli/docker-entrypoint.sh similarity index 100% rename from 19.03-rc/docker-entrypoint.sh rename to 29/cli/docker-entrypoint.sh diff --git a/19.03-rc/modprobe.sh b/29/cli/modprobe.sh similarity index 100% rename from 19.03-rc/modprobe.sh rename to 29/cli/modprobe.sh diff --git a/29/dind-rootless/Dockerfile b/29/dind-rootless/Dockerfile new file mode 100644 index 000000000..14c7b650e --- /dev/null +++ b/29/dind-rootless/Dockerfile @@ -0,0 +1,56 @@ +# +# NOTE: THIS DOCKERFILE IS GENERATED VIA "apply-templates.sh" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# + +FROM docker:29-dind + +# busybox "ip" is insufficient: +# [rootlesskit:child ] error: executing [[ip tuntap add name tap0 mode tap] [ip link set tap0 address 02:50:00:00:00:01]]: exit status 1 +# slirp4netns is recommended as rootlesskit's net driver +# https://github.com/rootless-containers/rootlesskit/blob/be156df0429551f5c23dc61dd07201b33076ff1d/docs/network.md#--netslirp4netns-recommended +RUN apk add --no-cache iproute2 fuse-overlayfs slirp4netns + +# "/run/user/UID" will be used by default as the value of XDG_RUNTIME_DIR +RUN mkdir /run/user && chmod 1777 /run/user + +# create a default user preconfigured for running rootless dockerd +RUN set -eux; \ + adduser -h /home/rootless -g 'Rootless' -D -u 1000 rootless; \ + echo 'rootless:100000:65536' >> /etc/subuid; \ + echo 'rootless:100000:65536' >> /etc/subgid + +RUN set -eux; \ + \ + apkArch="$(apk --print-arch)"; \ + case "$apkArch" in \ + 'x86_64') \ + url='https://download.docker.com/linux/static/stable/x86_64/docker-rootless-extras-29.10.0.tgz'; \ + sha256='a4ad65be3921ac3e45f3fe69893f5edbd078cb3b4a6499fe13288053553dce25'; \ + ;; \ + 'aarch64') \ + url='https://download.docker.com/linux/static/stable/aarch64/docker-rootless-extras-29.10.0.tgz'; \ + sha256='6d08caae6a61e58f86c21dc94bcbf87f2b7a82bb634ef051243004a7f92f9e07'; \ + ;; \ + *) echo >&2 "error: unsupported 'rootless.tgz' architecture ($apkArch)"; exit 1 ;; \ + esac; \ + \ + wget -O 'rootless.tgz' "$url"; \ + \ + tar --extract \ + --file rootless.tgz \ + --strip-components 1 \ + --directory /usr/local/bin/ \ + 'docker-rootless-extras/rootlesskit' \ + ; \ + rm rootless.tgz; \ + \ + rootlesskit --version + +# pre-create "/var/lib/docker" for our rootless user +RUN set -eux; \ + mkdir -p /home/rootless/.local/share/docker; \ + chown -R rootless:rootless /home/rootless/.local/share/docker +VOLUME /home/rootless/.local/share/docker +USER rootless diff --git a/29/dind/Dockerfile b/29/dind/Dockerfile new file mode 100644 index 000000000..257e27f25 --- /dev/null +++ b/29/dind/Dockerfile @@ -0,0 +1,117 @@ +# +# NOTE: THIS DOCKERFILE IS GENERATED VIA "apply-templates.sh" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# + +FROM docker:29-cli + +# Runtime dependencies: +# - https://github.com/moby/moby/blob/864598f8c2677189e308eb4a3b3c0dd41fc06599/project/PACKAGERS.md#runtime-dependencies#runtime-dependencies +# - https://github.com/docker/packaging/blob/0ba325d178593583f190dc91566214a85c3880ad/pkg/docker-engine/deb/control#L24-L36 +RUN set -eux; \ + apk add --no-cache \ + ip6tables \ + iptables \ + openssl \ + pigz \ + shadow-uidmap \ + xz \ + ; + +# dind might be used on systems where the nf_tables kernel module isn't available. In that case, +# we need to switch over to xtables-legacy. See https://github.com/docker-library/docker/issues/463 +RUN set -eux; \ + apk add --no-cache iptables-legacy; \ +# set up a symlink farm we can use PATH to switch to legacy with + mkdir -p /usr/local/sbin/.iptables-legacy; \ +# https://gitlab.alpinelinux.org/alpine/aports/-/blob/a7e1610a67a46fc52668528efe01cee621c2ba6c/main/iptables/APKBUILD#L77 + for f in \ + iptables \ + iptables-save \ + iptables-restore \ + ip6tables \ + ip6tables-save \ + ip6tables-restore \ + ; do \ +# "iptables-save" -> "iptables-legacy-save", "ip6tables" -> "ip6tables-legacy", etc. +# https://pkgs.alpinelinux.org/contents?branch=v3.24&name=iptables-legacy&arch=x86_64 + b="$(command -v "${f/tables/tables-legacy}")"; \ + "$b" --version; \ + ln -svT "$b" "/usr/local/sbin/.iptables-legacy/$f"; \ + done; \ +# verify it works (and gets us legacy) + export PATH="/usr/local/sbin/.iptables-legacy:$PATH"; \ + iptables --version | grep legacy + +# set up subuid/subgid so that "--userns-remap=default" works out-of-the-box +RUN set -eux; \ + addgroup -S dockremap; \ + adduser -S -G dockremap dockremap; \ + echo 'dockremap:165536:65536' >> /etc/subuid; \ + echo 'dockremap:165536:65536' >> /etc/subgid + +RUN set -eux; \ + \ + apkArch="$(apk --print-arch)"; \ + case "$apkArch" in \ + 'x86_64') \ + url='https://download.docker.com/linux/static/stable/x86_64/docker-29.10.0.tgz'; \ + sha256='7c1ebadc65c716cdc6d35fc78759ed0e4317debf43c21dd12f066f2006999def'; \ + ;; \ + 'armhf') \ + url='https://download.docker.com/linux/static/stable/armel/docker-29.10.0.tgz'; \ + sha256='b3e626f7560728eb601687da86c27edf9b7dd71f6a0f00737baeeb607c0f1d68'; \ + ;; \ + 'armv7') \ + url='https://download.docker.com/linux/static/stable/armhf/docker-29.10.0.tgz'; \ + sha256='08757af1f923c25d170211a1de8acc4e69e9cfbe7b5af63dd787afe2057efd5f'; \ + ;; \ + 'aarch64') \ + url='https://download.docker.com/linux/static/stable/aarch64/docker-29.10.0.tgz'; \ + sha256='6e5159e8b5615e0c0c2954a2a1a2a12bc65f5d9b603595dba24a10cb367408cd'; \ + ;; \ + 'ppc64le') \ + url='https://download.docker.com/linux/static/stable/ppc64le/docker-29.10.0.tgz'; \ + sha256='f07fe44072d1614de38effa6492f840653dfbf9e5a7d3a0a1dab4c2dad257190'; \ + ;; \ + 's390x') \ + url='https://download.docker.com/linux/static/stable/s390x/docker-29.10.0.tgz'; \ + sha256='09c4a2ec475121fe9c1485c65e9f54f1fa20aa4d68d0c4b271005db3943a763b'; \ + ;; \ + *) echo >&2 "error: unsupported 'docker.tgz' architecture ($apkArch)"; exit 1 ;; \ + esac; \ + \ + wget -O 'docker.tgz' "$url"; \ + echo "$sha256 *"'docker.tgz' | sha256sum -c -; \ + \ + tar --extract \ + --file docker.tgz \ + --strip-components 1 \ + --directory /usr/local/bin/ \ + --no-same-owner \ +# we exclude the CLI binary because we already extracted that over in the "docker:29-cli" image that we're FROM and we don't want to duplicate those bytes again in this layer + --exclude 'docker/docker' \ +# exclude containerd, relying on the "embedded containerd" instead: https://github.com/moby/moby/pull/53388 (makes for a smaller image) + --exclude 'docker/containerd' \ + ; \ + rm docker.tgz; \ + \ + dockerd --version; \ + ctr --version; \ + runc --version + +# https://github.com/moby/moby/tree/master/hack/dind +ENV DIND_COMMIT 8d9e3502aba39127e4d12196dae16d306f76993d + +RUN set -eux; \ + wget -O /usr/local/bin/dind "https://raw.githubusercontent.com/moby/moby/${DIND_COMMIT}/hack/dind"; \ + chmod +x /usr/local/bin/dind + +COPY dockerd-entrypoint.sh /usr/local/bin/ + +VOLUME /var/lib/docker +EXPOSE 2375 2376 + +ENTRYPOINT ["dockerd-entrypoint.sh"] +CMD [] diff --git a/19.03-rc/dind/dockerd-entrypoint.sh b/29/dind/dockerd-entrypoint.sh similarity index 71% rename from 19.03-rc/dind/dockerd-entrypoint.sh rename to 29/dind/dockerd-entrypoint.sh index 42aab58a8..130883d69 100755 --- a/19.03-rc/dind/dockerd-entrypoint.sh +++ b/29/dind/dockerd-entrypoint.sh @@ -21,11 +21,17 @@ _tls_san() { _tls_generate_certs() { local dir="$1"; shift + # if server/{ca,key,cert}.pem && !ca/key.pem, do NOTHING except verify (user likely managing CA themselves) # if ca/key.pem || !ca/cert.pem, generate CA public if necessary # if ca/key.pem, generate server public # if ca/key.pem, generate client public # (regenerating public certs every startup to account for SAN/IP changes and/or expiration) + if [ -s "$dir/server/ca.pem" ] && [ -s "$dir/server/cert.pem" ] && [ -s "$dir/server/key.pem" ] && [ ! -s "$dir/ca/key.pem" ]; then + openssl verify -CAfile "$dir/server/ca.pem" "$dir/server/cert.pem" + return 0 + fi + # https://github.com/FiloSottile/mkcert/issues/174 local certValidDays='825' @@ -35,7 +41,10 @@ _tls_generate_certs() { _tls_ensure_private "$dir/ca/key.pem" openssl req -new -key "$dir/ca/key.pem" \ -out "$dir/ca/cert.pem" \ - -subj '/CN=docker:dind CA' -x509 -days "$certValidDays" + -subj '/CN=docker:dind CA' \ + -x509 \ + -days "$certValidDays" \ + -addext keyUsage=critical,digitalSignature,keyCertSign fi if [ -s "$dir/ca/key.pem" ]; then @@ -47,6 +56,7 @@ _tls_generate_certs() { -subj '/CN=docker:dind server' cat > "$dir/server/openssl.cnf" <<-EOF [ x509_exts ] + extendedKeyUsage = serverAuth subjectAltName = $(_tls_san) EOF openssl x509 -req \ @@ -108,12 +118,8 @@ if [ "$#" -eq 0 ] || [ "${1#-}" != "$1" ]; then esac # add our default arguments - if [ -n "${DOCKER_TLS_CERTDIR:-}" ] \ - && _tls_generate_certs "$DOCKER_TLS_CERTDIR" \ - && [ -s "$DOCKER_TLS_CERTDIR/server/ca.pem" ] \ - && [ -s "$DOCKER_TLS_CERTDIR/server/cert.pem" ] \ - && [ -s "$DOCKER_TLS_CERTDIR/server/key.pem" ] \ - ; then + if [ -n "${DOCKER_TLS_CERTDIR:-}" ]; then + _tls_generate_certs "$DOCKER_TLS_CERTDIR" # generate certs and use TLS if requested/possible (default in 19.03+) set -- dockerd \ --host="$dockerSocket" \ @@ -138,6 +144,52 @@ if [ "$1" = 'dockerd' ]; then # explicitly remove Docker's default PID file to ensure that it can start properly if it was stopped uncleanly (and thus didn't clean up the PID file) find /run /var/run -iname 'docker*.pid' -delete || : + # XXX inject "docker-init" (tini) as pid1 to workaround https://github.com/docker-library/docker/issues/318 (zombie container-shim processes) + set -- docker-init -- "$@" + + iptablesLegacy= + if [ -n "${DOCKER_IPTABLES_LEGACY+x}" ]; then + # let users choose explicitly to legacy or not to legacy + iptablesLegacy="$DOCKER_IPTABLES_LEGACY" + if [ -n "$iptablesLegacy" ]; then + modprobe ip_tables || : + modprobe ip6_tables || : + else + modprobe nf_tables || : + fi + elif ( + # https://git.netfilter.org/iptables/tree/iptables/nft-shared.c?id=f5cf76626d95d2c491a80288bccc160c53b44e88#n420 + # https://github.com/docker-library/docker/pull/468#discussion_r1442131459 + for f in /proc/net/ip_tables_names /proc/net/ip6_tables_names /proc/net/arp_tables_names; do + if [ -r "$f" ] && b="$(cat "$f")" && [ -n "$b" ]; then + exit 0 + fi + done + exit 1 + ); then + # if we already have any "legacy" iptables rules, we should always use legacy + iptablesLegacy=1 + elif ! iptables -nL > /dev/null 2>&1; then + # if iptables fails to run, chances are high the necessary kernel modules aren't loaded (perhaps the host is using xtables, for example) + # https://github.com/docker-library/docker/issues/350 + # https://github.com/moby/moby/issues/26824 + # https://github.com/docker-library/docker/pull/437#issuecomment-1854900620 + modprobe nf_tables || : + if ! iptables -nL > /dev/null 2>&1; then + # might be host has no nf_tables, but Alpine is all-in now (so let's try a legacy fallback) + modprobe ip_tables || : + modprobe ip6_tables || : + if /usr/local/sbin/.iptables-legacy/iptables -nL > /dev/null 2>&1; then + iptablesLegacy=1 + fi + fi + fi + if [ -n "$iptablesLegacy" ]; then + # see https://github.com/docker-library/docker/issues/463 (and the dind Dockerfile where this directory is set up) + export PATH="/usr/local/sbin/.iptables-legacy:$PATH" + fi + iptables --version # so users can see whether it's legacy or not + uid="$(id -u)" if [ "$uid" != '0' ]; then # if we're not root, we must be trying to run rootless @@ -166,14 +218,14 @@ if [ "$1" = 'dockerd' ]; then fi # TODO overlay support detection? exec rootlesskit \ - --net="${DOCKERD_ROOTLESS_ROOTLESSKIT_NET:-vpnkit}" \ + --net="${DOCKERD_ROOTLESS_ROOTLESSKIT_NET:-slirp4netns}" \ --mtu="${DOCKERD_ROOTLESS_ROOTLESSKIT_MTU:-1500}" \ --disable-host-loopback \ --port-driver=builtin \ --copy-up=/etc \ --copy-up=/run \ ${DOCKERD_ROOTLESS_ROOTLESSKIT_FLAGS:-} \ - "$@" --userland-proxy-path=rootlesskit-docker-proxy + "$@" elif [ -x '/usr/local/bin/dind' ]; then # if we have the (mostly defunct now) Docker-in-Docker wrapper script, use it set -- '/usr/local/bin/dind' "$@" diff --git a/29/windows/windowsservercore-ltsc2022/Dockerfile b/29/windows/windowsservercore-ltsc2022/Dockerfile new file mode 100644 index 000000000..40a3c6a8d --- /dev/null +++ b/29/windows/windowsservercore-ltsc2022/Dockerfile @@ -0,0 +1,95 @@ +# +# NOTE: THIS DOCKERFILE IS GENERATED VIA "apply-templates.sh" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# + +FROM mcr.microsoft.com/windows/servercore:ltsc2022 + +# $ProgressPreference: https://github.com/PowerShell/PowerShell/issues/2138#issuecomment-251261324 +SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"] + +# PATH isn't actually set in the Docker image, so we have to set it from within the container +RUN $newPath = ('{0}\docker;{1}' -f $env:ProgramFiles, $env:PATH); \ + Write-Host ('Updating PATH: {0}' -f $newPath); \ + [Environment]::SetEnvironmentVariable('PATH', $newPath, [EnvironmentVariableTarget]::Machine); +# doing this first to share cache across versions more aggressively + +ENV DOCKER_VERSION 29.10.0 +ENV DOCKER_URL https://download.docker.com/win/static/stable/x86_64/docker-29.10.0.zip +ENV DOCKER_SHA256 bb894f67d85155e635ce71980fb2cf587e71dad8c41cc145c42a0de5160b6561 + +RUN Write-Host ('Downloading {0} ...' -f $env:DOCKER_URL); \ + Invoke-WebRequest -Uri $env:DOCKER_URL -OutFile 'docker.zip'; \ + \ + Write-Host ('Verifying sha256 ({0}) ...' -f $env:DOCKER_SHA256); \ + if ((Get-FileHash docker.zip -Algorithm sha256).Hash -ne $env:DOCKER_SHA256) { \ + Write-Host 'FAILED!'; \ + exit 1; \ + }; \ + \ + Write-Host 'Expanding ...'; \ + Expand-Archive docker.zip -DestinationPath $env:ProgramFiles; \ +# (this archive has a "docker/..." directory in it already) + \ + Write-Host 'Removing ...'; \ + Remove-Item @( \ + 'docker.zip', \ + ('{0}\docker\dockerd.exe' -f $env:ProgramFiles) \ + ) -Force; \ + \ + Write-Host 'Verifying install ("docker --version") ...'; \ + docker --version; \ + \ + Write-Host 'Complete.'; + +# https://github.com/docker-library/docker/issues/409#issuecomment-1462868414 +ENV DOCKER_BUILDX_VERSION 0.39.1 +ENV DOCKER_BUILDX_URL https://github.com/docker/buildx/releases/download/v0.39.1/buildx-v0.39.1.windows-amd64.exe +ENV DOCKER_BUILDX_SHA256 4a665d2c71f6f87a42313cb8847b8e834e2dfb1626a1b57fcdbaacf41a6c8387 +RUN $dir = ('{0}\docker\cli-plugins' -f $env:ProgramFiles); \ + Write-Host ('Creating {0} ...' -f $dir); \ + New-Item -ItemType Directory $dir -Force; \ + \ + $plugin = ('{0}\docker-buildx.exe' -f $dir); \ + Write-Host ('Downloading {0} ...' -f $env:DOCKER_BUILDX_URL); \ + Invoke-WebRequest -Uri $env:DOCKER_BUILDX_URL -OutFile $plugin; \ + \ + Write-Host ('Verifying sha256 ({0}) ...' -f $env:DOCKER_BUILDX_SHA256); \ + if ((Get-FileHash $plugin -Algorithm sha256).Hash -ne $env:DOCKER_BUILDX_SHA256) { \ + Write-Host 'FAILED!'; \ + exit 1; \ + }; \ + \ + Write-Host 'Verifying install ("docker buildx version") ...'; \ + docker buildx version; \ + \ + Write-Host 'Complete.'; +ENV DOCKER_COMPOSE_VERSION 5.8.0 +ENV DOCKER_COMPOSE_URL https://github.com/docker/compose/releases/download/v5.8.0/docker-compose-windows-x86_64.exe +ENV DOCKER_COMPOSE_SHA256 0c2d9245a5f61e8e3cc85009b8b4888fa82fded08239d28bd6da5ca818eda2b2 +RUN $dir = ('{0}\docker\cli-plugins' -f $env:ProgramFiles); \ + Write-Host ('Creating {0} ...' -f $dir); \ + New-Item -ItemType Directory $dir -Force; \ + \ + $plugin = ('{0}\docker-compose.exe' -f $dir); \ + Write-Host ('Downloading {0} ...' -f $env:DOCKER_COMPOSE_URL); \ + Invoke-WebRequest -Uri $env:DOCKER_COMPOSE_URL -OutFile $plugin; \ + \ + Write-Host ('Verifying sha256 ({0}) ...' -f $env:DOCKER_COMPOSE_SHA256); \ + if ((Get-FileHash $plugin -Algorithm sha256).Hash -ne $env:DOCKER_COMPOSE_SHA256) { \ + Write-Host 'FAILED!'; \ + exit 1; \ + }; \ + \ + Write-Host 'Verifying install ("docker compose version") ...'; \ + docker compose version; \ + \ + $link = ('{0}\docker\docker-compose.exe' -f $env:ProgramFiles); \ + Write-Host ('Linking {0} to {1} ...' -f $plugin, $link); \ + New-Item -ItemType SymbolicLink -Path $link -Target $plugin; \ + \ + Write-Host 'Verifying install ("docker-compose --version") ...'; \ + docker-compose --version; \ + \ + Write-Host 'Complete.'; diff --git a/29/windows/windowsservercore-ltsc2025/Dockerfile b/29/windows/windowsservercore-ltsc2025/Dockerfile new file mode 100644 index 000000000..8ad30c73b --- /dev/null +++ b/29/windows/windowsservercore-ltsc2025/Dockerfile @@ -0,0 +1,95 @@ +# +# NOTE: THIS DOCKERFILE IS GENERATED VIA "apply-templates.sh" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# + +FROM mcr.microsoft.com/windows/servercore:ltsc2025 + +# $ProgressPreference: https://github.com/PowerShell/PowerShell/issues/2138#issuecomment-251261324 +SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"] + +# PATH isn't actually set in the Docker image, so we have to set it from within the container +RUN $newPath = ('{0}\docker;{1}' -f $env:ProgramFiles, $env:PATH); \ + Write-Host ('Updating PATH: {0}' -f $newPath); \ + [Environment]::SetEnvironmentVariable('PATH', $newPath, [EnvironmentVariableTarget]::Machine); +# doing this first to share cache across versions more aggressively + +ENV DOCKER_VERSION 29.10.0 +ENV DOCKER_URL https://download.docker.com/win/static/stable/x86_64/docker-29.10.0.zip +ENV DOCKER_SHA256 bb894f67d85155e635ce71980fb2cf587e71dad8c41cc145c42a0de5160b6561 + +RUN Write-Host ('Downloading {0} ...' -f $env:DOCKER_URL); \ + Invoke-WebRequest -Uri $env:DOCKER_URL -OutFile 'docker.zip'; \ + \ + Write-Host ('Verifying sha256 ({0}) ...' -f $env:DOCKER_SHA256); \ + if ((Get-FileHash docker.zip -Algorithm sha256).Hash -ne $env:DOCKER_SHA256) { \ + Write-Host 'FAILED!'; \ + exit 1; \ + }; \ + \ + Write-Host 'Expanding ...'; \ + Expand-Archive docker.zip -DestinationPath $env:ProgramFiles; \ +# (this archive has a "docker/..." directory in it already) + \ + Write-Host 'Removing ...'; \ + Remove-Item @( \ + 'docker.zip', \ + ('{0}\docker\dockerd.exe' -f $env:ProgramFiles) \ + ) -Force; \ + \ + Write-Host 'Verifying install ("docker --version") ...'; \ + docker --version; \ + \ + Write-Host 'Complete.'; + +# https://github.com/docker-library/docker/issues/409#issuecomment-1462868414 +ENV DOCKER_BUILDX_VERSION 0.39.1 +ENV DOCKER_BUILDX_URL https://github.com/docker/buildx/releases/download/v0.39.1/buildx-v0.39.1.windows-amd64.exe +ENV DOCKER_BUILDX_SHA256 4a665d2c71f6f87a42313cb8847b8e834e2dfb1626a1b57fcdbaacf41a6c8387 +RUN $dir = ('{0}\docker\cli-plugins' -f $env:ProgramFiles); \ + Write-Host ('Creating {0} ...' -f $dir); \ + New-Item -ItemType Directory $dir -Force; \ + \ + $plugin = ('{0}\docker-buildx.exe' -f $dir); \ + Write-Host ('Downloading {0} ...' -f $env:DOCKER_BUILDX_URL); \ + Invoke-WebRequest -Uri $env:DOCKER_BUILDX_URL -OutFile $plugin; \ + \ + Write-Host ('Verifying sha256 ({0}) ...' -f $env:DOCKER_BUILDX_SHA256); \ + if ((Get-FileHash $plugin -Algorithm sha256).Hash -ne $env:DOCKER_BUILDX_SHA256) { \ + Write-Host 'FAILED!'; \ + exit 1; \ + }; \ + \ + Write-Host 'Verifying install ("docker buildx version") ...'; \ + docker buildx version; \ + \ + Write-Host 'Complete.'; +ENV DOCKER_COMPOSE_VERSION 5.8.0 +ENV DOCKER_COMPOSE_URL https://github.com/docker/compose/releases/download/v5.8.0/docker-compose-windows-x86_64.exe +ENV DOCKER_COMPOSE_SHA256 0c2d9245a5f61e8e3cc85009b8b4888fa82fded08239d28bd6da5ca818eda2b2 +RUN $dir = ('{0}\docker\cli-plugins' -f $env:ProgramFiles); \ + Write-Host ('Creating {0} ...' -f $dir); \ + New-Item -ItemType Directory $dir -Force; \ + \ + $plugin = ('{0}\docker-compose.exe' -f $dir); \ + Write-Host ('Downloading {0} ...' -f $env:DOCKER_COMPOSE_URL); \ + Invoke-WebRequest -Uri $env:DOCKER_COMPOSE_URL -OutFile $plugin; \ + \ + Write-Host ('Verifying sha256 ({0}) ...' -f $env:DOCKER_COMPOSE_SHA256); \ + if ((Get-FileHash $plugin -Algorithm sha256).Hash -ne $env:DOCKER_COMPOSE_SHA256) { \ + Write-Host 'FAILED!'; \ + exit 1; \ + }; \ + \ + Write-Host 'Verifying install ("docker compose version") ...'; \ + docker compose version; \ + \ + $link = ('{0}\docker\docker-compose.exe' -f $env:ProgramFiles); \ + Write-Host ('Linking {0} to {1} ...' -f $plugin, $link); \ + New-Item -ItemType SymbolicLink -Path $link -Target $plugin; \ + \ + Write-Host 'Verifying install ("docker-compose --version") ...'; \ + docker-compose --version; \ + \ + Write-Host 'Complete.'; diff --git a/Dockerfile-cli.template b/Dockerfile-cli.template new file mode 100644 index 000000000..273ddf5af --- /dev/null +++ b/Dockerfile-cli.template @@ -0,0 +1,95 @@ +{{ include "shared" -}} +FROM alpine:3.24 + +RUN apk add --no-cache \ + ca-certificates \ +# DOCKER_HOST=ssh://... -- https://github.com/docker/cli/pull/1014 + openssh-client \ +# https://github.com/docker-library/docker/issues/482#issuecomment-2197116408 + git + +# ensure that nsswitch.conf is set up for Go's "netgo" implementation (which Docker explicitly uses) +# - https://github.com/moby/moby/blob/v24.0.6/hack/make.sh#L111 +# - https://github.com/golang/go/blob/go1.19.13/src/net/conf.go#L227-L303 +# - docker run --rm debian:stretch grep '^hosts:' /etc/nsswitch.conf +RUN [ -e /etc/nsswitch.conf ] && grep '^hosts: files dns' /etc/nsswitch.conf + +# pre-add a "docker" group for socket usage +RUN set -eux; \ + addgroup -g 2375 -S docker + +ENV DOCKER_VERSION {{ .version }} + +RUN set -eux; \ + \ + {{ + download({ + arches: .arches, + urlKey: "dockerUrl", + sha256Key: "dockerSha256", + target: "docker.tgz", + }) + }}; \ + \ + tar --extract \ + --file docker.tgz \ + --strip-components 1 \ + --directory /usr/local/bin/ \ + --no-same-owner \ + 'docker/docker' \ + ; \ + rm docker.tgz; \ + \ + docker --version +{{ + { + buildx: .buildx, + compose: .compose, + } + | to_entries | map( + .key as $key | .value | ( +-}} + +ENV DOCKER_{{ $key | ascii_upcase }}_VERSION {{ .version }} +RUN set -eux; \ + \ + {{ + download({ + arches: .arches, + urlKey: "url", + sha256Key: "sha256", + target: ("docker-" + $key), + missingArchWarning: true, + }) + }}; \ + \ + plugin='/usr/local/libexec/docker/cli-plugins/docker-{{ $key }}'; \ + mkdir -p "$(dirname "$plugin")"; \ + mv -vT {{ "docker-" + $key | @sh }} "$plugin"; \ + chmod +x "$plugin"; \ + \ +{{ if $key == "compose" then ( -}} + ln -sv "$plugin" /usr/local/bin/; \ + docker-{{ $key }} --version; \ +{{ ) else "" end -}} + docker {{ $key }} version +{{ + ) + ) + | add +-}} + +COPY modprobe.sh /usr/local/bin/modprobe +COPY docker-entrypoint.sh /usr/local/bin/ + +# https://github.com/docker-library/docker/pull/166 +# dockerd-entrypoint.sh uses DOCKER_TLS_CERTDIR for auto-generating TLS certificates +# docker-entrypoint.sh uses DOCKER_TLS_CERTDIR for auto-setting DOCKER_TLS_VERIFY and DOCKER_CERT_PATH +# (For this to work, at least the "client" subdirectory of this path needs to be shared between the client and server containers via a volume, "docker cp", or other means of data sharing.) +ENV DOCKER_TLS_CERTDIR=/certs +# also, ensure the directory pre-exists and has wide enough permissions for "dockerd-entrypoint.sh" to create subdirectories, even when run in "rootless" mode +RUN mkdir /certs /certs/client && chmod 1777 /certs /certs/client +# (doing both /certs and /certs/client so that if Docker does a "copy-up" into a volume defined on /certs/client, it will "do the right thing" by default in a way that still works for rootless users) + +ENTRYPOINT ["docker-entrypoint.sh"] +CMD ["sh"] diff --git a/Dockerfile-dind-rootless.template b/Dockerfile-dind-rootless.template index 6f30d8215..85ba8c6f0 100644 --- a/Dockerfile-dind-rootless.template +++ b/Dockerfile-dind-rootless.template @@ -1,8 +1,11 @@ -FROM docker:%%VERSION%%-dind +{{ include "shared" -}} +FROM docker:{{ env.version }}-dind # busybox "ip" is insufficient: # [rootlesskit:child ] error: executing [[ip tuntap add name tap0 mode tap] [ip link set tap0 address 02:50:00:00:00:01]]: exit status 1 -RUN apk add --no-cache iproute2 +# slirp4netns is recommended as rootlesskit's net driver +# https://github.com/rootless-containers/rootlesskit/blob/be156df0429551f5c23dc61dd07201b33076ff1d/docs/network.md#--netslirp4netns-recommended +RUN apk add --no-cache iproute2 fuse-overlayfs slirp4netns # "/run/user/UID" will be used by default as the value of XDG_RUNTIME_DIR RUN mkdir /run/user && chmod 1777 /run/user @@ -15,43 +18,23 @@ RUN set -eux; \ RUN set -eux; \ \ -# this "case" statement is generated via "update.sh" - %%ARCH-CASE%%; \ - \ - if ! wget -O rootless.tgz "https://download.docker.com/linux/static/${DOCKER_CHANNEL}/${dockerArch}/docker-rootless-extras-${DOCKER_VERSION}.tgz"; then \ - echo >&2 "error: failed to download 'docker-rootless-extras-${DOCKER_VERSION}' from '${DOCKER_CHANNEL}' for '${dockerArch}'"; \ - exit 1; \ - fi; \ + {{ + download({ + arches: .arches, + urlKey: "rootlessExtrasUrl", + sha256Key: "rootlessExtrasSha256", + target: "rootless.tgz", + }) + }}; \ \ tar --extract \ --file rootless.tgz \ --strip-components 1 \ --directory /usr/local/bin/ \ - 'docker-rootless-extras/vpnkit' \ + 'docker-rootless-extras/rootlesskit' \ ; \ rm rootless.tgz; \ \ -# we download/build rootlesskit separately to get a newer release -# rootlesskit --version; \ - vpnkit --version - -# https://github.com/rootless-containers/rootlesskit/releases -ENV ROOTLESSKIT_VERSION 0.9.1 - -RUN set -eux; \ - apk add --no-cache --virtual .rootlesskit-build-deps \ - go \ - libc-dev \ - ; \ - wget -O rootlesskit.tgz "https://github.com/rootless-containers/rootlesskit/archive/v${ROOTLESSKIT_VERSION}.tar.gz"; \ - export GOPATH='/go'; mkdir "$GOPATH"; \ - mkdir -p "$GOPATH/src/github.com/rootless-containers/rootlesskit"; \ - tar --extract --file rootlesskit.tgz --directory "$GOPATH/src/github.com/rootless-containers/rootlesskit" --strip-components 1; \ - rm rootlesskit.tgz; \ - go build -o /usr/local/bin/rootlesskit github.com/rootless-containers/rootlesskit/cmd/rootlesskit; \ - go build -o /usr/local/bin/rootlesskit-docker-proxy github.com/rootless-containers/rootlesskit/cmd/rootlesskit-docker-proxy; \ - rm -rf "$GOPATH"; \ - apk del --no-network .rootlesskit-build-deps; \ rootlesskit --version # pre-create "/var/lib/docker" for our rootless user diff --git a/Dockerfile-dind.template b/Dockerfile-dind.template index 04f2d31bc..3c9459358 100644 --- a/Dockerfile-dind.template +++ b/Dockerfile-dind.template @@ -1,40 +1,88 @@ -FROM docker:%%VERSION%% +{{ include "shared" -}} +FROM docker:{{ env.version }}-cli -# https://github.com/docker/docker/blob/master/project/PACKAGERS.md#runtime-dependencies +# Runtime dependencies: +# - https://github.com/moby/moby/blob/864598f8c2677189e308eb4a3b3c0dd41fc06599/project/PACKAGERS.md#runtime-dependencies#runtime-dependencies +# - https://github.com/docker/packaging/blob/0ba325d178593583f190dc91566214a85c3880ad/pkg/docker-engine/deb/control#L24-L36 RUN set -eux; \ apk add --no-cache \ - btrfs-progs \ - e2fsprogs \ - e2fsprogs-extra \ + ip6tables \ iptables \ openssl \ + pigz \ shadow-uidmap \ - xfsprogs \ xz \ -# pigz: https://github.com/moby/moby/pull/35697 (faster gzip implementation) - pigz \ - ; \ -# only install zfs if it's available for the current architecture -# https://git.alpinelinux.org/cgit/aports/tree/main/zfs/APKBUILD?h=3.6-stable#n9 ("all !armhf !ppc64le" as of 2017-11-01) -# "apk info XYZ" exits with a zero exit code but no output when the package exists but not for this arch - if zfs="$(apk info --no-cache --quiet zfs)" && [ -n "$zfs" ]; then \ - apk add --no-cache zfs; \ - fi + ; -# TODO aufs-tools +# dind might be used on systems where the nf_tables kernel module isn't available. In that case, +# we need to switch over to xtables-legacy. See https://github.com/docker-library/docker/issues/463 +RUN set -eux; \ + apk add --no-cache iptables-legacy; \ +# set up a symlink farm we can use PATH to switch to legacy with + mkdir -p /usr/local/sbin/.iptables-legacy; \ +# https://gitlab.alpinelinux.org/alpine/aports/-/blob/a7e1610a67a46fc52668528efe01cee621c2ba6c/main/iptables/APKBUILD#L77 + for f in \ + iptables \ + iptables-save \ + iptables-restore \ + ip6tables \ + ip6tables-save \ + ip6tables-restore \ + ; do \ +# "iptables-save" -> "iptables-legacy-save", "ip6tables" -> "ip6tables-legacy", etc. +# https://pkgs.alpinelinux.org/contents?branch=v3.24&name=iptables-legacy&arch=x86_64 + b="$(command -v "${f/tables/tables-legacy}")"; \ + "$b" --version; \ + ln -svT "$b" "/usr/local/sbin/.iptables-legacy/$f"; \ + done; \ +# verify it works (and gets us legacy) + export PATH="/usr/local/sbin/.iptables-legacy:$PATH"; \ + iptables --version | grep legacy # set up subuid/subgid so that "--userns-remap=default" works out-of-the-box -RUN set -x \ - && addgroup -S dockremap \ - && adduser -S -G dockremap dockremap \ - && echo 'dockremap:165536:65536' >> /etc/subuid \ - && echo 'dockremap:165536:65536' >> /etc/subgid +RUN set -eux; \ + addgroup -S dockremap; \ + adduser -S -G dockremap dockremap; \ + echo 'dockremap:165536:65536' >> /etc/subuid; \ + echo 'dockremap:165536:65536' >> /etc/subgid + +RUN set -eux; \ + \ + {{ + download({ + arches: .arches, + urlKey: "dockerUrl", + sha256Key: "dockerSha256", + target: "docker.tgz", + }) + }}; \ + \ + tar --extract \ + --file docker.tgz \ + --strip-components 1 \ + --directory /usr/local/bin/ \ + --no-same-owner \ +# we exclude the CLI binary because we already extracted that over in the "docker:{{ env.version }}-cli" image that we're FROM and we don't want to duplicate those bytes again in this layer + --exclude 'docker/docker' \ +{{ if .version == "29.8.2" then "" else ( -}} +# exclude containerd, relying on the "embedded containerd" instead: https://github.com/moby/moby/pull/53388 (makes for a smaller image) + --exclude 'docker/containerd' \ +{{ ) end -}} + ; \ + rm docker.tgz; \ + \ + dockerd --version; \ +{{ if .version == "29.8.2" then ( -}} + containerd --version; \ +{{ ) else "" end -}} + ctr --version; \ + runc --version -# https://github.com/docker/docker/tree/master/hack/dind -ENV DIND_COMMIT %%DIND-COMMIT%% +# https://github.com/moby/moby/tree/master/hack/dind +ENV DIND_COMMIT {{ .dindCommit }} RUN set -eux; \ - wget -O /usr/local/bin/dind "https://raw.githubusercontent.com/docker/docker/${DIND_COMMIT}/hack/dind"; \ + wget -O /usr/local/bin/dind "https://raw.githubusercontent.com/moby/moby/${DIND_COMMIT}/hack/dind"; \ chmod +x /usr/local/bin/dind COPY dockerd-entrypoint.sh /usr/local/bin/ diff --git a/Dockerfile-git.template b/Dockerfile-git.template deleted file mode 100644 index 1c5647123..000000000 --- a/Dockerfile-git.template +++ /dev/null @@ -1,3 +0,0 @@ -FROM docker:%%VERSION%% - -RUN apk add --no-cache git diff --git a/Dockerfile-windows-servercore.template b/Dockerfile-windows-servercore.template new file mode 100644 index 000000000..d7969968d --- /dev/null +++ b/Dockerfile-windows-servercore.template @@ -0,0 +1,92 @@ +FROM mcr.microsoft.com/windows/{{ env.windowsVariant }}:{{ env.windowsRelease }} + +# $ProgressPreference: https://github.com/PowerShell/PowerShell/issues/2138#issuecomment-251261324 +SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"] + +# PATH isn't actually set in the Docker image, so we have to set it from within the container +RUN $newPath = ('{0}\docker;{1}' -f $env:ProgramFiles, $env:PATH); \ + Write-Host ('Updating PATH: {0}' -f $newPath); \ + [Environment]::SetEnvironmentVariable('PATH', $newPath, [EnvironmentVariableTarget]::Machine); +# doing this first to share cache across versions more aggressively + +ENV DOCKER_VERSION {{ .version }} +ENV DOCKER_URL {{ .arches["windows-amd64"].dockerUrl }} +{{ if .arches["windows-amd64"].dockerSha256 then ( -}} +ENV DOCKER_SHA256 {{ .arches["windows-amd64"].dockerSha256 }} +{{ ) else ( -}} +{{ # TODO remove this whole else block! as of 29.10.0-rc.1, we have checksums 🥳 -}} +# TODO ENV DOCKER_SHA256 +# https://github.com/docker/docker-ce/blob/5b073ee2cf564edee5adca05eee574142f7627bb/components/packaging/static/hash_files !! +# (no SHA file artifacts on download.docker.com yet as of 2017-06-07 though) +{{ ) end -}} + +RUN Write-Host ('Downloading {0} ...' -f $env:DOCKER_URL); \ + Invoke-WebRequest -Uri $env:DOCKER_URL -OutFile 'docker.zip'; \ + \ +{{ if .arches["windows-amd64"].dockerSha256 then ( -}} + Write-Host ('Verifying sha256 ({0}) ...' -f $env:DOCKER_SHA256); \ + if ((Get-FileHash docker.zip -Algorithm sha256).Hash -ne $env:DOCKER_SHA256) { \ + Write-Host 'FAILED!'; \ + exit 1; \ + }; \ + \ +{{ ) else "" end -}} + Write-Host 'Expanding ...'; \ + Expand-Archive docker.zip -DestinationPath $env:ProgramFiles; \ +# (this archive has a "docker/..." directory in it already) + \ + Write-Host 'Removing ...'; \ + Remove-Item @( \ + 'docker.zip', \ + ('{0}\docker\dockerd.exe' -f $env:ProgramFiles) \ + ) -Force; \ + \ + Write-Host 'Verifying install ("docker --version") ...'; \ + docker --version; \ + \ + Write-Host 'Complete.'; + +# https://github.com/docker-library/docker/issues/409#issuecomment-1462868414 +{{ + { + buildx: .buildx, + compose: .compose, + } + | to_entries | map( + .key as $key | ($key | ascii_upcase) as $KEY | .value | ( +-}} +ENV DOCKER_{{ $KEY }}_VERSION {{ .version }} +ENV DOCKER_{{ $KEY }}_URL {{ .arches["windows-amd64"].url }} +ENV DOCKER_{{ $KEY }}_SHA256 {{ .arches["windows-amd64"].sha256 }} +RUN $dir = ('{0}\docker\cli-plugins' -f $env:ProgramFiles); \ + Write-Host ('Creating {0} ...' -f $dir); \ + New-Item -ItemType Directory $dir -Force; \ + \ + $plugin = ('{0}\docker-{{ $key }}.exe' -f $dir); \ + Write-Host ('Downloading {0} ...' -f $env:DOCKER_{{ $KEY }}_URL); \ + Invoke-WebRequest -Uri $env:DOCKER_{{ $KEY }}_URL -OutFile $plugin; \ + \ + Write-Host ('Verifying sha256 ({0}) ...' -f $env:DOCKER_{{ $KEY }}_SHA256); \ + if ((Get-FileHash $plugin -Algorithm sha256).Hash -ne $env:DOCKER_{{ $KEY }}_SHA256) { \ + Write-Host 'FAILED!'; \ + exit 1; \ + }; \ + \ + Write-Host 'Verifying install ("docker {{ $key }} version") ...'; \ + docker {{ $key }} version; \ +{{ if $key == "compose" then ( -}} + \ + $link = ('{0}\docker\docker-{{ $key }}.exe' -f $env:ProgramFiles); \ + Write-Host ('Linking {0} to {1} ...' -f $plugin, $link); \ + New-Item -ItemType SymbolicLink -Path $link -Target $plugin; \ + \ + Write-Host 'Verifying install ("docker-{{ $key }} --version") ...'; \ + docker-{{ $key }} --version; \ +{{ ) else "" end -}} + \ + Write-Host 'Complete.'; +{{ + ) + ) + | add +-}} diff --git a/Dockerfile-windows-windowsservercore.template b/Dockerfile-windows-windowsservercore.template deleted file mode 100644 index 89ad458cb..000000000 --- a/Dockerfile-windows-windowsservercore.template +++ /dev/null @@ -1,35 +0,0 @@ -FROM microsoft/windowsservercore:%%TAG%% - -# $ProgressPreference: https://github.com/PowerShell/PowerShell/issues/2138#issuecomment-251261324 -SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"] - -# PATH isn't actually set in the Docker image, so we have to set it from within the container -RUN $newPath = ('{0}\docker;{1}' -f $env:ProgramFiles, $env:PATH); \ - Write-Host ('Updating PATH: {0}' -f $newPath); \ - [Environment]::SetEnvironmentVariable('PATH', $newPath, [EnvironmentVariableTarget]::Machine); -# doing this first to share cache across versions more aggressively - -ENV DOCKER_CHANNEL %%DOCKER-CHANNEL%% -ENV DOCKER_VERSION %%DOCKER-VERSION%% -# TODO ENV DOCKER_SHA256 -# https://github.com/docker/docker-ce/blob/5b073ee2cf564edee5adca05eee574142f7627bb/components/packaging/static/hash_files !! -# (no SHA file artifacts on download.docker.com yet as of 2017-06-07 though) - -RUN $url = ('https://download.docker.com/win/static/{0}/x86_64/docker-{1}.zip' -f $env:DOCKER_CHANNEL, $env:DOCKER_VERSION); \ - Write-Host ('Downloading {0} ...' -f $url); \ - Invoke-WebRequest -Uri $url -OutFile 'docker.zip'; \ - \ - Write-Host 'Expanding ...'; \ - Expand-Archive docker.zip -DestinationPath $env:ProgramFiles; \ -# (this archive has a "docker/..." directory in it already) - \ - Write-Host 'Removing ...'; \ - Remove-Item @( \ - 'docker.zip', \ - ('{0}\docker\dockerd.exe' -f $env:ProgramFiles) \ - ) -Force; \ - \ - Write-Host 'Verifying install ("docker --version") ...'; \ - docker --version; \ - \ - Write-Host 'Complete.'; diff --git a/Dockerfile.template b/Dockerfile.template deleted file mode 100644 index 002a4c708..000000000 --- a/Dockerfile.template +++ /dev/null @@ -1,53 +0,0 @@ -FROM alpine:%%TAG%% - -RUN apk add --no-cache \ - ca-certificates \ -# DOCKER_HOST=ssh://... -- https://github.com/docker/cli/pull/1014 - openssh-client - -# set up nsswitch.conf for Go's "netgo" implementation (which Docker explicitly uses) -# - https://github.com/docker/docker-ce/blob/v17.09.0-ce/components/engine/hack/make.sh#L149 -# - https://github.com/golang/go/blob/go1.9.1/src/net/conf.go#L194-L275 -# - docker run --rm debian:stretch grep '^hosts:' /etc/nsswitch.conf -RUN [ ! -e /etc/nsswitch.conf ] && echo 'hosts: files dns' > /etc/nsswitch.conf - -ENV DOCKER_CHANNEL %%DOCKER-CHANNEL%% -ENV DOCKER_VERSION %%DOCKER-VERSION%% -# TODO ENV DOCKER_SHA256 -# https://github.com/docker/docker-ce/blob/5b073ee2cf564edee5adca05eee574142f7627bb/components/packaging/static/hash_files !! -# (no SHA file artifacts on download.docker.com yet as of 2017-06-07 though) - -RUN set -eux; \ - \ -# this "case" statement is generated via "update.sh" - %%ARCH-CASE%%; \ - \ - if ! wget -O docker.tgz "https://download.docker.com/linux/static/${DOCKER_CHANNEL}/${dockerArch}/docker-${DOCKER_VERSION}.tgz"; then \ - echo >&2 "error: failed to download 'docker-${DOCKER_VERSION}' from '${DOCKER_CHANNEL}' for '${dockerArch}'"; \ - exit 1; \ - fi; \ - \ - tar --extract \ - --file docker.tgz \ - --strip-components 1 \ - --directory /usr/local/bin/ \ - ; \ - rm docker.tgz; \ - \ - dockerd --version; \ - docker --version - -COPY modprobe.sh /usr/local/bin/modprobe -COPY docker-entrypoint.sh /usr/local/bin/ - -# https://github.com/docker-library/docker/pull/166 -# dockerd-entrypoint.sh uses DOCKER_TLS_CERTDIR for auto-generating TLS certificates -# docker-entrypoint.sh uses DOCKER_TLS_CERTDIR for auto-setting DOCKER_TLS_VERIFY and DOCKER_CERT_PATH -# (For this to work, at least the "client" subdirectory of this path needs to be shared between the client and server containers via a volume, "docker cp", or other means of data sharing.) -ENV DOCKER_TLS_CERTDIR=/certs -# also, ensure the directory pre-exists and has wide enough permissions for "dockerd-entrypoint.sh" to create subdirectories, even when run in "rootless" mode -RUN mkdir /certs /certs/client && chmod 1777 /certs /certs/client -# (doing both /certs and /certs/client so that if Docker does a "copy-up" into a volume defined on /certs/client, it will "do the right thing" by default in a way that still works for rootless users) - -ENTRYPOINT ["docker-entrypoint.sh"] -CMD ["sh"] diff --git a/README.md b/README.md index bfd2d4ab4..bcd2f83db 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ ## Maintained by: [Tianon (of the Docker Project)](https://github.com/docker-library/docker) -This is the Git repo of the [Docker "Official Image"](https://github.com/docker-library/official-images#what-are-official-images) for [`docker`](https://hub.docker.com/_/docker/) (not to be confused with any official `docker` image provided by `docker` upstream). See [the Docker Hub page](https://hub.docker.com/_/docker/) for the full readme on how to use this Docker image and for information regarding contributing and issues. +This is the Git repo of the [Docker "Official Image"](https://github.com/docker-library/official-images#what-are-official-images) for [`docker`](https://hub.docker.com/_/docker/). See [the Docker Hub page](https://hub.docker.com/_/docker/) for the full readme on how to use this Docker image and for information regarding contributing and issues. The [full image description on Docker Hub](https://hub.docker.com/_/docker/) is generated/maintained over in [the docker-library/docs repository](https://github.com/docker-library/docs), specifically in [the `docker` directory](https://github.com/docker-library/docs/tree/master/docker). @@ -12,15 +12,4 @@ For more information about the full official images change lifecycle, see [the " For outstanding `docker` image PRs, check [PRs with the "library/docker" label on the official-images repository](https://github.com/docker-library/official-images/labels/library%2Fdocker). For the current "source of truth" for [`docker`](https://hub.docker.com/_/docker/), see [the `library/docker` file in the official-images repository](https://github.com/docker-library/official-images/blob/master/library/docker). ---- - -- [![build status badge](https://img.shields.io/travis/docker-library/docker/master.svg?label=Travis%20CI)](https://travis-ci.org/docker-library/docker/branches) -- [![build status badge](https://img.shields.io/appveyor/ci/docker-library/docker/master.svg?label=AppVeyor)](https://ci.appveyor.com/project/docker-library/docker) -- [![build status badge](https://img.shields.io/jenkins/s/https/doi-janky.infosiftr.net/job/update.sh/job/docker.svg?label=Automated%20update.sh)](https://doi-janky.infosiftr.net/job/update.sh/job/docker) - -| Build | Status | Badges | (per-arch) | -|:-:|:-:|:-:|:-:| -| [![amd64 build status badge](https://img.shields.io/jenkins/s/https/doi-janky.infosiftr.net/job/multiarch/job/amd64/job/docker.svg?label=amd64)](https://doi-janky.infosiftr.net/job/multiarch/job/amd64/job/docker) | [![arm32v6 build status badge](https://img.shields.io/jenkins/s/https/doi-janky.infosiftr.net/job/multiarch/job/arm32v6/job/docker.svg?label=arm32v6)](https://doi-janky.infosiftr.net/job/multiarch/job/arm32v6/job/docker) | [![arm32v7 build status badge](https://img.shields.io/jenkins/s/https/doi-janky.infosiftr.net/job/multiarch/job/arm32v7/job/docker.svg?label=arm32v7)](https://doi-janky.infosiftr.net/job/multiarch/job/arm32v7/job/docker) | [![arm64v8 build status badge](https://img.shields.io/jenkins/s/https/doi-janky.infosiftr.net/job/multiarch/job/arm64v8/job/docker.svg?label=arm64v8)](https://doi-janky.infosiftr.net/job/multiarch/job/arm64v8/job/docker) | -| [![put-shared build status badge](https://img.shields.io/jenkins/s/https/doi-janky.infosiftr.net/job/put-shared/job/light/job/docker.svg?label=put-shared)](https://doi-janky.infosiftr.net/job/put-shared/job/light/job/docker) | - diff --git a/apply-templates.sh b/apply-templates.sh new file mode 100755 index 000000000..f11612fb5 --- /dev/null +++ b/apply-templates.sh @@ -0,0 +1,73 @@ +#!/usr/bin/env bash +set -Eeuo pipefail + +[ -f versions.json ] # run "versions.sh" first + +jqt='.jq-template.awk' +if [ -n "${BASHBREW_SCRIPTS:-}" ]; then + jqt="$BASHBREW_SCRIPTS/jq-template.awk" +elif [ "$BASH_SOURCE" -nt "$jqt" ]; then + # https://github.com/docker-library/bashbrew/blob/master/scripts/jq-template.awk + wget -qO "$jqt" 'https://github.com/docker-library/bashbrew/raw/9f6a35772ac863a0241f147c820354e4008edf38/scripts/jq-template.awk' +fi + +if [ "$#" -eq 0 ]; then + versions="$(jq -r 'keys | map(@sh) | join(" ")' versions.json)" + eval "set -- $versions" +fi + +generated_warning() { + cat <<-EOH + # + # NOTE: THIS DOCKERFILE IS GENERATED VIA "apply-templates.sh" + # + # PLEASE DO NOT EDIT IT DIRECTLY. + # + + EOH +} + +for version; do + export version + + if jq -e '.[env.version] | not' versions.json > /dev/null; then + echo "deleting $version ..." + rm -rf "$version" + continue + fi + + rm -rf "$version" + + variants="$(jq -r '.[env.version].variants | map(@sh) | join(" ")' versions.json)" + eval "variants=( $variants )" + + for variant in "${variants[@]}"; do + dir="$version/$variant" + + case "$variant" in + windows/*) + variant="$(basename "$variant")" # "windowsservercore-1809", etc + windowsVariant="${variant%%-*}" # "windowsservercore", "nanoserver" + windowsRelease="${variant#$windowsVariant-}" # "ltsc2022", "1809", etc + windowsVariant="${windowsVariant#windows}" # "servercore", "nanoserver" + export windowsVariant windowsRelease + template="Dockerfile-windows-$windowsVariant.template" + ;; + + *) + template="Dockerfile-$variant.template" + ;; + esac + + echo "processing $dir ..." + + mkdir -p "$dir" + { + generated_warning + gawk -f "$jqt" "$template" + } > "$dir/Dockerfile" + done + + cp -a docker-entrypoint.sh modprobe.sh "$version/cli/" + cp -a dockerd-entrypoint.sh "$version/dind/" +done diff --git a/dockerd-entrypoint.sh b/dockerd-entrypoint.sh index 42aab58a8..130883d69 100755 --- a/dockerd-entrypoint.sh +++ b/dockerd-entrypoint.sh @@ -21,11 +21,17 @@ _tls_san() { _tls_generate_certs() { local dir="$1"; shift + # if server/{ca,key,cert}.pem && !ca/key.pem, do NOTHING except verify (user likely managing CA themselves) # if ca/key.pem || !ca/cert.pem, generate CA public if necessary # if ca/key.pem, generate server public # if ca/key.pem, generate client public # (regenerating public certs every startup to account for SAN/IP changes and/or expiration) + if [ -s "$dir/server/ca.pem" ] && [ -s "$dir/server/cert.pem" ] && [ -s "$dir/server/key.pem" ] && [ ! -s "$dir/ca/key.pem" ]; then + openssl verify -CAfile "$dir/server/ca.pem" "$dir/server/cert.pem" + return 0 + fi + # https://github.com/FiloSottile/mkcert/issues/174 local certValidDays='825' @@ -35,7 +41,10 @@ _tls_generate_certs() { _tls_ensure_private "$dir/ca/key.pem" openssl req -new -key "$dir/ca/key.pem" \ -out "$dir/ca/cert.pem" \ - -subj '/CN=docker:dind CA' -x509 -days "$certValidDays" + -subj '/CN=docker:dind CA' \ + -x509 \ + -days "$certValidDays" \ + -addext keyUsage=critical,digitalSignature,keyCertSign fi if [ -s "$dir/ca/key.pem" ]; then @@ -47,6 +56,7 @@ _tls_generate_certs() { -subj '/CN=docker:dind server' cat > "$dir/server/openssl.cnf" <<-EOF [ x509_exts ] + extendedKeyUsage = serverAuth subjectAltName = $(_tls_san) EOF openssl x509 -req \ @@ -108,12 +118,8 @@ if [ "$#" -eq 0 ] || [ "${1#-}" != "$1" ]; then esac # add our default arguments - if [ -n "${DOCKER_TLS_CERTDIR:-}" ] \ - && _tls_generate_certs "$DOCKER_TLS_CERTDIR" \ - && [ -s "$DOCKER_TLS_CERTDIR/server/ca.pem" ] \ - && [ -s "$DOCKER_TLS_CERTDIR/server/cert.pem" ] \ - && [ -s "$DOCKER_TLS_CERTDIR/server/key.pem" ] \ - ; then + if [ -n "${DOCKER_TLS_CERTDIR:-}" ]; then + _tls_generate_certs "$DOCKER_TLS_CERTDIR" # generate certs and use TLS if requested/possible (default in 19.03+) set -- dockerd \ --host="$dockerSocket" \ @@ -138,6 +144,52 @@ if [ "$1" = 'dockerd' ]; then # explicitly remove Docker's default PID file to ensure that it can start properly if it was stopped uncleanly (and thus didn't clean up the PID file) find /run /var/run -iname 'docker*.pid' -delete || : + # XXX inject "docker-init" (tini) as pid1 to workaround https://github.com/docker-library/docker/issues/318 (zombie container-shim processes) + set -- docker-init -- "$@" + + iptablesLegacy= + if [ -n "${DOCKER_IPTABLES_LEGACY+x}" ]; then + # let users choose explicitly to legacy or not to legacy + iptablesLegacy="$DOCKER_IPTABLES_LEGACY" + if [ -n "$iptablesLegacy" ]; then + modprobe ip_tables || : + modprobe ip6_tables || : + else + modprobe nf_tables || : + fi + elif ( + # https://git.netfilter.org/iptables/tree/iptables/nft-shared.c?id=f5cf76626d95d2c491a80288bccc160c53b44e88#n420 + # https://github.com/docker-library/docker/pull/468#discussion_r1442131459 + for f in /proc/net/ip_tables_names /proc/net/ip6_tables_names /proc/net/arp_tables_names; do + if [ -r "$f" ] && b="$(cat "$f")" && [ -n "$b" ]; then + exit 0 + fi + done + exit 1 + ); then + # if we already have any "legacy" iptables rules, we should always use legacy + iptablesLegacy=1 + elif ! iptables -nL > /dev/null 2>&1; then + # if iptables fails to run, chances are high the necessary kernel modules aren't loaded (perhaps the host is using xtables, for example) + # https://github.com/docker-library/docker/issues/350 + # https://github.com/moby/moby/issues/26824 + # https://github.com/docker-library/docker/pull/437#issuecomment-1854900620 + modprobe nf_tables || : + if ! iptables -nL > /dev/null 2>&1; then + # might be host has no nf_tables, but Alpine is all-in now (so let's try a legacy fallback) + modprobe ip_tables || : + modprobe ip6_tables || : + if /usr/local/sbin/.iptables-legacy/iptables -nL > /dev/null 2>&1; then + iptablesLegacy=1 + fi + fi + fi + if [ -n "$iptablesLegacy" ]; then + # see https://github.com/docker-library/docker/issues/463 (and the dind Dockerfile where this directory is set up) + export PATH="/usr/local/sbin/.iptables-legacy:$PATH" + fi + iptables --version # so users can see whether it's legacy or not + uid="$(id -u)" if [ "$uid" != '0' ]; then # if we're not root, we must be trying to run rootless @@ -166,14 +218,14 @@ if [ "$1" = 'dockerd' ]; then fi # TODO overlay support detection? exec rootlesskit \ - --net="${DOCKERD_ROOTLESS_ROOTLESSKIT_NET:-vpnkit}" \ + --net="${DOCKERD_ROOTLESS_ROOTLESSKIT_NET:-slirp4netns}" \ --mtu="${DOCKERD_ROOTLESS_ROOTLESSKIT_MTU:-1500}" \ --disable-host-loopback \ --port-driver=builtin \ --copy-up=/etc \ --copy-up=/run \ ${DOCKERD_ROOTLESS_ROOTLESSKIT_FLAGS:-} \ - "$@" --userland-proxy-path=rootlesskit-docker-proxy + "$@" elif [ -x '/usr/local/bin/dind' ]; then # if we have the (mostly defunct now) Docker-in-Docker wrapper script, use it set -- '/usr/local/bin/dind' "$@" diff --git a/generate-stackbrew-library.sh b/generate-stackbrew-library.sh index dde99337c..920da3058 100755 --- a/generate-stackbrew-library.sh +++ b/generate-stackbrew-library.sh @@ -1,44 +1,20 @@ -#!/bin/bash -set -eu - -declare -A aliases=( - #[18.06]='edge' -) - -# used for auto-detecting the "latest" of each channel (for tagging it appropriately) -# https://blog.docker.com/2017/03/docker-enterprise-edition/ -declare -A latestChannelRelease=() +#!/usr/bin/env bash +set -Eeuo pipefail self="$(basename "$BASH_SOURCE")" cd "$(dirname "$(readlink -f "$BASH_SOURCE")")" -source '.architectures-lib' - -parentArches() { - local version="$1"; shift # "17.06", etc - - local parent="$(awk 'toupper($1) == "FROM" { print $2 }' "$version/Dockerfile")" - echo "${parentRepoToArches[$parent]:-}" -} -versionArches() { - local version="$1"; shift - - local parentArches="$(parentArches "$version")" - - local versionArches=() - for arch in $parentArches; do - if hasBashbrewArch "$arch" && grep -qE "^# $arch\$" "$version/Dockerfile"; then - versionArches+=( "$arch" ) - fi - done - echo "${versionArches[*]}" -} - -versions=( */ ) -versions=( "${versions[@]%/}" ) - -# sort version numbers with highest first -IFS=$'\n'; versions=( $(echo "${versions[*]}" | sort -rV) ); unset IFS +if [ "$#" -eq 0 ]; then + versions="$(jq -r ' + to_entries + # sort version numbers with highest first + | sort_by(.key | split("[.-]"; "") | map(try tonumber // .)) + | reverse + | map(if .value then .key | @sh else empty end) + | join(" ") + ' versions.json)" + eval "set -- $versions" +fi # get the most recent commit which modified any of "$@" fileCommit() { @@ -62,12 +38,63 @@ dirCommit() { ) } +getArches() { + local repo="$1"; shift + local officialImagesBase="${BASHBREW_LIBRARY:-https://github.com/docker-library/official-images/raw/HEAD/library}/" + + local parentRepoToArchesStr + parentRepoToArchesStr="$( + find -name 'Dockerfile' -exec awk -v officialImagesBase="$officialImagesBase" ' + toupper($1) == "FROM" && $2 !~ /^('"$repo"'|scratch|.*\/.*)(:|$)/ { + printf "%s%s\n", officialImagesBase, $2 + } + ' '{}' + \ + | sort -u \ + | xargs -r bashbrew cat --format '["{{ .RepoName }}:{{ .TagName }}"]="{{ join " " .TagEntry.Architectures }}"' + )" + eval "declare -g -A parentRepoToArches=( $parentRepoToArchesStr )" +} +getArches 'docker' + +versionArches() { + local version="$1"; shift + local variant="${1:-}" + local selector='dockerUrl' + if [[ "$variant" = *rootless ]]; then + selector='rootlessExtrasUrl' + fi + + if [[ "$variant" = windows/* ]]; then + version="$version" jq -r ' + .[env.version].arches + | keys[] + | select(startswith("windows-")) + ' versions.json | sort + return + fi + + local parent parentArches + parent="$(awk 'toupper($1) == "FROM" { print $2 }' "$version/cli/Dockerfile")" + parentArches="${parentRepoToArches[$parent]:-}" + + comm -12 \ + <( + version="$version" jq -r --arg selector "$selector" ' + .[env.version].arches | to_entries[] + | select(.value[$selector]) + | .key + ' versions.json | sort + ) \ + <(xargs -n1 <<<"$parentArches" | sort) +} + cat <<-EOH # this file is generated via https://github.com/docker-library/docker/blob/$(fileCommit "$self")/$self Maintainers: Tianon Gravi (@tianon), Joseph Ferguson (@yosifkit) GitRepo: https://github.com/docker-library/docker.git +Builder: buildkit EOH # prints "$2$1$3$1...$N" @@ -77,21 +104,17 @@ join() { echo "${out#$sep}" } -for version in "${versions[@]}"; do - rcVersion="${version%-rc}" - - commit="$(dirCommit "$version")" +# used for auto-detecting the "latest" of each channel (for tagging it appropriately) +# https://blog.docker.com/2017/03/docker-enterprise-edition/ +declare -A latestChannelRelease=() - fullVersion="$(git show "$commit":"$version/Dockerfile" | awk '$1 == "ENV" && $2 == "DOCKER_VERSION" { print $3; exit }')" +for version; do + export version + rcVersion="${version%-rc}" - if [ "$rcVersion" != "$version" ] && [ -e "$rcVersion/Dockerfile" ]; then - # if this is a "-rc" release, let's make sure the release it contains isn't already GA (and thus something we should not publish anymore) - rcFullVersion="$(git show HEAD:"$rcVersion/Dockerfile" | awk '$1 == "ENV" && $2 == "DOCKER_VERSION" { print $3; exit }')" - latestVersion="$({ echo "$fullVersion"; echo "$rcFullVersion"; } | sort -V | tail -1)" - if [[ "$fullVersion" == "$rcFullVersion"* ]] || [ "$latestVersion" = "$rcFullVersion" ]; then - # "x.y.z-rc1" == x.y.z* - continue - fi + if ! fullVersion="$(jq -er '.[env.version] | if . then .version else empty end' versions.json)"; then + # support running "generate-stackbrew-library.sh" on a singular "null" version ("20.10-rc" when the RC is older than the GA release, for example) + continue fi versionAliases=() @@ -103,12 +126,13 @@ for version in "${versions[@]}"; do else versionAliases+=( $fullVersion ) fi - versionAliases+=( - $version - ) + if [ "$fullVersion" != "$version" ]; then + versionAliases+=( + $version + ) + fi # add a few channel/version-related aliases - channel="$(versionChannel "$version")" majorVersion="${version%%.*}" if [ "$version" != "$rcVersion" ] && [ -z "${latestChannelRelease['rc']:-}" ]; then versionAliases+=( 'rc' ) @@ -118,16 +142,13 @@ for version in "${versions[@]}"; do versionAliases+=( "$majorVersion" ) latestChannelRelease["$majorVersion"]="$version" fi - versionAliases+=( - ${aliases[$version]:-} - ) - if [ -z "${latestChannelRelease[$channel]:-}" ]; then - versionAliases+=( "$channel" ) - latestChannelRelease[$channel]="$version" + + channel='stable' + if [ "$rcVersion" != "$version" ]; then + channel='test' fi # every release goes into the "test" channel, so the biggest numbered release wins (RC or not) if [ -z "${latestChannelRelease['test']:-}" ]; then - versionAliases+=( 'test' ) latestChannelRelease['test']="$version" fi if [ "$version" = "$rcVersion" ] && [ -z "${latestChannelRelease['latest']:-}" ]; then @@ -135,40 +156,37 @@ for version in "${versions[@]}"; do latestChannelRelease['latest']="$version" fi - versionArches="$(versionArches "$version")" - - echo - cat <<-EOE - Tags: $(join ', ' "${versionAliases[@]}") - Architectures: $(join ', ' $versionArches) - GitCommit: $commit - Directory: $version - EOE + variants="$(jq -r '.[env.version].variants | map(@sh) | join(" ")' versions.json)" + eval "variants=( $variants )" - for v in \ - dind dind-rootless git \ - windows/windowsservercore-{ltsc2016,1709} \ - ; do + for v in "${variants[@]}"; do dir="$version/$v" [ -f "$dir/Dockerfile" ] || continue - variant="$(basename "$v")" commit="$(dirCommit "$dir")" + variant="$(basename "$v")" variantAliases=( "${versionAliases[@]/%/-$variant}" ) variantAliases=( "${variantAliases[@]//latest-/}" ) - case "$v" in - # https://github.com/docker/docker-ce/blob/8fb3bb7b2210789a4471c017561c1b0de0b4f145/components/engine/hack/make/binary-daemon#L24 - # "vpnkit is amd64-only" ... for now?? - dind-rootless) variantArches='amd64' ;; - - windows/*) variantArches='windows-amd64' ;; - *) variantArches="$versionArches" ;; - esac + if [ "$variant" = 'cli' ] || [ "$variant" = 'dind' ]; then + parent="$(awk 'toupper($1) == "FROM" { print $2 }' "$version/cli/Dockerfile")" + alpine="${parent#*:}" # "3.14" + suiteAliases=( "${variantAliases[0]}" ) # only "X.Y.Z-foo" + suiteAliases=( "${suiteAliases[@]/%/-alpine$alpine}" ) + suiteAliases=( "${suiteAliases[@]//latest-/}" ) + variantAliases+=( "${suiteAliases[@]}" ) + if [ "$variant" = 'dind' ]; then + # add "latest" aliases + suiteAliases=( "${versionAliases[0]}" ) # only "X.Y.Z-foo" + suiteAliases=( "${suiteAliases[@]/%/-alpine$alpine}" ) + suiteAliases=( "${suiteAliases[@]//latest-/}" ) + variantAliases+=( "${versionAliases[@]}" "${suiteAliases[@]}" ) + fi + fi sharedTags=() - if [[ "$variant" == 'windowsservercore'* ]]; then + if [[ "$variant" == windowsservercore* ]]; then sharedTags=( "${versionAliases[@]/%/-windowsservercore}" ) sharedTags=( "${sharedTags[@]//latest-/}" ) fi @@ -179,10 +197,13 @@ for version in "${versions[@]}"; do echo "SharedTags: $(join ', ' "${sharedTags[@]}")" fi cat <<-EOE - Architectures: $(join ', ' $variantArches) + Architectures: $(join ', ' $(versionArches "$version" "$v")) GitCommit: $commit Directory: $dir EOE - [ "$variant" = "$v" ] || echo "Constraints: $variant" + if [ "$variant" != "$v" ]; then + echo "Constraints: $variant" + echo 'Builder: classic' # no Windows support in BuildKit (yet) + fi done done diff --git a/release-architectures b/release-architectures deleted file mode 100644 index 1271c0eb9..000000000 --- a/release-architectures +++ /dev/null @@ -1,9 +0,0 @@ -# see subdirectories of https://download.docker.com/linux/static/ - -# bashbrew-arch apk-arch docker-release-arch -amd64 x86_64 x86_64 -arm32v6 armhf armel -arm32v7 armv7 armhf -arm64v8 aarch64 aarch64 -ppc64le ppc64le ppc64le -s390x s390x s390x diff --git a/shared.jq b/shared.jq new file mode 100644 index 000000000..ed950bbb3 --- /dev/null +++ b/shared.jq @@ -0,0 +1,67 @@ +# converts a bashbrew architecture to apk's strings +def apkArch: + { + # https://dl-cdn.alpinelinux.org/alpine/edge/main/ + # https://wiki.alpinelinux.org/wiki/Architecture#Alpine_Hardware_Architecture_.28.22arch.22.29_Support + # https://pkgs.alpinelinux.org/packages ("Arch" dropdown) + amd64: "x86_64", + arm32v6: "armhf", + arm32v7: "armv7", + arm64v8: "aarch64", + i386: "x86", + ppc64le: "ppc64le", + riscv64: "riscv64", + s390x: "s390x", + }[.] + ; + +# RUN set -eux; \ +# ... +# {{ +# download({ +# arches: .arches, +# urlKey: "dockerUrl", +# #sha256Key: "sha256", +# target: "docker.tgz", +# #missingArchWarning: true, +# }) +# }}; \ +# ... +def download(opts): + (opts.sha256Key | not) as $notSha256 + | [ + "apkArch=\"$(apk --print-arch)\"; + case \"$apkArch\" in" + , + ( + opts.arches | to_entries[] + | .key as $bashbrewArch + | ($bashbrewArch | apkArch) as $apkArch + | .value + | .[opts.urlKey] as $url + | (if $notSha256 then "none" else .[opts.sha256Key] end) as $sha256 + | select($apkArch and $url) + | (" + \($apkArch | @sh)) + url=\($url | @sh);" + + if $notSha256 or ($sha256 == null) then "" else " + sha256=\($sha256 | @sh);" + end + " + ;;" + ) + ) + , + " + *) echo >&2 \"\(if opts.missingArchWarning then "warning" else "error" end): unsupported \(opts.target | @sh) architecture ($apkArch)\(if opts.missingArchWarning then "; skipping" else "" end)\"; exit \(if opts.missingArchWarning then 0 else 1 end) ;; + esac; + + wget -O \(opts.target | @sh) \"$url\";" + , + if opts.sha256Key and all(opts.arches[]; has(opts.sha256Key)) then " + echo \"$sha256 *\"\(opts.target | @sh) | sha256sum -c -;" + else "" end + ] | add + | rtrimstr(";") + | gsub("(?<=[^[:space:]])\n"; " \\\n") + | gsub("(?<=[[:space:]])\n"; "\\\n") + ; diff --git a/update.sh b/update.sh index 756d6bc43..214077c0f 100755 --- a/update.sh +++ b/update.sh @@ -1,162 +1,7 @@ -#!/bin/bash +#!/usr/bin/env bash set -eo pipefail -defaultAlpineVersion='3.11' -declare -A alpineVersion=( - #[17.09]='3.6' -) - cd "$(dirname "$(readlink -f "$BASH_SOURCE")")" -source '.architectures-lib' - -versions=( "$@" ) -if [ ${#versions[@]} -eq 0 ]; then - versions=( */ ) -fi -versions=( "${versions[@]%/}" ) - -# see http://stackoverflow.com/a/2705678/433558 -sed_escape_lhs() { - echo "$@" | sed -e 's/[]\/$*.^|[]/\\&/g' -} -sed_escape_rhs() { - echo "$@" | sed -e 's/[\/&]/\\&/g' | sed -e ':a;N;$!ba;s/\n/\\n/g' -} - -# "tac|tac" for http://stackoverflow.com/a/28879552/433558 -dindLatest="$(curl -fsSL 'https://github.com/docker/docker/commits/master/hack/dind.atom' | tac|tac | awk -F '[[:space:]]*[<>/]+' '$2 == "id" && $3 ~ /Commit/ { print $4; exit }')" - -dockerVersions="$( - git ls-remote --tags https://github.com/docker/docker-ce.git \ - | cut -d$'\t' -f2 \ - | grep '^refs/tags/v[0-9].*$' \ - | sed 's!^refs/tags/v!!; s!\^{}$!!' \ - | sort -u \ - | gawk ' - { data[lines++] = $0 } - - # "beta" sorts lower than "tp" even though "beta" is a more preferred release, so we need to explicitly adjust the sorting order for RCs - # also, "18.09.0-ce-beta1" vs "18.09.0-beta3" - function docker_version_compare(i1, v1, i2, v2, l, r) { - l = v1; gsub(/-ce/, "", l); gsub(/-tp/, "-alpha", l) - r = v2; gsub(/-ce/, "", r); gsub(/-tp/, "-alpha", r) - patsplit(l, ltemp, /[^.-]+/) - patsplit(r, rtemp, /[^.-]+/) - for (i = 0; i < length(ltemp) && i < length(rtemp); ++i) { - if (ltemp[i] < rtemp[i]) { - return -1 - } - if (ltemp[i] > rtemp[i]) { - return 1 - } - } - return 0 - } - - END { - asort(data, result, "docker_version_compare") - for (i in result) { - print result[i] - } - } - ' -)" - -travisEnv= -appveyorEnv= -for version in "${versions[@]}"; do - rcVersion="${version%-rc}" - - versionOptions="$(grep "^$rcVersion[.]" <<<"$dockerVersions")" - - rcGrepV='-v' - if [ "$rcVersion" != "$version" ]; then - rcGrepV= - fi - - fullVersion="$(grep $rcGrepV -E -- '-(rc|tp|beta)' <<<"$versionOptions" | tail -1)" - if [ -z "$fullVersion" ]; then - echo >&2 "warning: cannot find full version for $version" - continue - fi - - channel="$(versionChannel "$version")" - - echo "$version: $fullVersion ($channel)" - - archCase='apkArch="$(apk --print-arch)"; '$'\\\n' - archCase+=$'\t''case "$apkArch" in '$'\\\n' - for apkArch in $(apkArches); do - dockerArch="$(apkToDockerArch "$apkArch")" - # check whether the given architecture is supported for this release - if wget --quiet --spider "https://download.docker.com/linux/static/$channel/$dockerArch/docker-$fullVersion.tgz" &> /dev/null; then - bashbrewArch="$(apkToBashbrewArch "$apkArch")" - archCase+="# $bashbrewArch"$'\n' - archCase+=$'\t\t'"$apkArch) dockerArch='$dockerArch' ;; "$'\\\n' - fi - done - archCase+=$'\t\t''*) echo >&2 "error: unsupported architecture ($apkArch)"; exit 1 ;;'$'\\\n' - archCase+=$'\t''esac' - - alpine="${alpineVersion[$version]:-$defaultAlpineVersion}" - - majorVersion="${fullVersion%%.*}" - minorVersion="${fullVersion#$majorVersion.}" - minorVersion="${minorVersion%%.*}" - minorVersion="${minorVersion#0}" - - for variant in \ - '' git dind dind-rootless \ - windows/windowsservercore-{1709,ltsc2016} \ - ; do - dir="$version${variant:+/$variant}" - [ -d "$dir" ] || continue - df="$dir/Dockerfile" - slash='/' - case "$variant" in - windows/windowsservercore*) tag="${variant#*-}"; template='Dockerfile-windows-windowsservercore.template' ;; - *) tag="$alpine"; template="Dockerfile${variant:+-${variant//$slash/-}}.template" ;; - esac - sed -r \ - -e 's!%%VERSION%%!'"$version"'!g' \ - -e 's!%%DOCKER-CHANNEL%%!'"$channel"'!g' \ - -e 's!%%DOCKER-VERSION%%!'"$fullVersion"'!g' \ - -e 's!%%TAG%%!'"$tag"'!g' \ - -e 's!%%DIND-COMMIT%%!'"$dindLatest"'!g' \ - -e 's!%%ARCH-CASE%%!'"$(sed_escape_rhs "$archCase")"'!g' \ - "$template" > "$df" - - # DOCKER_TLS_CERTDIR is only enabled-by-default in 19.03+ - if [ "$majorVersion" -lt 19 ]; then - sed -ri -e 's!^(ENV DOCKER_TLS_CERTDIR=).*$!\1!' "$df" - fi - - # pigz (https://github.com/moby/moby/pull/35697) is only 18.02+ - if [ "$majorVersion" -lt 18 ] || { [ "$majorVersion" -eq 18 ] && [ "$minorVersion" -lt 2 ]; }; then - sed -ri '/pigz/d' "$df" - fi - - if [[ "$variant" == windows/* ]]; then - winVariant="$(basename "$variant")" - - case "$winVariant" in - *-1709) ;; # no AppVeyor support for 1709 yet: https://github.com/appveyor/ci/issues/1885 - *) appveyorEnv='\n - version: '"$version"'\n variant: '"$winVariant$appveyorEnv" ;; - esac - fi - done - - cp -a docker-entrypoint.sh modprobe.sh "$version/" - cp -a dockerd-entrypoint.sh "$version/dind/" - - travisEnv='\n - VERSION='"$version$travisEnv" -done - -travis="$(awk -v 'RS=\n\n' '$1 == "env:" { $0 = "env:'"$travisEnv"'" } { printf "%s%s", $0, RS }' .travis.yml)" -echo "$travis" > .travis.yml - -if [ -f .appveyor.yml ]; then - appveyor="$(awk -v 'RS=\n\n' '$1 == "environment:" { $0 = "environment:\n matrix:'"$appveyorEnv"'" } { printf "%s%s", $0, RS }' .appveyor.yml)" - echo "$appveyor" > .appveyor.yml -fi +./versions.sh "$@" +./apply-templates.sh "$@" diff --git a/versions.json b/versions.json new file mode 100644 index 000000000..e97e8e7b1 --- /dev/null +++ b/versions.json @@ -0,0 +1,198 @@ +{ + "29": { + "arches": { + "amd64": { + "dockerSha256": "7c1ebadc65c716cdc6d35fc78759ed0e4317debf43c21dd12f066f2006999def", + "dockerUrl": "https://download.docker.com/linux/static/stable/x86_64/docker-29.10.0.tgz", + "rootlessExtrasSha256": "a4ad65be3921ac3e45f3fe69893f5edbd078cb3b4a6499fe13288053553dce25", + "rootlessExtrasUrl": "https://download.docker.com/linux/static/stable/x86_64/docker-rootless-extras-29.10.0.tgz" + }, + "arm32v6": { + "dockerSha256": "b3e626f7560728eb601687da86c27edf9b7dd71f6a0f00737baeeb607c0f1d68", + "dockerUrl": "https://download.docker.com/linux/static/stable/armel/docker-29.10.0.tgz" + }, + "arm32v7": { + "dockerSha256": "08757af1f923c25d170211a1de8acc4e69e9cfbe7b5af63dd787afe2057efd5f", + "dockerUrl": "https://download.docker.com/linux/static/stable/armhf/docker-29.10.0.tgz" + }, + "arm64v8": { + "dockerSha256": "6e5159e8b5615e0c0c2954a2a1a2a12bc65f5d9b603595dba24a10cb367408cd", + "dockerUrl": "https://download.docker.com/linux/static/stable/aarch64/docker-29.10.0.tgz", + "rootlessExtrasSha256": "6d08caae6a61e58f86c21dc94bcbf87f2b7a82bb634ef051243004a7f92f9e07", + "rootlessExtrasUrl": "https://download.docker.com/linux/static/stable/aarch64/docker-rootless-extras-29.10.0.tgz" + }, + "ppc64le": { + "dockerSha256": "f07fe44072d1614de38effa6492f840653dfbf9e5a7d3a0a1dab4c2dad257190", + "dockerUrl": "https://download.docker.com/linux/static/stable/ppc64le/docker-29.10.0.tgz" + }, + "s390x": { + "dockerSha256": "09c4a2ec475121fe9c1485c65e9f54f1fa20aa4d68d0c4b271005db3943a763b", + "dockerUrl": "https://download.docker.com/linux/static/stable/s390x/docker-29.10.0.tgz" + }, + "windows-amd64": { + "dockerSha256": "bb894f67d85155e635ce71980fb2cf587e71dad8c41cc145c42a0de5160b6561", + "dockerUrl": "https://download.docker.com/win/static/stable/x86_64/docker-29.10.0.zip" + } + }, + "buildx": { + "arches": { + "amd64": { + "file": "buildx-v0.39.1.linux-amd64", + "sha256": "903090816da68f8bc1a2ff5346dd163a5adacfce4548d003c75df42cd47a9bf4", + "url": "https://github.com/docker/buildx/releases/download/v0.39.1/buildx-v0.39.1.linux-amd64" + }, + "arm32v6": { + "file": "buildx-v0.39.1.linux-arm-v6", + "sha256": "3675402568ec1a5b96792d6bde9ebdafb9d29e9681b7ff747e97d54c2198a735", + "url": "https://github.com/docker/buildx/releases/download/v0.39.1/buildx-v0.39.1.linux-arm-v6" + }, + "arm32v7": { + "file": "buildx-v0.39.1.linux-arm-v7", + "sha256": "e6c51234507ef11ea661a8f714412a5eb9abeba586da73dca82ad89410f03b13", + "url": "https://github.com/docker/buildx/releases/download/v0.39.1/buildx-v0.39.1.linux-arm-v7" + }, + "arm64v8": { + "file": "buildx-v0.39.1.linux-arm64", + "sha256": "05c88e0f9152825e609a1cdb391faf14d5f94d23d071eaecb87bae69d98da8b8", + "url": "https://github.com/docker/buildx/releases/download/v0.39.1/buildx-v0.39.1.linux-arm64" + }, + "darwin-amd64": { + "file": "buildx-v0.39.1.darwin-amd64", + "sha256": "52f6c18ba57d1d103aaaecd9c38087af124909c83aa8aa66fd6f130fc6c0619d", + "url": "https://github.com/docker/buildx/releases/download/v0.39.1/buildx-v0.39.1.darwin-amd64" + }, + "darwin-arm64v8": { + "file": "buildx-v0.39.1.darwin-arm64", + "sha256": "7a7f10602f0826d36b046e8db012b4cbfaa4ba56f9d2a5d374fe5bb7ae864fc4", + "url": "https://github.com/docker/buildx/releases/download/v0.39.1/buildx-v0.39.1.darwin-arm64" + }, + "freebsd-amd64": { + "file": "buildx-v0.39.1.freebsd-amd64", + "sha256": "26d13a39bac3a67a223c2a96cb6a929eadecfac3e6daff150d0ce22bc767e38c", + "url": "https://github.com/docker/buildx/releases/download/v0.39.1/buildx-v0.39.1.freebsd-amd64" + }, + "freebsd-arm64v8": { + "file": "buildx-v0.39.1.freebsd-arm64", + "sha256": "80136c0fc9200fbc460ecd236b76f4e647616012eb8770e5f57aaa95702a54d8", + "url": "https://github.com/docker/buildx/releases/download/v0.39.1/buildx-v0.39.1.freebsd-arm64" + }, + "netbsd-amd64": { + "file": "buildx-v0.39.1.netbsd-amd64", + "sha256": "b2b5907e8b4c902dc9df95c85857f668463fca06088e56f49dcac0df9cb3362c", + "url": "https://github.com/docker/buildx/releases/download/v0.39.1/buildx-v0.39.1.netbsd-amd64" + }, + "netbsd-arm64v8": { + "file": "buildx-v0.39.1.netbsd-arm64", + "sha256": "97af1f8a64faf5834452025ebdc07302bc0b1961ff3552d2b4ae170f3b90d55b", + "url": "https://github.com/docker/buildx/releases/download/v0.39.1/buildx-v0.39.1.netbsd-arm64" + }, + "openbsd-amd64": { + "file": "buildx-v0.39.1.openbsd-amd64", + "sha256": "378aa8d382ba764e8c2597afd6f742b9ca386c96c5a3d219e648ef67b466a894", + "url": "https://github.com/docker/buildx/releases/download/v0.39.1/buildx-v0.39.1.openbsd-amd64" + }, + "openbsd-arm64v8": { + "file": "buildx-v0.39.1.openbsd-arm64", + "sha256": "fa4c1ed66f5f21843ab23778c34101a693436be7a39a08673ad896e4c7792b9e", + "url": "https://github.com/docker/buildx/releases/download/v0.39.1/buildx-v0.39.1.openbsd-arm64" + }, + "ppc64le": { + "file": "buildx-v0.39.1.linux-ppc64le", + "sha256": "69713727c669ca87660c2197a5b97389cbad189120ee405f801986e8459ef83b", + "url": "https://github.com/docker/buildx/releases/download/v0.39.1/buildx-v0.39.1.linux-ppc64le" + }, + "riscv64": { + "file": "buildx-v0.39.1.linux-riscv64", + "sha256": "b0af9b8cf5e8e244ea4049b4ca897c77a0b8b0d78c1b1cd7b8324d451de71ed8", + "url": "https://github.com/docker/buildx/releases/download/v0.39.1/buildx-v0.39.1.linux-riscv64" + }, + "s390x": { + "file": "buildx-v0.39.1.linux-s390x", + "sha256": "f611aa33cd5290ad1e2ca6d5357a06123541643698d729392d05a20d527e526e", + "url": "https://github.com/docker/buildx/releases/download/v0.39.1/buildx-v0.39.1.linux-s390x" + }, + "windows-amd64": { + "file": "buildx-v0.39.1.windows-amd64.exe", + "sha256": "4a665d2c71f6f87a42313cb8847b8e834e2dfb1626a1b57fcdbaacf41a6c8387", + "url": "https://github.com/docker/buildx/releases/download/v0.39.1/buildx-v0.39.1.windows-amd64.exe" + }, + "windows-arm64v8": { + "file": "buildx-v0.39.1.windows-arm64.exe", + "sha256": "2edf4093a6eefc56c140a00b781c332e0654591e5952d7f13a8dd8353a9a57e1", + "url": "https://github.com/docker/buildx/releases/download/v0.39.1/buildx-v0.39.1.windows-arm64.exe" + } + }, + "version": "0.39.1" + }, + "compose": { + "arches": { + "amd64": { + "file": "docker-compose-linux-x86_64", + "sha256": "b8840f5008c447f41fce0a57ae3adeab42c89b1eb6e6012524bcabbfb4ffbaf6", + "url": "https://github.com/docker/compose/releases/download/v5.8.0/docker-compose-linux-x86_64" + }, + "arm32v6": { + "file": "docker-compose-linux-armv6", + "sha256": "c88658466ae9a4dadae64e6a4ec125202212bd460934537bd482bcd5e313f57b", + "url": "https://github.com/docker/compose/releases/download/v5.8.0/docker-compose-linux-armv6" + }, + "arm32v7": { + "file": "docker-compose-linux-armv7", + "sha256": "a7a79755648b975b66df08b4bfbe12b29f113d5dd8c7cd5b6b53b69efff2f422", + "url": "https://github.com/docker/compose/releases/download/v5.8.0/docker-compose-linux-armv7" + }, + "arm64v8": { + "file": "docker-compose-linux-aarch64", + "sha256": "1a9c918b2fb49b9c87f0018c64b5abd0d30715155e98dc939779fbaee6c414d3", + "url": "https://github.com/docker/compose/releases/download/v5.8.0/docker-compose-linux-aarch64" + }, + "darwin-amd64": { + "file": "docker-compose-darwin-x86_64", + "sha256": "5c41cd573c549dc66abb03c5b29d6d4dfaae206b2e79848d1c32482bb2a3b416", + "url": "https://github.com/docker/compose/releases/download/v5.8.0/docker-compose-darwin-x86_64" + }, + "darwin-arm64v8": { + "file": "docker-compose-darwin-aarch64", + "sha256": "008b8fcf6c6d60340f5796626a0f0d51c042085793a9b1653343011727140b71", + "url": "https://github.com/docker/compose/releases/download/v5.8.0/docker-compose-darwin-aarch64" + }, + "ppc64le": { + "file": "docker-compose-linux-ppc64le", + "sha256": "921437ba1fe9b5f7e3146c74c4d6c56673881741561c71bc23106b1e45886b1d", + "url": "https://github.com/docker/compose/releases/download/v5.8.0/docker-compose-linux-ppc64le" + }, + "riscv64": { + "file": "docker-compose-linux-riscv64", + "sha256": "0af052a262dcf3a28214c7c86442046fc5e50b698e838d1904395d7a5333b142", + "url": "https://github.com/docker/compose/releases/download/v5.8.0/docker-compose-linux-riscv64" + }, + "s390x": { + "file": "docker-compose-linux-s390x", + "sha256": "444af1a82eb51edd4a2aa5b1a209724f2acd19644e488fbd8c1dc8fd7d477f97", + "url": "https://github.com/docker/compose/releases/download/v5.8.0/docker-compose-linux-s390x" + }, + "windows-amd64": { + "file": "docker-compose-windows-x86_64.exe", + "sha256": "0c2d9245a5f61e8e3cc85009b8b4888fa82fded08239d28bd6da5ca818eda2b2", + "url": "https://github.com/docker/compose/releases/download/v5.8.0/docker-compose-windows-x86_64.exe" + }, + "windows-arm64v8": { + "file": "docker-compose-windows-aarch64.exe", + "sha256": "ec7a100a77d9aedbaa6e2b13a10140729860b58b8d2b6855d8191c52e7dd50fc", + "url": "https://github.com/docker/compose/releases/download/v5.8.0/docker-compose-windows-aarch64.exe" + } + }, + "version": "5.8.0" + }, + "dindCommit": "8d9e3502aba39127e4d12196dae16d306f76993d", + "variants": [ + "cli", + "dind", + "dind-rootless", + "windows/windowsservercore-ltsc2025", + "windows/windowsservercore-ltsc2022" + ], + "version": "29.10.0" + }, + "29-rc": null +} diff --git a/versions.sh b/versions.sh new file mode 100755 index 000000000..0ef1ea359 --- /dev/null +++ b/versions.sh @@ -0,0 +1,310 @@ +#!/usr/bin/env bash +set -Eeuo pipefail + +# bashbrew arch to docker-release-arch +declare -A dockerArches=( + ['amd64']='x86_64' + ['arm32v6']='armel' + ['arm32v7']='armhf' + ['arm64v8']='aarch64' + ['ppc64le']='ppc64le' + ['riscv64']='riscv64' + ['s390x']='s390x' + ['windows-amd64']='x86_64' +) + +cd "$(dirname "$(readlink -f "$BASH_SOURCE")")" + +versions=( "$@" ) +if [ ${#versions[@]} -eq 0 ]; then + versions=( */ ) + json='{}' +else + json="$(< versions.json)" +fi +versions=( "${versions[@]%/}" ) + +scriptPid="$$" # so we can kill the script even from a subshell +_curl() { + exec 42>&1 + local code + code="$(curl --silent --location -o /dev/fd/42 --write-out '%{http_code}' "$@")" + case "$code" in + 200) return 0 ;; + 404) return 1 ;; + esac + echo >&2 "error: unexpected status code $code while fetching: $*" + kill "$scriptPid" + exit 1 +} + +dindLatest="$( + _curl -H 'Accept: application/json' 'https://github.com/moby/moby/commits/master/hack/dind.atom' \ + | jq -r '.payload | first(.. | .commits?[]?.oid)' +)" + +dockerVersions="$( + git ls-remote --tags https://github.com/moby/moby.git \ + | jq --raw-input --null-input --raw-output ' + [ inputs | capture("refs/tags/(docker-)?v(?[0-9.a-z-]+)($|\\^)") | .version ] + | unique_by( split(".") | map(tonumber? // .) ) + | reverse[] + ' +)" + +buildxVersions="$( + git ls-remote --tags https://github.com/docker/buildx.git \ + | jq --raw-input --null-input --raw-output ' + [ inputs | capture("refs/tags/v(?[0-9.]+)($|\\^)") | .version ] + | unique_by( split(".") | map(tonumber? // .) ) + | reverse[] + ' +)" +buildx= +buildxVersion= +for buildxVersion in $buildxVersions; do + # checksums.txt -> linux + *bsd checksums + # checksums-signed.txt -> windows + darwin checksums (see also https://github.com/docker/buildx/pull/3978) + # fail if one is missing + if \ + checksums="$(_curl "https://github.com/docker/buildx/releases/download/v${buildxVersion}/checksums.txt")" \ + && checksums+=$'\n' \ + && checksums+="$(_curl "https://github.com/docker/buildx/releases/download/v${buildxVersion}/checksums-signed.txt")" \ + ; then + buildx="$(jq <<<"$checksums" -csR --arg version "$buildxVersion" ' + rtrimstr("\n") | split("\n") + | map( + split(" [ *]?"; "") + | { + sha256: .[0], + file: .[1], + url: ("https://github.com/docker/buildx/releases/download/v" + $version + "/" + .[1]), + } + | select(.file | test("[.]json$") | not) + | { ( + .file + | capture("[.](?linux|windows|darwin|[a-z0-9]*bsd)-(?[^.]+)(?[.]exe)?$") + // error("failed to parse os-arch from filename: " + .) + | if .os == "linux" then "" else .os + "-" end + + ({ + "amd64": "amd64", + "arm-v6": "arm32v6", + "arm-v7": "arm32v7", + "arm64": "arm64v8", + "ppc64le": "ppc64le", + "riscv64": "riscv64", + "s390x": "s390x", + }[.arch] // error("unknown buildx architecture: " + .arch)) + ): . } + ) + | add + | { + version: $version, + arches: ., + } + ')" + break + fi +done +if [ -z "$buildx" ]; then + echo >&2 'error: failed to determine buildx version!' + exit 1 +fi + +composeVersions="$( + git ls-remote --tags https://github.com/docker/compose.git \ + | jq --raw-input --null-input --raw-output ' + [ inputs | capture("refs/tags/v(?[0-9.]+)($|\\^)") | .version ] + | unique_by( split(".") | map(tonumber? // .) ) + | reverse[] + ' +)" +compose= +composeVersion= +for composeVersion in $composeVersions; do + if checksums="$(_curl "https://github.com/docker/compose/releases/download/v${composeVersion}/checksums.txt")"; then + compose="$(jq <<<"$checksums" -csR --arg version "$composeVersion" ' + rtrimstr("\n") | split("\n") + | map( + split(" *") + | { + sha256: .[0], + file: .[1], + url: ("https://github.com/docker/compose/releases/download/v" + $version + "/" + .[1]), + } + | select(.file | test("[.]json$") | not) + | { ( + .file + | capture("-(?linux|windows|darwin|freebsd|openbsd)-(?[^.]+)(?[.]exe)?$") + // error("failed to parse os-arch from filename: " + .) + | if .os == "linux" then "" else .os + "-" end + + ({ + aarch64: "arm64v8", + armv6: "arm32v6", + armv7: "arm32v7", + ppc64le: "ppc64le", + riscv64: "riscv64", + s390x: "s390x", + x86_64: "amd64", + }[.arch] // error("unknown compose architecture: " + .arch)) + ): . } + ) + | add + | { + version: $version, + arches: ., + } + ')" + break + fi +done +if [ -z "$compose" ]; then + echo >&2 'error: failed to determine compose version!' + exit 1 +fi + +for version in "${versions[@]}"; do + rcVersion="${version%-rc}" + export version rcVersion + channel='stable' + + versionOptions="$(grep "^$rcVersion[.]" <<<"$dockerVersions")" + + rcGrepV='-v' + if [ "$rcVersion" != "$version" ]; then + rcGrepV= + channel='test' + fi + + if ! fullVersion="$(grep $rcGrepV -E -- '-(rc|tp|beta)' <<<"$versionOptions" | head -1)" || [ -z "$fullVersion" ]; then + if currentNull="$(jq -r '.[env.version] == null' versions.json)" && [ "$currentNull" = 'true' ]; then + echo >&2 "warning: skipping '$version' (does not appear to be released yet)" + json="$(jq <<<"$json" -c '.[env.version] = null')" + continue + fi + echo >&2 "error: cannot find full version for $version" + exit 1 + fi + + # if this is a "-rc" release, let's make sure the release it contains isn't already GA (and thus something we should not publish anymore) + if [ "$rcVersion" != "$version" ] && rcFullVersion="$(jq <<<"$json" -r '.[env.rcVersion].version // ""')" && [ -n "$rcFullVersion" ]; then + latestVersion="$({ echo "$fullVersion"; echo "$rcFullVersion"; } | sort -V | tail -1)" + if [[ "$fullVersion" == "$rcFullVersion"* ]] || [ "$latestVersion" = "$rcFullVersion" ]; then + # "x.y.z-rc1" == x.y.z* + echo >&2 "warning: skipping/removing '$version' ('$rcVersion' is at '$rcFullVersion' which is newer than '$fullVersion')" + json="$(jq <<<"$json" -c '.[env.version] = null')" + continue + fi + fi + + echo "$version: $fullVersion (buildx $buildxVersion, compose $composeVersion)" + + export fullVersion dindLatest + doc="$( + jq -nc --argjson buildx "$buildx" --argjson compose "$compose" '{ + version: env.fullVersion, + arches: {}, + dindCommit: env.dindLatest, + buildx: $buildx, + compose: $compose, + }' + )" + + declare -A hasArches=() + for bashbrewArch in "${!dockerArches[@]}"; do + arch="${dockerArches[$bashbrewArch]}" + # check whether the given architecture is supported for this release + case "$bashbrewArch" in + windows-*) url="https://download.docker.com/win/static/$channel/$arch/docker-$fullVersion.zip"; windows=1 ;; + *) url="https://download.docker.com/linux/static/$channel/$arch/docker-$fullVersion.tgz"; windows= ;; + esac + if _curl --head "$url" > /dev/null; then + export bashbrewArch url + doc="$( + jq <<<"$doc" -c '.arches[env.bashbrewArch] = { + dockerUrl: env.url, + }' + )" + else + continue + fi + if sha256="$(_curl "$url.sha256")"; then + sha256="${sha256%% *}" + if [[ ! "$sha256" =~ ^[[:xdigit:]]{64}$ ]]; then + echo >&2 "error: invalid checksum for $url: '$sha256'" + exit 1 + fi + + export sha256 + doc="$(jq <<<"$doc" -c ' + .arches[env.bashbrewArch].dockerSha256 = env.sha256 + ')" + fi + hasArches["$bashbrewArch"]=1 + + if [ -n "$windows" ]; then + continue # Windows doesn't have rootless extras :) + fi + + # https://github.com/moby/moby/blob/v20.10.7/hack/make/binary-daemon#L24 + # "vpnkit is available for x86_64 and aarch64" + case "$bashbrewArch" in + amd64 | arm64v8) + rootlessExtrasUrl="https://download.docker.com/linux/static/$channel/$arch/docker-rootless-extras-$fullVersion.tgz" + if _curl --head "$rootlessExtrasUrl" > /dev/null; then + if rootlessExtrasSha256="$(_curl "$rootlessExtrasUrl.sha256")"; then + rootlessExtrasSha256="${rootlessExtrasSha256%% *}" + if [[ ! "$rootlessExtrasSha256" =~ ^[[:xdigit:]]{64}$ ]]; then + echo >&2 "error: invalid checksum for $rootlessExtrasUrl: '$rootlessExtrasSha256'" + exit 1 + fi + else + rootlessExtrasSha256= + fi + + export rootlessExtrasUrl rootlessExtrasSha256 + doc="$(jq <<<"$doc" -c ' + .arches[env.bashbrewArch] |= ( + .rootlessExtrasUrl = env.rootlessExtrasUrl + | if env.rootlessExtrasSha256 != "" then + .rootlessExtrasSha256 = env.rootlessExtrasSha256 + end + ) + ')" + fi + ;; + esac + done + + for alwaysExpectedArch in amd64 arm64v8; do + if [ -z "${hasArches["$alwaysExpectedArch"]:-}" ]; then + echo >&2 "error: missing '$alwaysExpectedArch' for '$version'; cowardly refusing to continue! (because this is almost always a scraping flake or similar bug)" + exit 1 + fi + done + + # order here controls the order of the library/ file + for variant in \ + cli \ + dind \ + dind-rootless \ + windows/windowsservercore-ltsc2025 \ + windows/windowsservercore-ltsc2022 \ + ; do + base="${variant%%/*}" # "buster", "windows", etc. + if [ "$base" = 'windows' ] && [ -z "${hasArches['windows-amd64']}" ]; then + continue + fi + export variant + doc="$(jq <<<"$doc" -c '.variants += [ env.variant ]')" + done + + json="$(jq <<<"$json" -c --argjson doc "$doc" ' + .[env.version] = $doc + # make sure both "XX.YY" and "XX.YY-rc" always exist + | .[env.rcVersion] //= null + | .[env.rcVersion + "-rc"] //= null + ')" +done + +jq <<<"$json" -S . > versions.json