其他分享
首页 > 其他分享> > Dockerfile制作alpine-glibc镜像

Dockerfile制作alpine-glibc镜像

作者:互联网

一 工作目录

root@k8s-harbor-01:/data/dockerfile/system/alpine-glibc# pwd
/data/dockerfile/system/alpine-glibc

二 下载glibc

root@k8s-harbor-01:/data/dockerfile/system/alpine-glibc# wget https://github.com/sgerrand/alpine-pkg-glibc/releases/download/2.34-r0/glibc-2.34-r0.apk

三 编写Dockerfile

root@k8s-harbor-01:/data/dockerfile/system/alpine-glibc# cat Dockerfile 
FROM alpine:3.15

COPY glibc-2.34-r0.apk /tmp
RUN echo \
        "-----BEGIN PUBLIC KEY-----\
        MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEApZ2u1KJKUu/fW4A25y9m\
        y70AGEa/J3Wi5ibNVGNn1gT1r0VfgeWd0pUybS4UmcHdiNzxJPgoWQhV2SSW1JYu\
        tOqKZF5QSN6X937PTUpNBjUvLtTQ1ve1fp39uf/lEXPpFpOPL88LKnDBgbh7wkCp\
        m2KzLVGChf83MS0ShL6G9EQIAUxLm99VpgRjwqTQ/KfzGtpke1wqws4au0Ab4qPY\
        KXvMLSPLUp7cfulWvhmZSegr5AdhNw5KNizPqCJT8ZrGvgHypXyiFvvAH5YRtSsc\
        Zvo9GI2e2MaZyo9/lvb+LbLEJZKEQckqRj4P26gmASrZEPStwc+yqy1ShHLA0j6m\
        1QIDAQAB\
        -----END PUBLIC KEY-----" | sed 's/   */\n/g' > "/etc/apk/keys/sgerrand.rsa.pub" \
    && apk add /tmp/glibc-2.34-r0.apk \
    && rm -rf /tmp/glibc-2.34-r0.apk

四 编写构建镜像脚本

root@k8s-harbor-01:/data/dockerfile/system/alpine-glibc# cat build-command.sh 
#!/bin/bash
docker build -t  192.168.174.120/baseimages/alpine_glibc-base:3.15 .

#docker push 192.168.174.120/baseimages/alpine_glibc-base:3.15

五 构建镜像

root@k8s-harbor-01:/data/dockerfile/system/alpine-glibc# ./build-command.sh 
Sending build context to Docker daemon  1.945MB
Step 1/3 : FROM alpine:3.15
 ---> c059bfaa849c
Step 2/3 : COPY glibc-2.34-r0.apk /tmp
 ---> 539a16de5d07
Step 3/3 : RUN echo         "-----BEGIN PUBLIC KEY-----        MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEApZ2u1KJKUu/fW4A25y9m        y70AGEa/J3Wi5ibNVGNn1gT1r0VfgeWd0pUybS4UmcHdiNzxJPgoWQhV2SSW1JYu        tOqKZF5QSN6X937PTUpNBjUvLtTQ1ve1fp39uf/lEXPpFpOPL88LKnDBgbh7wkCp        m2KzLVGChf83MS0ShL6G9EQIAUxLm99VpgRjwqTQ/KfzGtpke1wqws4au0Ab4qPY        KXvMLSPLUp7cfulWvhmZSegr5AdhNw5KNizPqCJT8ZrGvgHypXyiFvvAH5YRtSsc        Zvo9GI2e2MaZyo9/lvb+LbLEJZKEQckqRj4P26gmASrZEPStwc+yqy1ShHLA0j6m        1QIDAQAB        -----END PUBLIC KEY-----" | sed 's/   */\n/g' > "/etc/apk/keys/sgerrand.rsa.pub"     && apk add /tmp/glibc-2.34-r0.apk     && rm -rf /tmp/glibc-2.34-r0.apk
 ---> Running in 0a6cf2ace175
fetch https://dl-cdn.alpinelinux.org/alpine/v3.15/main/x86_64/APKINDEX.tar.gz
fetch https://dl-cdn.alpinelinux.org/alpine/v3.15/community/x86_64/APKINDEX.tar.gz
(1/1) Installing glibc (2.34-r0)
OK: 10 MiB in 15 packages
Removing intermediate container 0a6cf2ace175
 ---> 6a740bc2390f
Successfully built 6a740bc2390f
Successfully tagged 192.168.174.120/baseimages/alpine_glibc-base:3.15

六 提交镜像到harbor

root@k8s-harbor-01:/data/dockerfile/system/alpine-glibc# docker push 192.168.174.120/baseimages/alpine_glibc-base:3.15

标签:2.34,r0,glibc,apk,-----,Dockerfile,alpine
来源: https://www.cnblogs.com/wangguishe/p/15635119.html