- Alpine Linux is a community developed operating system designed for routers, firewalls, VPNs, VoIP boxes and servers. It was designed with security in mind; it has proactive security features like PaX and SSP that prevent security holes in the software to be exploited.
- If you want to run glibc programs in Alpine Linux. Sudo mount -bind /sys sys sudo mount -t proc proc proc cp /etc/resolv.conf etc sudo chroot.
- Alpine Linux package often has the.apk extension and called as 'a-packs'. The apk command is equivalent to apt command / apt-get command on Debian/Ubuntu on yum command on CentOS Linux. Use apk for installing, upgrading, configuring, and removing apps/programs for an Alpine Linux operating system in a consistent manner.
- First of all, make sure the sudo package is installed in your Alpine Linux system. By default, sudo is not installed. To install sudo in Alpine Linux as root user, run: # apk update # apk add sudo. Next, let us create a new user in Alpine Linux and grant sudo privileges to the newly created user. Create a sudo user in Alpine Linux.
If you want to run glibc programs in Alpine Linux, there are a few ways of doing so. You could install glibc as additional to musl (you would have to do this manually), or you could do it the easy way and use either Flatpak (the easiest) or a chroot.
Because there are different use cases, this is just a slight overview about what's possible and what's intelligent.
- 1Your options
- 1.2Chroot
Flatpak
Flatpak is by far the easiest method of running any graphical glibc program on Alpine.Firstly install it.
Alpine docker image doesn't have bash installed by default. You will need to add following commands to get bash: RUN apk update && apk add bash If youre using Alpine 3.3+ then you can just do. RUN apk add -no-cache bash to keep docker image size small. (Thanks to comment from @sprkysnrky).
Then you can run any Flatpak application:
It is recommended to enable Flathub using it's instructions here, as most glibc programs you might need will be packaged there.
You can then install applications from it, for example:
Chroot
Gentoo Linux
Select a stage3 from here and portage latest from here at gentoo/snapshots/portage-latest.tar.xz.
First,
Enter the chroot:
And voilà, you have your working Gentoo chroot!
You can now take a look at Gentoo's Handbook to find out how you can configure and install your system, or simply extract/copy the program you need to run in your chroot enviroment and execute it.
Here is a wrapper script that is similar to arch-chroot
when you frequently reuse this chroot:
Also, create an account with the same user name as host current user to the chroot or make changes to the userspec option to chroot line.
Contents of gentoo-chroot.sh
Alpine Linux Bash App
Do at chmod +x gentoo-chroot.sh
to get it to work.
- 1Your options
- 1.2Chroot
Flatpak
Flatpak is by far the easiest method of running any graphical glibc program on Alpine.Firstly install it.
Alpine docker image doesn't have bash installed by default. You will need to add following commands to get bash: RUN apk update && apk add bash If youre using Alpine 3.3+ then you can just do. RUN apk add -no-cache bash to keep docker image size small. (Thanks to comment from @sprkysnrky).
Then you can run any Flatpak application:
It is recommended to enable Flathub using it's instructions here, as most glibc programs you might need will be packaged there.
You can then install applications from it, for example:
Chroot
Gentoo Linux
Select a stage3 from here and portage latest from here at gentoo/snapshots/portage-latest.tar.xz.
First,
Enter the chroot:
And voilà, you have your working Gentoo chroot!
You can now take a look at Gentoo's Handbook to find out how you can configure and install your system, or simply extract/copy the program you need to run in your chroot enviroment and execute it.
Here is a wrapper script that is similar to arch-chroot
when you frequently reuse this chroot:
Also, create an account with the same user name as host current user to the chroot or make changes to the userspec option to chroot line.
Contents of gentoo-chroot.sh
Alpine Linux Bash App
Do at chmod +x gentoo-chroot.sh
to get it to work.
Arch Linux
Either use pacstrap (included with the arch-install-scripts package) or an Arch bootstrap image:
Once that is done, update the system and install the desired package(s) (denoted by 'foo' in this example):
Alpine Linux Bash Profile
Debian
Use the provided debootstrap package to create the Debian chroot. --arch
is optional, depending of your needs.
Alpine Linux Bash Script
On the linux-grsec kernel, you will need to relax chroot limitations:
You can now use apt-get
to install needed packages.