Getting panic: spanic: standard_init_linux.go:178: exec user process caused "no such file or directory"red] while running the docker image

panic: spanic: standard_init_linux.go:178: exec user process caused "no such file or directory"red]
/usr/local/go/src/runtime/panic.go:481 +0x3e6
github.com/urfave/cli.HandleAction.func1(0xc8201092e8)
panic(0x/tmp/tmp.SspaUm6Eju/src/github.com/opencontainers/runc/Godeps/_workspace/src/github.com/urfave/cli/app.go:478 +0x38e
panic(0x/usr/local/go/src/runtime/panic.go:443 +0x4e9
github.c/tmp/tmp.SspaUm6Eju/src/github.com/opencontainers/runc/Godeps/_workspace/src/github.com/opencontainers/runc/libcontainer/factory_linux.go:259 +0x136
github.c/tmp/tmp.SspaUm6Eju/src/github.com/opencontainers/runc/Godeps/_workspace/src/github.com/opencontainers/runc/libcontainer/factory_linux.go:277 +0x5b1
main.glo/tmp/tmp.SspaUm6Eju/src/github.com/opencontainers/runc/main_unix.go:26 +0x68
reflect./usr/local/go/src/reflect/value.go:435 +0x120d 0x4, 0xc820109268, 0x1, 0x1, 0x0, 0x0, …)
reflect./usr/local/go/src/reflect/value.go:303 +0xb109268, 0x1, 0x1, 0x0, 0x0, 0x0)
github.c/tmp/tmp.SspaUm6Eju/src/github.com/opencontainers/runc/Godeps/_workspace/src/github.com/urfave/cli/app.go:487 +0x2ee
github.c/tmp/tmp.SspaUm6Eju/src/github.com/opencontainers/runc/Godeps/_workspace/src/github.com/urfave/cli/command.go:191 +0xfec
github.c/tmp/tmp.SspaUm6Eju/src/github.com/opencontainers/runc/Godeps/_workspace/src/github.com/urfave/cli/app.go:240 +0xaa4
main.mai/tmp/tmp.SspaUm6Eju/src/github.com/opencontainers/runc/main.go:137 +0xe24

your suggestions are appreciated if you come across these kind of errors

Hi,
I got similar problem :frowning:

panic: standard_init_linux.go:178: exec user process caused “no such file or directory” [recovered]
panic: standard_init_linux.go:178: exec user process caused “no such file or directory”

[…]

Solved :slight_smile:

In the Dockerfile check if in the Entrypoint you start some script.

If you start these script be sure that the first line is: #!/bin/sh
Instead of: #!/bin/bash

A greeting.

5 Likes

Awesome! Changing script to point to sh instead of bash fixed my issue!

1 Like

I also got into same trouble.
In my case, modifying bash is not solved either.

Try to posting a sample code that reproduces the error, Dockerfile and/or script started at Entrypoint.
I’m not an expert but maybe someone know more about the trouble.

A greeting.

I ran into the same issue. In my case I used a docker host on Windows, and my entry point script contained the well know windows end-of-line characters (^M).

As /bin/bash^M cannot be found. Simply removed these lines (dos2unix in windows powershell will help you).

3 Likes

Thanks for reply. although I have set “set ff=unix” in vim, but It still not working.
but It is certain that there is a problem with entry point script. if exclude entry point script, it work well.

You can run the image just before running the endpoint interactively, and then run the entrypoint manually. You will can then more easily debug the entrypoint issue.

