70

Is there a best practice on setting up glibc on docker alpine linux base image with correct paths so any spawned process can correctly reference the location of the installed libc libraries?

kai
  • 747
  • 1
  • 5
  • 8
  • 3
    The Alpine docks have a whole page dedicated to this... https://wiki.alpinelinux.org/wiki/Running_glibc_programs – bremen_matt Apr 04 '19 at 04:30

4 Answers4

56

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

carlomas
  • 974
  • 1
  • 8
  • 14
  • 1
    The updated commands are based on latest install instructions from https://github.com/sgerrand/alpine-pkg-glibc - these worked well – RichVel Mar 25 '21 at 18:12
18

Installing the glibc compatibility libraries has worked for me so far every time

apk add gcompat

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

secustor
  • 2,516
  • 2
  • 12
  • 17
6

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
Erik Aronesty
  • 10,225
  • 4
  • 54
  • 36
Jakub Jirutka
  • 9,541
  • 4
  • 40
  • 34
  • 18
    Because there is no good alternative. Java, python, node and other frameworks need glibc, musl is not supported (or not really). So either use use a big base image, or you use alpine with ported glibc – FreshMike Jun 22 '18 at 10:41
  • 17
    Using musl_libc is like Jeff Bezos saying that from now on Amazon will only do business in Latin. – Alwyn Schoeman Oct 11 '18 at 17:22
2

I had create a github repo Docker build for glibc for alpine, support multi-arch, i.e. x86_64, aarch64, etc. You can build from the latest glibc source for any CPU type in just one line command. It was forked from sgerrand's repo, I modified to support multi-arch and combine builder stage and packaging stage into one single line. Or you could just download the pre-built packages from release page.

Puxos
  • 21
  • 1
  • when I run it I get ```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.``` – Michaela Ervin Nov 16 '20 at 04:57