1. 程式人生 > 其它 >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