github.com/jwhonce/docker@v0.6.7-0.20190327063223-da823cf3a5a3/Dockerfile (about) 1 # This file describes the standard way to build Docker, using docker 2 # 3 # Usage: 4 # 5 # # Use make to build a development environment image and run it in a container. 6 # # This is slow the first time. 7 # make BIND_DIR=. shell 8 # 9 # The following commands are executed inside the running container. 10 11 # # Make a dockerd binary. 12 # # hack/make.sh binary 13 # 14 # # Install dockerd to /usr/local/bin 15 # # make install 16 # 17 # # Run unit tests 18 # # hack/test/unit 19 # 20 # # Run tests e.g. integration, py 21 # # hack/make.sh binary test-integration test-docker-py 22 # 23 # Note: AppArmor used to mess with privileged mode, but this is no longer 24 # the case. Therefore, you don't have to disable it anymore. 25 # 26 27 FROM golang:1.12.1 AS base 28 # allow replacing httpredir or deb mirror 29 ARG APT_MIRROR=deb.debian.org 30 RUN sed -ri "s/(httpredir|deb).debian.org/$APT_MIRROR/g" /etc/apt/sources.list 31 32 FROM base AS criu 33 # Install CRIU for checkpoint/restore support 34 ENV CRIU_VERSION 3.11 35 # Install dependency packages specific to criu 36 RUN apt-get update && apt-get install -y \ 37 libnet-dev \ 38 libprotobuf-c0-dev \ 39 libprotobuf-dev \ 40 libnl-3-dev \ 41 libcap-dev \ 42 protobuf-compiler \ 43 protobuf-c-compiler \ 44 python-protobuf \ 45 && mkdir -p /usr/src/criu \ 46 && curl -sSL https://github.com/checkpoint-restore/criu/archive/v${CRIU_VERSION}.tar.gz | tar -C /usr/src/criu/ -xz --strip-components=1 \ 47 && cd /usr/src/criu \ 48 && make \ 49 && make PREFIX=/build/ install-criu 50 51 FROM base AS registry 52 ENV REGISTRY_COMMIT 47a064d4195a9b56133891bbb13620c3ac83a827 53 RUN set -x \ 54 && export GOPATH="$(mktemp -d)" \ 55 && git clone https://github.com/docker/distribution.git "$GOPATH/src/github.com/docker/distribution" \ 56 && (cd "$GOPATH/src/github.com/docker/distribution" && git checkout -q "$REGISTRY_COMMIT") \ 57 && GOPATH="$GOPATH/src/github.com/docker/distribution/Godeps/_workspace:$GOPATH" \ 58 go build -buildmode=pie -o /build/registry-v2 github.com/docker/distribution/cmd/registry \ 59 && rm -rf "$GOPATH" 60 61 62 63 FROM base AS docker-py 64 # Get the "docker-py" source so we can run their integration tests 65 ENV DOCKER_PY_COMMIT ac922192959870774ad8428344d9faa0555f7ba6 66 RUN git clone https://github.com/docker/docker-py.git /build \ 67 && cd /build \ 68 && git checkout -q $DOCKER_PY_COMMIT 69 70 71 72 FROM base AS swagger 73 # Install go-swagger for validating swagger.yaml 74 ENV GO_SWAGGER_COMMIT c28258affb0b6251755d92489ef685af8d4ff3eb 75 RUN set -x \ 76 && export GOPATH="$(mktemp -d)" \ 77 && git clone https://github.com/go-swagger/go-swagger.git "$GOPATH/src/github.com/go-swagger/go-swagger" \ 78 && (cd "$GOPATH/src/github.com/go-swagger/go-swagger" && git checkout -q "$GO_SWAGGER_COMMIT") \ 79 && go build -o /build/swagger github.com/go-swagger/go-swagger/cmd/swagger \ 80 && rm -rf "$GOPATH" 81 82 83 FROM base AS frozen-images 84 RUN apt-get update && apt-get install -y jq ca-certificates --no-install-recommends 85 # Get useful and necessary Hub images so we can "docker load" locally instead of pulling 86 COPY contrib/download-frozen-image-v2.sh / 87 RUN /download-frozen-image-v2.sh /build \ 88 buildpack-deps:jessie@sha256:dd86dced7c9cd2a724e779730f0a53f93b7ef42228d4344b25ce9a42a1486251 \ 89 busybox:latest@sha256:bbc3a03235220b170ba48a157dd097dd1379299370e1ed99ce976df0355d24f0 \ 90 busybox:glibc@sha256:0b55a30394294ab23b9afd58fab94e61a923f5834fba7ddbae7f8e0c11ba85e6 \ 91 debian:jessie@sha256:287a20c5f73087ab406e6b364833e3fb7b3ae63ca0eb3486555dc27ed32c6e60 \ 92 hello-world:latest@sha256:be0cd392e45be79ffeffa6b05338b98ebb16c87b255f48e297ec7f98e123905c 93 # See also ensureFrozenImagesLinux() in "integration-cli/fixtures_linux_daemon_test.go" (which needs to be updated when adding images to this list) 94 95 # Just a little hack so we don't have to install these deps twice, once for runc and once for dockerd 96 FROM base AS runtime-dev 97 RUN apt-get update && apt-get install -y \ 98 libapparmor-dev \ 99 libseccomp-dev 100 101 102 FROM base AS tomlv 103 ENV INSTALL_BINARY_NAME=tomlv 104 COPY hack/dockerfile/install/install.sh ./install.sh 105 COPY hack/dockerfile/install/$INSTALL_BINARY_NAME.installer ./ 106 RUN PREFIX=/build ./install.sh $INSTALL_BINARY_NAME 107 108 FROM base AS vndr 109 ENV INSTALL_BINARY_NAME=vndr 110 COPY hack/dockerfile/install/install.sh ./install.sh 111 COPY hack/dockerfile/install/$INSTALL_BINARY_NAME.installer ./ 112 RUN PREFIX=/build ./install.sh $INSTALL_BINARY_NAME 113 114 FROM base AS containerd 115 RUN apt-get update && apt-get install -y btrfs-tools 116 ENV INSTALL_BINARY_NAME=containerd 117 COPY hack/dockerfile/install/install.sh ./install.sh 118 COPY hack/dockerfile/install/$INSTALL_BINARY_NAME.installer ./ 119 RUN PREFIX=/build ./install.sh $INSTALL_BINARY_NAME 120 121 FROM base AS proxy 122 ENV INSTALL_BINARY_NAME=proxy 123 COPY hack/dockerfile/install/install.sh ./install.sh 124 COPY hack/dockerfile/install/$INSTALL_BINARY_NAME.installer ./ 125 RUN PREFIX=/build ./install.sh $INSTALL_BINARY_NAME 126 127 FROM base AS gometalinter 128 ENV INSTALL_BINARY_NAME=gometalinter 129 COPY hack/dockerfile/install/install.sh ./install.sh 130 COPY hack/dockerfile/install/$INSTALL_BINARY_NAME.installer ./ 131 RUN PREFIX=/build ./install.sh $INSTALL_BINARY_NAME 132 133 FROM base AS dockercli 134 ENV INSTALL_BINARY_NAME=dockercli 135 COPY hack/dockerfile/install/install.sh ./install.sh 136 COPY hack/dockerfile/install/$INSTALL_BINARY_NAME.installer ./ 137 RUN PREFIX=/build ./install.sh $INSTALL_BINARY_NAME 138 139 FROM runtime-dev AS runc 140 ENV INSTALL_BINARY_NAME=runc 141 COPY hack/dockerfile/install/install.sh ./install.sh 142 COPY hack/dockerfile/install/$INSTALL_BINARY_NAME.installer ./ 143 RUN PREFIX=/build ./install.sh $INSTALL_BINARY_NAME 144 145 FROM base AS tini 146 RUN apt-get update && apt-get install -y cmake vim-common 147 COPY hack/dockerfile/install/install.sh ./install.sh 148 ENV INSTALL_BINARY_NAME=tini 149 COPY hack/dockerfile/install/$INSTALL_BINARY_NAME.installer ./ 150 RUN PREFIX=/build ./install.sh $INSTALL_BINARY_NAME 151 152 FROM base AS rootlesskit 153 ENV INSTALL_BINARY_NAME=rootlesskit 154 COPY hack/dockerfile/install/install.sh ./install.sh 155 COPY hack/dockerfile/install/$INSTALL_BINARY_NAME.installer ./ 156 RUN PREFIX=/build/ ./install.sh $INSTALL_BINARY_NAME 157 COPY ./contrib/dockerd-rootless.sh /build 158 159 # TODO: Some of this is only really needed for testing, it would be nice to split this up 160 FROM runtime-dev AS dev 161 RUN groupadd -r docker 162 RUN useradd --create-home --gid docker unprivilegeduser 163 # Let us use a .bashrc file 164 RUN ln -sfv /go/src/github.com/docker/docker/.bashrc ~/.bashrc 165 # Activate bash completion and include Docker's completion if mounted with DOCKER_BASH_COMPLETION_PATH 166 RUN echo "source /usr/share/bash-completion/bash_completion" >> /etc/bash.bashrc 167 RUN ln -s /usr/local/completion/bash/docker /etc/bash_completion.d/docker 168 RUN ldconfig 169 # This should only install packages that are specifically needed for the dev environment and nothing else 170 # Do you really need to add another package here? Can it be done in a different build stage? 171 RUN apt-get update && apt-get install -y \ 172 apparmor \ 173 aufs-tools \ 174 bash-completion \ 175 btrfs-tools \ 176 iptables \ 177 jq \ 178 libcap2-bin \ 179 libdevmapper-dev \ 180 # libffi-dev and libssl-dev appear to be required for compiling paramiko on s390x/ppc64le 181 libffi-dev \ 182 libssl-dev \ 183 libudev-dev \ 184 libsystemd-dev \ 185 binutils-mingw-w64 \ 186 g++-mingw-w64-x86-64 \ 187 net-tools \ 188 pigz \ 189 python-backports.ssl-match-hostname \ 190 python-dev \ 191 # python-cffi appears to be required for compiling paramiko on s390x/ppc64le 192 python-cffi \ 193 python-mock \ 194 python-pip \ 195 python-requests \ 196 python-setuptools \ 197 python-websocket \ 198 python-wheel \ 199 thin-provisioning-tools \ 200 vim \ 201 vim-common \ 202 xfsprogs \ 203 zip \ 204 bzip2 \ 205 xz-utils \ 206 libprotobuf-c1 \ 207 libnet1 \ 208 libnl-3-200 \ 209 --no-install-recommends 210 COPY --from=swagger /build/swagger* /usr/local/bin/ 211 COPY --from=frozen-images /build/ /docker-frozen-images 212 COPY --from=gometalinter /build/ /usr/local/bin/ 213 COPY --from=tomlv /build/ /usr/local/bin/ 214 COPY --from=vndr /build/ /usr/local/bin/ 215 COPY --from=tini /build/ /usr/local/bin/ 216 COPY --from=runc /build/ /usr/local/bin/ 217 COPY --from=containerd /build/ /usr/local/bin/ 218 COPY --from=proxy /build/ /usr/local/bin/ 219 COPY --from=dockercli /build/ /usr/local/cli 220 COPY --from=registry /build/registry* /usr/local/bin/ 221 COPY --from=criu /build/ /usr/local/ 222 COPY --from=docker-py /build/ /docker-py 223 # TODO: This is for the docker-py tests, which shouldn't really be needed for 224 # this image, but currently CI is expecting to run this image. This should be 225 # split out into a separate image, including all the `python-*` deps installed 226 # above. 227 RUN cd /docker-py \ 228 && pip install docker-pycreds==0.4.0 \ 229 && pip install paramiko==2.4.2 \ 230 && pip install yamllint==1.5.0 \ 231 && pip install -r test-requirements.txt 232 COPY --from=rootlesskit /build/ /usr/local/bin/ 233 COPY --from=djs55/vpnkit@sha256:e508a17cfacc8fd39261d5b4e397df2b953690da577e2c987a47630cd0c42f8e /vpnkit /usr/local/bin/vpnkit.x86_64 234 235 ENV PATH=/usr/local/cli:$PATH 236 ENV DOCKER_BUILDTAGS apparmor seccomp selinux 237 # Options for hack/validate/gometalinter 238 ENV GOMETALINTER_OPTS="--deadline=2m" 239 WORKDIR /go/src/github.com/docker/docker 240 VOLUME /var/lib/docker 241 # Wrap all commands in the "docker-in-docker" script to allow nested containers 242 ENTRYPOINT ["hack/dind"] 243 244 FROM dev AS final 245 # Upload docker source 246 COPY . /go/src/github.com/docker/docker