dockerTools.streamLayeredImage containers can't runt nix-friendly #!/usr/bin/env bash
script
#373143
Labels
0.kind: bug
Something is broken
Describe the bug
Nix-friendly bash scripts which use
#!/usr/bin/env bash
shebang don't work in docker images built bybuildLayeredImage
(and, transitively, bystreamLayeredImage
)This is caused by
/usr/bin/env
not being created and all packages' bins being linked to/bin
instead.Steps to reproduce
Steps to reproduce the behavior:
import.sh
mounted to container's/repo
:{"msg":"exec container process (missing dynamic library?) '/repo/./import.sh': No such file or directory","level":"error","time":"2025-01-12T09:44:45.821363Z"}
Expected behavior
Import script being run.
Additional context
head -n1 import.sh #!/usr/bin/env bash
I tried to understand where the/bin
symlinking happens but so far I was unable to identify the place. I think it happens in the$stdenv/setup
phase but the setup script is rather complicated and I have yet to analyze it properly.It seems the linking happens in the
symlinkJoin
step but so far I don't see how to address the issue.Therefore, I'm unsure who to tag.
I suggest a flag being added to
streamLayeredImage
which will make the build follow common distro practices and instead of putting links to/bin
puts them in/usr/bin
and symlinks/bin -> /usr/bin
. This might incidentally also indirectly solve (or at least make easier to solve) issues like #129007 or #240919 .Another solution would be to create the symlink
../bin/env usr/bin/env
in the process of image creation but that would be a single-use-case only solution and would probably do more harm than good, especially considering that not all images necessarily containcoreutils
(which providesenv
) - possibly put this behind a flag also? I don't think this is a good idea but it would work.Metadata
Notify maintainers
tbd.
Note for maintainers: Please tag this issue in your PR.
Add a 👍 reaction to issues you find important.
The text was updated successfully, but these errors were encountered: