From 98697c544e37ee8a38f14f8c9e1aac6e7030fcaa Mon Sep 17 00:00:00 2001 From: Quentin McGaw Date: Mon, 15 Jul 2019 22:03:17 -0700 Subject: [PATCH] Added Docker CLI binary to final image --- Dockerfile | 17 ++++++++++++++++- README.md | 4 ++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 03eafc31..b88ad974 100644 --- a/Dockerfile +++ b/Dockerfile @@ -14,6 +14,20 @@ RUN CGO_ENABLED=0 GOOS=linux GOARCH=${GOARCH} GOARM=${GOARM} go build -a -ldflag -X main.version=${VERSION} \ -X main.buildSource=Docker" +FROM ${BASE_IMAGE_BUILDER}:${GO_VERSION}-alpine${ALPINE_VERSION} AS docker-builder +ARG GOARCH=amd64 +ARG GOARM +ARG DOCKER_VERSION=v18.09.7 +RUN apk add -U -q --progress --no-cache git bash coreutils gcc musl-dev +WORKDIR /go/src/github.com/docker/cli +RUN git clone --branch ${DOCKER_VERSION} --single-branch --depth 1 https://github.com/docker/cli.git . > /dev/null 2>&1 +ENV CGO_ENABLED=0 \ + GOARCH=${GOARCH} \ + GOARM=${GOARM} \ + DISABLE_WARN_OUTSIDE_CONTAINER=1 +RUN ./scripts/build/binary +RUN rm build/docker && mv build/docker-linux-* build/docker + FROM scratch ARG BUILD_DATE ARG VCS_REF @@ -28,4 +42,5 @@ LABEL org.label-schema.schema-version="1.0.0-rc1" \ org.label-schema.version=${VERSION} ENTRYPOINT [ "/lazydocker" ] VOLUME [ "/.config/jesseduffield/lazydocker" ] -COPY --from=builder /go/src/github.com/jesseduffield/lazydocker/lazydocker /lazydocker \ No newline at end of file +ENV PATH=/ +COPY --from=docker-builder /go/src/github.com/docker/cli/build/docker /docker \ No newline at end of file diff --git a/README.md b/README.md index 74c267a5..f36cc6cf 100644 --- a/README.md +++ b/README.md @@ -117,6 +117,10 @@ docker build -t lazyteam/lazydocker \ . ``` +If you encounter a compatibility issue with Docker bundled binary, try rebuilding +the image with the build argument `--build-arg DOCKER_VERSION="v$(docker -v | cut -d" " -f3 | rev | cut -c 2- | rev)"` +so that the bundled docker binary matches your host docker binary version. + ## Usage Call `lazydocker` in your terminal. I personally use this a lot so I've made an alias for it like so: