Skip to content

fix: isolate glibc libs in alpine image to avoid conflicts with musl packages#523

Merged
bartlomieju merged 2 commits intomainfrom
fix/alpine-glibc-isolation
Mar 25, 2026
Merged

fix: isolate glibc libs in alpine image to avoid conflicts with musl packages#523
bartlomieju merged 2 commits intomainfrom
fix/alpine-glibc-isolation

Conversation

@bartlomieju
Copy link
Copy Markdown
Member

Summary

  • Move glibc libraries from /usr/local/lib/ to /usr/local/lib/glibc/ so they don't shadow Alpine's musl-compatible libraries
  • Remove the global LD_LIBRARY_PATH="/usr/local/lib" env var
  • Use patchelf --set-rpath to embed the library path directly in the deno and tini binaries (patchelf is installed and removed in the same layer)

This fixes the issue where installing musl-based packages (node, ffmpeg, etc.) into the alpine image would crash because glibc's libgcc_s.so.1 in /usr/local/lib/ was shadowing Alpine's native version.

Before:

$ apk add nodejs && node -v
Error relocating /usr/local/lib/libgcc_s.so.1: _dl_find_object: symbol not found

After:

$ apk add nodejs && node -v
v24.13.0
$ deno --version
deno 2.7.6

Fixes #350

Test plan

  • deno eval "console.log('hello')" works
  • deno --version works
  • apk add nodejs npm && node -v works (no longer crashes)
  • Express app via npm:express runs and responds correctly

🤖 Generated with Claude Code

…packages

Move glibc libraries from /usr/local/lib/ to /usr/local/lib/glibc/ and
use patchelf to embed the rpath directly in the deno and tini binaries,
removing the global LD_LIBRARY_PATH env var. This prevents glibc's
libgcc_s.so.1 from shadowing Alpine's musl-compatible version, which
caused crashes when installing musl-based packages like node or ffmpeg.

Fixes #350

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor

@igorbdl igorbdl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🚀

@bartlomieju bartlomieju merged commit 01a6547 into main Mar 25, 2026
6 checks passed
@bartlomieju bartlomieju deleted the fix/alpine-glibc-isolation branch March 25, 2026 07:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Latest image broke nodejs / npm usage (maybe related to libgcc)

2 participants