I want to ask if it is possible to install Ubuntu or Debian packages in Alpine? I know Alpine uses musl while Debian uses glibc. Still I would like to know if it is possible without too much work. I am trying to port my server which runs on Ubuntu previously to Alpine but I realised that Nginx sub_filter is not available on Alpine's version of Nginx and I need that module.
- Short answer is no.Joe– Joe2020-06-18 03:27:03 +00:00Commented Jun 18, 2020 at 3:27
- You can search for Alpine with glibc support, there are some custom Alpine versions that include glibc out there.Federal Reserve– Federal Reserve2020-06-18 04:14:46 +00:00Commented Jun 18, 2020 at 4:14
- I think honestly that you wouldn't want to. Alpine is designed to be very small and light weight. Sucking down a whole bunch of bloated dependencies for the sake of one server module would pretty much defeat the point of Alpine. Are you porting this for docker?Philip Couling– Philip Couling2020-06-18 06:47:17 +00:00Commented Jun 18, 2020 at 6:47
- Yes, I am trying to port what used to run on Ubuntu to Alpine so that I can keep the overall size small.wesdork– wesdork2020-06-29 00:09:40 +00:00Commented Jun 29, 2020 at 0:09
1 Answer
You could actually install lightweight .deb packages on Alpine using dpkg. However, you'd need the .deb files for all dependent packages, so this could work only for very simple cases.
The main issue for running Debian/Ubuntu binaries on Alpine is indeed glibc incompatiblity with musl libc. You could tackle it on several levels:
For light glibc compatibility, try installing
libc6-compat. It is a thin wrapper around musl that provides some glibc interfaces and stubs. However, it is not likely to work for complex glibc applications.For full glibc compatibility, you could install glibc on your Alpine container, as suggested by @FederalReserve. This is actually a simple and common procedure. See for example: Dockerfile. glibc alone adds only a few extra MB to the Alpine image, which is relatively a lot considering Alpine base image is roughly 5MB on its own, but in absolute MB increase terms it should be definitely tolerable.
Attempt building the software natively on Alpine. In your case, Nginx with the
sub_filtermodule enabled. However, for Nginx, I don't know for sure the amount of effort required (depending on Nginx build system and whether the module requires porting to Alpine Linux), so this is just a suggestion.
- Alright, I will check out your suggestions to see which one works for me the best. Thank you!wesdork– wesdork2020-06-29 00:11:01 +00:00Commented Jun 29, 2020 at 0:11