Is there a best practice on setting up glibc on docker alpine linux base image?

我与影子孤独终老i 提交于 2019-11-28 20:17:14

Yes there is,

I've used a custom built glibc to install a JRE on it.

You can find it here

You can use wget or curl to get the code and apk to install them

UPDATED commands see comments below

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

It worked perfectly for me

apk add libgcc

It seems that this makes glibc available. This increases the size of the image by a few MB.

Jakub Jirutka

The best practice is to not install glibc on Alpine Linux. It uses musl libc instead, a lightweight, fast, simple and standards-conform C library (i.e. everything that glibc is not).

Instead of installing glibc on Alpine, build and/or package your dependent software packages and libraries for 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
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!