1、安装docker-buildx插件
yum install -y docker-buildx-plugin
2、 执行docker buildx create
docker buildx create --name liebe --use --platform linux/amd64,linux/arm64 --driver docker-container --driver-opt network=host --config=buildkit.toml
docker buildx ls 可以查看
docker buildx rm 名称 可以删除
3、use创建的 buildx
docker buildx use liebe
4、镜像打包构建
docker buildx build --load --platform linux/arm64 -t graylog-log-sidecar-collector:latest .
补充、配置docker
vim /etc/docker/daemon.json
{
"registry-mirrors": ["https://docker.888666222.xyz","https://docker.rainbond.cc","https://do.nark.eu.org",
"https://dc.j8.work",
"https://docker.m.daocloud.io",
"https://dockerproxy.com",
"https://docker.mirrors.ustc.edu.cn",
"https://docker.nju.edu.cn"]
}sudo systemctl daemon-reload
sudo systemctl restart docker
将镜像加载到本地 Docker 引擎:
使用
--load
参数将构建的镜像加载到本地 Docker 环境中,这样你可以直接使用该镜像:
buildkit.toml内容
debug=true
[registry."docker.io"]
mirrors = ["https://docker.888666222.xyz"]
Dockerfile
FROM arm64v8/debian:buster-slim
LABEL maintainer 'Markus Gulden <mg@gulden.consulting>'
RUN apt-get update && apt-get install -y openssl libapr1 libdbi1 libexpat1 ca-certificates
ENV SIDECAR_BINARY_URL https://github.com/Graylog2/collector-sidecar/releases/download/1.5.0/graylog-sidecar_1.5.0-1_arm64.deb
ENV FILEBEAT_BINARY_URL https://artifacts.elastic.co/downloads/beats/filebeat/filebeat-7.17.3-arm64.deb
RUN apt-get install -y --no-install-recommends curl && curl -Lo sidecar.deb ${SIDECAR_BINARY_URL} && dpkg -i sidecar.deb && rm sidecar.deb && curl -Lo filebeat.deb ${FILEBEAT_BINARY_URL} && dpkg -i filebeat.deb && rm filebeat.deb && apt-get purge -y --auto-remove curl
#GS_LIST_LOG_FILES="[]"
ENV GS_UPDATE_INTERVAL=10 \
GS_TLS_SKIP_VERIFY="false" \
GS_SEND_STATUS="true" \
GS_CACHE_PATH="/var/cache/graylog-sidecar" \
GS_COLLECTOR_CONFIGURATION_DIRECTORY="/var/lib/graylog-sidecar/generated" \
GS_LOG_PATH="/var/log/graylog-sidecar" \
GS_LOG_ROTATE_MAX_FILE_SIZE="1MiB" \
GS_LOG_ROTATE_KEEP_FILES=100 \
GS_COLLECTOR_BINARIES_WHITELIST="["/usr/bin/filebeat", "/usr/bin/packetbeat", "/usr/bin/metricbeat", "/usr/bin/heartbeat", "/usr/bin/auditbeat", "/usr/bin/journalbeat", "/usr/share/filebeat/bin/filebeat", "/usr/share/packetbeat/bin/packetbeat", "/usr/share/metricbeat/bin/metricbeat", "/usr/share/heartbeat/bin/heartbeat", "/usr/share/auditbeat/bin/auditbeat", "/usr/share/journalbeat/bin/journalbeat", "/usr/bin/nxlog", "/opt/nxlog/bin/nxlog"]"
ADD ./data /data
CMD /usr/bin/graylog-sidecar -c /data/sidecar.yml
查看docker镜像的架构
docker inspect --format '{{.Architecture}}' graylog-log-sidecar-collector:latest