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.
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.