slim icon indicating copy to clipboard operation
slim copied to clipboard

exec: "/bin/sh": stat /bin/sh: no such file or directory

Open ErikSvedin opened this issue 9 years ago • 9 comments

After using docker-slim to minify a base image (ui_base) which is used to build one of my apps. The child image fails to build with the error message provided in the title:

exec: "/bin/sh": stat /bin/sh: no such file or directory

Relevant parts of my dockerfile for the child image:

WORKDIR /src
ENTRYPOINT ["/src/docker-entrypoint.sh"]

RUN . /src/deploy.sh

For the deploy script i changed it around to:

CMD ["/src/deploy.sh"]

Which prevents error on the build step, but the entrypoint still gives the same error as above. Is this something obvious that im missing? The minification seems to work great. from 870mb -> 23

Im using:

docker -v
Docker version 1.9.1, build a34a1d5

ErikSvedin avatar Feb 16 '16 09:02 ErikSvedin

Sorry to hear about the problem Erik :-( Thank you for reporting it though! I'll try to repro the condition to see if it is what I think it is :-)

kcq avatar Feb 17 '16 02:02 kcq

I'd appreciate it. There's a lot being installed in the base image, including node, nginx and some internal npm dependencies. All is based on debian:jessie

ErikSvedin avatar Feb 17 '16 12:02 ErikSvedin

I couldn't repro the condition for some reason. Can you try to build and minify the new sample node app (in sample/apps/node_jessie) to see if you get the same error?

kcq avatar Feb 19 '16 07:02 kcq

@kcq I'm receiving the same Container command '/bin/sh' not found or does not exist.

FROM ruby:2.2.4

RUN apt-get update -qq && apt-get install -y --no-install-recommends \
    build-essential \
    libqt4-webkit \
    libqt4-dev \
    xvfb \
    nodejs \
    imagemagick
./docker-slim build test/ruby
FROM test/ruby.slim:latest

RUN mkdir -p /usr/src/app

mattpickle avatar May 16 '16 13:05 mattpickle

Same problem. Why?

imWildCat avatar Jun 15 '17 00:06 imWildCat

My issue seems similar using centos 7 as the base and a custom start up script. stat /blah/start.sh: no such file or directory": unknown.

btorretta avatar Feb 18 '20 20:02 btorretta

@btorretta what is your application container image like? What kind of application / application stack is it? What do you have for the ENTRYPOINT and CMD instructions in your image? What is /blah/start.sh and what is it supposed to do?

In general minifying the base images is a little more complicated and it requires extra parameters for the docker-slim build command because there's no application code to observe, so you need to tell docker-slim explicitly which components you want/need using the --include-path, --include-path-file, --include-bin, --include-exe and --include-shell parameters.

The error Matt had is related though slightly different. The minified base image no longer had a shell in it, so when the RUN mkdir -p /usr/src/app instruction in the child image fails (because you need a shell to run the mkdir command). This can be a potential docker-slim enhancement/feature to build new images from the minified/shell-less base images...

kcq avatar Feb 18 '20 20:02 kcq

Thanks @kcq . I've gotten past this issue by using those flags. This is a java application running under its own user in the dockerful and unfortunately there isn't a lot of leeway for me to change it. Now when I run docker run I get permission denied on files that I thought I was including, or at least their path. sudo docker-slim build --include-path /app/ --include-path /tmp/ --include-path /apps/ --include-path /usr/ --include-path-file /usr/bin/java.real --include-path-file /apps/ --include-path-file /usr/bin/ --http-probe=false --include-shell myfatimage

sudo docker run -p 5400:5400 -u blah myslimimage --env-file envfile

The run puts a permission denied for files on /tmp. Thank you.

btorretta avatar Feb 20 '20 00:02 btorretta

@btorretta Thanks for the extra info! The next version should address these permission related use cases and it'll also have an ability to overwrite/set permissions, so that should help here too.

kcq avatar Feb 25 '20 17:02 kcq