Something like:

  1. add ^M to scripts to showcase problem:

    PS D:\peter\git\docker-nginx-ssl-secure> unix2dos .\entrypoint.sh
    unix2dos: converting file .\entrypoint.sh to DOS format…

  2. build the image:
    PS D:\peter\git\docker-nginx-ssl-secure> docker build .
    Sending build context to Docker daemon 193.5 kB
    Step 1/13 : FROM nginx
    —> cc1b61406712
    Step 2/13 : MAINTAINER MarvAmBass
    —> Using cache
    —> b9a7bd7082bf
    Step 3/13 : ENV LANG C.UTF-8
    —> Using cache
    —> 3ad7b2649826
    Step 4/13 : RUN apt-get update; apt-get install -y openssl
    —> Using cache
    —> b7d147f47854
    Step 5/13 : RUN rm -rf /etc/nginx/conf.d/; mkdir -p /etc/nginx/external
    —> Using cache
    —> 4759dc9499ff
    Step 6/13 : RUN sed -i 's/access_log.
    /access_log /dev/stdout;/g’ /etc/nginx/nginx.conf; sed -i ‘s/error_log.*/err
    or_log /dev/stdout info;/g’ /etc/nginx/nginx.conf; sed -i ‘s/^pid/daemon off;\npid/g’ /etc/nginx/nginx.conf
    —> Using cache
    —> 381e25635548
    Step 7/13 : ADD basic.conf /etc/nginx/conf.d/basic.conf
    —> Using cache
    —> be5aff0ad9c8
    Step 8/13 : ADD ssl.conf /etc/nginx/conf.d/ssl.conf
    —> Using cache
    —> d22ec231dc1f
    Step 9/13 : ADD server.conf /etc/nginx/conf.d/server.conf
    —> Using cache
    —> 2908cf301245
    Step 10/13 : ADD entrypoint.sh /opt/entrypoint.sh
    —> a3973b7daa6c
    Removing intermediate container 96f37cd872f3
    Step 11/13 : RUN chmod a+x /opt/entrypoint.sh
    —> Running in 6aed97756b3a
    —> cb1836482964
    Removing intermediate container 6aed97756b3a
    Step 12/13 : ENTRYPOINT /opt/entrypoint.sh
    —> Running in 5ed03b3f0a38
    —> 263099d3a6d2

  3. run the image upto running the entrypoint, in this case “cb1836482964”

    PS D:\peter\git\docker-nginx-ssl-secure> docker run -p 8000:80 -p 8443:443 -it cb1836482964 /bin/bash
    root@03ddc70eac1d:/#

  4. Go into image and run it manually:
    PS D:\peter\git\docker-nginx-ssl-secure> docker run -p 8000:80 -p 8443:443 -it cb1836482964 /bin/bash
    root@03ddc70eac1d:/# cd /opt
    root@03ddc70eac1d:/opt# ./entrypoint.sh
    bash: ./entrypoint.sh: /bin/bash^M: bad interpreter: No such file or directory

3 Likes

This post made me realise my issue was line endings on windows for a similar error output. Thanks so much!

That solved the problem. Initially, I made the git clone from Windows terminal and git use the Windows end-of-line characters for all the files.

I exec dos2unix docker-entrypoint.sh for all my entrypoints scripts (yeah, this project use several) and that fix the problem. docker-compose up was able to create and start all the containers.

Previously I convert all my scripts from bash format to sh but that didn’t work. I think the people that fix their problem that way was because they edit this files using a unix editor which automatically use the unix end-to-line format for save the changes.

2 Likes

Hi
I faced same problem. This is my Dockerfile, please check.

MAINTAINER Egor Vorozhtsov egor@vorozhtsov.com.ru

COPY ./ /var/www/zoomtivity
COPY ./ /var/www/zoomtivity-dev

RUN
echo "Project files are: " && ls -las /var/www/zoomtivity && ls -las /var/www/zoomtivity-dev &&
echo “Installing required Alpine packages…” && apk update && apk add --no-cache nodejs python make g++ git nano mc bash nasm autoconf automake libpng-dev libtool &&
echo “Removing default nginx config…” && rm /etc/nginx/conf.d/default.conf &&
echo “Installing global NPM packages…” && npm install -g gulp bower &&
echo “Installing local NPM packages…” && cd /var/www/zoomtivity && npm install &&
echo “Installing Bower packages…” && bower install --allow-root &&
echo “Building project…” && npm run build &&
echo “Configuring entrypoint…” && chmod +x ./entrypoint.sh &&
echo "Project files are: " && ls -las /var/www/zoomtivity

COPY nginx-vhost.conf /etc/nginx/conf.d/

WORKDIR /var/www/zoomtivity-dev

EXPOSE 80 81

ENTRYPOINT ["/var/www/zoomtivity/entrypoint.sh"]

Also, make sure to run dos2unix on script file whenever anyone edit anything on any kind of editor on windows…Even if script file is being created on Git Bash don’t forget to run dos2unix…

I have same error every time I’m trying to create container with go executable “from scratch”. I tried different dirs and entrypoints and file is never found by /bin/sh though I see it.

But building with CGO_ENABLED=0 flag helps:

$ GOARCH=amd64 CGO_ENABLED=0 GOOS=linux go build .
2 Likes

I had the same problem because the file had been edited on a Windows environment.
Launching this command resolved everything.

sed -i -e 's/\r$//' c <path_to_sh_file>