Use docker build kit to build an Docker image available on a raspberry pie
- 2021-10-11 20:04:21
- OfStack
Docker Installation
curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.sh
sudo usermod -aG ${user_name}
What is build-kit
Refer to build ARM based Docker Images Simply put, it is an extensiondocker build
An experimental function of
Take bind as an example to build it
The docker-bind project is an open source custom DNS deployment service, but does not provide a service based on
linux/aarch64
The available image of the schema, so you need to use it yourself
buildx
Command to perform a build operation
In the raspberry pie system, execute the
uname -a
To view your target schema
....
# Execute the following command in the raspberry pie system
git clone https://github.com/sameersbn/docker-bind.git
cd docker-bind
# Modify Dockerfile Content, pay attention! ! This setting is the same as docker-bind Relating to, relating to build-kit It has nothing to do with the use of, only for demonstration
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="sameer@damagehead.com"
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 own docker Warehouse
# I use Alibaba Cloud's mirror warehouse, or I can use it dockerhub 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 it is in Mac Or Windows To execute a build on, you need to first execute the following command
docker buildx create --use
After push is finished, it can be used on raspberry pie ~
Reference
build ARM based Docker Images
docker buildx build
Build Docker Image for Raspberry Pi