You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to use distroless images for my work. I know that distroless images don't have a shell so I use the debug version in multi-stage builds. But it fails:
Part of my Dockerfile:
FROM gcr.io/distroless/java:debug
RUN mkdir /opt/myfolder
> docker build -f Dockerfile -t mydocker:0.1 .
Sending build context to Docker daemon 189.5MB
Step 1/12 : FROM gcr.io/distroless/java:debug
---> 4949b7bccd46
Step 2/12 : RUN mkdir /opt/myfolder
---> Running in aff60bc2937b
OCI runtime create failed: container_linux.go:345: starting container process caused "exec: \"/bin/sh\": stat /bin/sh: no such file or directory": unknown
This doesn't seem to fix it for me. I'm starting with FROM gcr.io/distroless/java:8-nonroot and getting the following error:
OCI runtime create failed: container_linux.go:370: starting container process caused: exec: "/busybox/sh": stat /busybox/sh: no such file or directory: unknown
Activity
przemolb commentedon Oct 15, 2019
The same happens when I use:
FROM gcr.io/distroless/base-debian10or
FROM gcr.io/distroless/base-debian10:debugloosebazooka commentedon Oct 15, 2019
Yeah so
RUNby default use/bin/sh(hardcoded) if you use this syntax (shell form)The way to invoke busybox (using exec form) is to do something like
as described here: https://docs.docker.com/engine/reference/builder/#run
chanseokoh commentedon Oct 15, 2019
Alternatively
RUN ["/busybox/mkdir", "-p", "/opt/myfolder"]. You can think like some common tools (ls,chmod, ...) are under/busybox.przemolb commentedon Oct 16, 2019
So busybox is part of the distroless images ?! I thought it is only language related stuff ...
loosebazooka commentedon Oct 16, 2019
Sorry if it wasn't clear, but you can only do this in debug.
briandealwis commentedon Oct 16, 2019
Alternatively you can use the
SHELLdirective:senfo commentedon May 4, 2021
This doesn't seem to fix it for me. I'm starting with FROM gcr.io/distroless/java:8-nonroot and getting the following error:
OCI runtime create failed: container_linux.go:370: starting container process caused: exec: "/busybox/sh": stat /busybox/sh: no such file or directory: unknownloosebazooka commentedon May 4, 2021
As mentioned a few comments up, you can only use busybox in a debug image.
senfo commentedon May 4, 2021
Grr, I completely overlooked that tidbit. Thank you for the clarification. That cleared things up for me.
florath commentedon Jan 18, 2022
For the files: I had the same problem and took me some time to solve it. I really want to stay with the non-debug version.
It is possible to create an empty directory and then COPY it over into the image, like
The COPY command copies over the complete hierarchy, so it is possible to create a complete set of (empty) directories: