Skip to content

Instantly share code, notes, and snippets.

@barsa-net
Last active February 29, 2024 16:14
Show Gist options
  • Save barsa-net/e049b9651677491bda8ca1ca4ce2ab7c to your computer and use it in GitHub Desktop.
Save barsa-net/e049b9651677491bda8ca1ca4ce2ab7c to your computer and use it in GitHub Desktop.
wagoodman/dive image builder for ARM64/aarch64
FROM golang:alpine AS builder
RUN apk update && \
apk add git make
WORKDIR /go/src
ARG DIVE_VERSION=${DIVE_VERSION:-v0.10.0}
RUN git clone https://github.com/wagoodman/dive.git dive && \
git -C /go/src/dive checkout ${DIVE_VERSION}
WORKDIR /go/src/dive
ENV CGO_ENABLED=0
RUN make build
FROM scratch AS export-stage
COPY --from=builder /go/src/dive/dist/dive_linux_amd64/dive .
FROM alpine:3.12
ARG DOCKER_CLI_VERSION=${DOCKER_CLI_VERSION:-19.03.1}
RUN wget -O- https://download.docker.com/linux/static/stable/$(uname -m)/docker-${DOCKER_CLI_VERSION}.tgz | \
tar -xzf - docker/docker --strip-component=1 && \
mv docker /usr/local/bin
COPY --from=builder /go/src/dive/dist/dive_linux_amd64/dive /usr/local/bin
ENTRYPOINT ["/usr/local/bin/dive"]
@barsa-net
Copy link
Author

barsa-net commented Jan 8, 2022

As wagoodman/dive does not come with an aarch64 image, I use this Dockerfile as one-file image builder on my RPi.

It has not thoroughly tested but it should work in most cases.

Usage

Docker Image

Build as usual, tagging it as the original image

docker build . -t wagoodman/dive:latest

then you can just use it with the official suggested run options:

docker run --rm -it \
    -v /var/run/docker.sock:/var/run/docker.sock \
    wagoodman/dive:latest <dive arguments...>

Binary

If your prefer to have a binary to install on your local system you use BuildKit and you will find the binary inside dist/ folder, building should consume about ~600MiB of disk space and it takes about ~130s on my RPi 4
NOTE: to build this you must have Docker 18.09 or higher

DOCKER_BUILDKIT=1 docker build --target=export-stage --output dist .

Cleanup

FYI, you can prune the builder cache doing

docker builder prune

@lukaszmn
Copy link

Thanks, it almost worked for Raspberry Pi 4 (armv71).

I had to make two changes:

  1. In the Dockerfile I changed $(uname -m) to armhf:
RUN wget -O- https://download.docker.com/linux/static/stable/armhf/docker-${DOCKER_CLI_VERSION}.tgz | \
  1. I added the Docker version (obtained with docker -v) when building the image:
docker build . -t wagoodman/dive:latest --build-arg DOCKER_CLI_VERSION=20.10.12

@unphased
Copy link

This is great, thank you. It seems to work for aarch64 as well. Working with Nvidia Jetson docker files here.

I was hoping to use dive to inspect a very large (30GB) dev docker image since I don't have enough free space on the VM to do a docker save on it. Unfortunately it looks like dive also has to make a copy and i also ran out of disk trying to run dive... Oh well, time to expand the vm disk one more time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment