【问题标题】:Is there a best practice on setting up glibc on docker alpine linux base image?在 docker alpine linux 基础映像上设置 glibc 是否有最佳实践?
【发布时间】:2016-10-15 14:07:26
【问题描述】:

是否有在 docker alpine linux 基础映像上设置 glibc 的最佳实践,并使用正确的路径,以便任何生成的进程都可以正确引用已安装的 libc 库的位置?

【问题讨论】:

标签: docker glibc alpine


【解决方案1】:

到目前为止,每次安装 glibc 兼容性库都对我有用

apk add gcompat

https://pkgs.alpinelinux.org/package/edge/community/x86_64/gcompat

【讨论】:

    【解决方案2】:

    我创建了一个 github repo Docker build for glibc for alpine,支持多架构,即 x86_64、aarch64 等。您可以通过一行命令从最新的 glibc 源构建任何 CPU 类型。它是从sgerrand's repo 派生的,我修改为支持多架构并将构建阶段和打包阶段合并为一条线。或者您可以从发布页面下载预构建的包。

    【讨论】:

    • 当我运行它时,我得到E: The repository 'http://mirrors.aliyun.com/ubuntu disco Release' does not have a Release file. E: The repository 'http://mirrors.aliyun.com/ubuntu disco-security Release' does not have a Release file. E: The repository 'http://mirrors.aliyun.com/ubuntu disco-updates Release' does not have a Release file. E: The repository 'http://mirrors.aliyun.com/ubuntu disco-backports Release' does not have a Release file. E: The repository 'http://mirrors.aliyun.com/ubuntu disco-proposed Release' does not have a Release file.
    【解决方案3】:

    最佳做法是在 Alpine Linux 上安装 glibc。它使用 musl libc 代替,这是一个轻量级、快速、简单且符合标准的 C 库(即 glibc 所不具备的一切)。

    不要在 Alpine 上安装 glibc,而是为 Alpine 构建和/或打包您的依赖软件包和库。

        FROM alpine:3.4
        RUN echo "http://dl-cdn.alpinelinux.org/alpine/latest-stable/main" > /etc/apk/repositories
        RUN echo "http://dl-cdn.alpinelinux.org/alpine/latest-stable/community" >> /etc/apk/repositories
        RUN apk --no-cache --update-cache add gcc gfortran python python-dev py-pip build-base wget freetype-dev libpng-dev openblas-dev
        RUN ln -s /usr/include/locale.h /usr/include/xlocale.h
        RUN pip install numpy scipy pandas matplotlib
    

    【讨论】:

    • 因为没有好的选择。 Java、python、node等框架需要glibc,musl不支持(或者真的不支持)。所以要么使用大的基础镜像,要么使用带有移植 glibc 的 alpine
    • 使用 musl_libc 就像 Jeff Bezos 说从现在开始亚马逊只会用拉丁语做生意。
    【解决方案4】:

    是的,有,

    我使用自定义构建的 glibc 在其上安装 JRE。

    你可以找到它here

    您可以使用 wget 或 curl 获取代码和 apk 来安装它们

    更新的命令见下面的 cmets

    apk --no-cache add ca-certificates wget
    wget -q -O /etc/apk/keys/sgerrand.rsa.pub https://alpine-pkgs.sgerrand.com/sgerrand.rsa.pub
    wget https://github.com/sgerrand/alpine-pkg-glibc/releases/download/2.28-r0/glibc-2.28-r0.apk
    apk add glibc-2.28-r0.apk
    

    对我来说效果很好

    【讨论】:

    猜你喜欢
    • 2011-01-07
    • 2021-12-11
    • 1970-01-01
    • 2014-01-04
    • 1970-01-01
    • 2019-10-23
    • 1970-01-01
    • 2017-07-05
    • 1970-01-01
    相关资源
    最近更新 更多