Skip to content

Using with docker images

Wojtek Czekalski edited this page Sep 5, 2023 · 1 revision

Adding nix-ld to docker images allows you to run pre-compiled binaries that depend on dynamic libraries inside docker images. To achieve that:

  1. Add pkgs.nix-ld to your docker image
  2. Set Env in the image like so:
"NIX_LD_LIBRARY_PATH=${pkgs.lib.makeLibraryPath [ pkgs.stdenv.cc ]}"
''NIX_LD=${pkgs.lib.fileContents "${pkgs.stdenv.cc}/nix-support/dynamic-linker"}''
  1. add
runAsRoot = ''
  mkdir /lib64
  ln -s /libexec/nix-ld /lib64/$(basename  $(< ${pkgs.stdenv.cc}/nix-support/dynamic-linker))
'';
Clone this wiki locally