Docker installation

curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.sh
sudo usermod -aG ${user_name}
Copy the code

The build – kit is what

  • See Build ARM Based Docker Images
  • Simply put, it’s extensiondocker buildAn experimental feature of the
"features": {
    "buildkit": true
  }
Copy the code

Build with bind as an example

  • docker-bindThe project is an open source custom DNS deployment service, but does not provide a baselinux/aarch64An available mirror of the schema, so you need to use it yourselfbuildxCommand to perform the build operation
    • In the Raspberry PI system, executeuname -aTo look at your target architecture
# Run the following command on the raspberry PI system
git clone https://github.com/sameersbn/docker-bind.git
cd docker-bind
# change the content of Dockerfile. This setting is related to docker-bind, not build-kit, but for demonstration purposes only
echo 'FROM ubuntu:focal-20200423 AS add-apt-repositories
COPY jcameron-key.asc jcameron-key.asc
RUN apt-get update \
 && DEBIAN_FRONTEND=noninteractive apt-get install -y gnupg \
 && apt-get install -y curl \
 && apt-key adv --fetch-keys https://www.webmin.com/jcameron-key.asc \
 && echo "deb http://download.webmin.com/download/repository sarge contrib" >> /etc/apt/sources.list

FROM ubuntu:focal-20200423

LABEL maintainer="[email protected]"

ENV BIND_USER=bind \
    BIND_VERSION=9.16.1 \
    WEBMIN_VERSION=1.970 \
    DATA_DIR=/data

RUN apt-get update \
  && apt-get install -y curl

COPY --from=add-apt-repositories /etc/apt/trusted.gpg /etc/apt/trusted.gpg

COPY --from=add-apt-repositories /etc/apt/sources.list /etc/apt/sources.list

RUN rm -rf /etc/apt/apt.conf.d/docker-gzip-indexes \
 && apt-get update \
 && DEBIAN_FRONTEND=noninteractive apt-get install -y \
      bind9=1:${BIND_VERSION}* bind9-host=1:${BIND_VERSION}* dnsutils \
      webmin=${WEBMIN_VERSION}* \
 && rm -rf /var/lib/apt/lists/*

COPY entrypoint.sh /sbin/entrypoint.sh

RUN chmod 755 /sbin/entrypoint.sh

EXPOSE 53/udp 53/tcp 10000/tcp

ENTRYPOINT ["/sbin/entrypoint.sh"]

CMD ["/usr/sbin/named"]' > Dockerfile
Log in to your Docker repository
# I use aliyun's mirror warehouse, and I can also use dockerHub's official warehouse
docker login --username=${user_name} registry.cn-hangzhou.aliyuncs.com
docker buildx build --platform linux/aarch64  -t registry.cn-hangzhou.aliyuncs.com/docker-image-lee/bind:aarch64 --no-cache --push .

If you are running a build on Mac or Windows, you need to run the following command first
docker buildx create --use
Copy the code
  • Once push is complete, it can be used on raspberry PI

reference

  • build ARM based Docker Images

  • docker buildx build

  • Build Docker Image for Raspberry Pi