Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Alpine Linux How to install x86 packages on x86_64 architecture

Tags:

docker

alpine

I am trying to install 32-bit packages on official alpine docker images but whenever I do apk add libcurl for example it install 64-bit version of libcurl whereas I want to install 32-bit package. Any thoughts how to do the same on Alpine Linux 3.7?

like image 927
Abhinav Avatar asked Jan 29 '18 10:01

Abhinav


People also ask

How do I install an Alpine package in Linux?

You can install packages from a local disk (such as CDROM or a USB stick) or the internet archive location using apk command, the Alpine package manager for binary packages, instead of compiling them from the source. The list of repositories is stored in /etc/apk/repositories configuration file.

Is Alpine 64 bit?

If you run Docker on a non-Linux host, for example in Docker Desktop on Windows and macOS, then your containers are probably running on Alpine Linux. Native versions are available for 32- and 64-bit x86 and Arm, plus PPC64le and IBM s390x; MIPS64 was dropped in the last release.

What packages does Alpine Linux use?

Alpine Linux is a very simple distribution that will try to stay out of your way. It uses its own package manager called apk, the OpenRC init system, script driven set-ups and that's it!


1 Answers

Actually, only one file defines which packages take from alpine repos. It is /etc/apk/arch:

# cat /etc/apk/arch 
x86_64

Its value shows which packages we should take from our alpine repos:

# cat /etc/apk/repositories 
http://dl-cdn.alpinelinux.org/alpine/v3.7/main
http://dl-cdn.alpinelinux.org/alpine/v3.7/community

So, we can make a trick here. We can "switch" alpine to get x86 packages from the repos:

/ # echo "x86" > /etc/apk/arch
/ # apk add --no-cache libcurl
fetch http://dl-cdn.alpinelinux.org/alpine/v3.7/main/x86/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.7/community/x86/APKINDEX.tar.gz
(1/12) Replacing musl (1.1.18-r2 -> 1.1.18-r2)
(2/12) Replacing busybox (1.27.2-r8 -> 1.27.2-r8)
Executing busybox-1.27.2-r8.post-upgrade
(3/12) Replacing alpine-baselayout (3.0.5-r2 -> 3.0.5-r2)
Executing alpine-baselayout-3.0.5-r2.pre-upgrade
Executing alpine-baselayout-3.0.5-r2.post-upgrade
(4/12) Replacing libressl2.6-libcrypto (2.6.3-r0 -> 2.6.3-r0)
(5/12) Replacing libressl2.6-libssl (2.6.3-r0 -> 2.6.3-r0)
(6/12) Replacing zlib (1.2.11-r1 -> 1.2.11-r1)
(7/12) Replacing apk-tools (2.8.2-r0 -> 2.8.2-r0)
(8/12) Replacing scanelf (1.2.2-r1 -> 1.2.2-r1)
(9/12) Replacing musl-utils (1.1.18-r2 -> 1.1.18-r2)
(10/12) Installing ca-certificates (20171114-r0)
(11/12) Installing libssh2 (1.8.0-r2)
(12/12) Installing libcurl (7.57.0-r0)
Executing busybox-1.27.2-r8.trigger
Executing ca-certificates-20171114-r0.trigger
OK: 5 MiB in 14 packages
like image 145
nickgryg Avatar answered Nov 03 '22 00:11

nickgryg