Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

standard_init_linux.go:211: exec user process caused "no such file or directory"?

Dockerfile

FROM python:3.7.4-alpine

ENV PYTHONUNBUFFERED 1
ENV PYTHONDONTWRITEBYTECODE 1
ENV LANG C.UTF-8
MAINTAINER "[email protected]"


RUN apk update && apk add postgresql-dev gcc musl-dev
RUN apk --update add build-base jpeg-dev zlib-dev
RUN pip install --upgrade setuptools pip

RUN mkdir /code
WORKDIR /code

COPY requirements.txt /code/
RUN pip install -r requirements.txt
COPY . /code/

#CMD ["gunicorn", "--log-level=DEBUG", "--timeout 90", "--bind", "0.0.0.0:8000", "express_proj.wsgi:application"]
ENTRYPOINT ["./docker-entrypoint.sh"]

docker-entrypoint.sh

#!/bin/bash

# Prepare log files and start outputting logs to stdout
touch /code/gunicorn.log
touch /code/access.log
tail -n 0 -f /code/*.log &

# Start Gunicorn processes
echo Starting Gunicorn.
exec gunicorn express_proj.wsgi:application \
    --name express \
    --bind 0.0.0.0:8000 \
    --log-level=info \
    --log-file=/code/gunicorn.log \
    --access-logfile=/code/access.log \
    --workers 2 \
    --timeout 90 \
    "$@"

Getting Error standard_init_linux.go:211: exec user process caused "no such file or directory" Need help. Some saying to use dos2unix(i do not know hoe to use it.)

like image 868
Nurbek Batyrzhan uulu Avatar asked Apr 20 '20 17:04

Nurbek Batyrzhan uulu


People also ask

Why is there no such file or directory in Exec user process?

2019-01-31T16:00:10.908327548Z standard_init_linux.go:195: exec user process caused "no such file or directory" This is normally due to the Linux system not understanding one of your scripts you are trying to execute. In Windows, text file’s end of line sequence is normally CR+LF (Carriage Return[0x0D] + Line Feed[0x0A]).

Why am I getting “no such file or directory” error in Linux?

If you have ever build Linux containers on Windows with custom shell scripts, you may have ran into this issue error before: 2019-01-31T16:00:10.908327548Z standard_init_linux.go:195: exec user process caused "no such file or directory" This is normally due to the Linux system not understanding one of your scripts you are trying to execute.

Why can’t I execute my Linux script?

This is normally due to the Linux system not understanding one of your scripts you are trying to execute. In Windows, text file’s end of line sequence is normally CR+LF (Carriage Return[0x0D] + Line Feed[0x0A]). In Linux and modern Macs (OS X+), the EOL sequence is just LF.

Why is there no such file or directory in dockerfile?

The problem: a wrong file format caused by Windows. Let’s fix this! Docker outputs all build steps when creating an image based on a Dockerfile. The “exec user process caused „no such file or directory“” issue occurred when executing a shell script.


Video Answer


2 Answers

The "shebang" line at the start of a script says what interpreter to use to run it. In your case, your script has specified #!/bin/bash, but Alpine-based Docker images don't typically include GNU bash; instead, they have a more minimal /bin/sh that includes just the functionality in the POSIX shell specification.

Your script isn't using any of the non-standard bash extensions, so you can just change the start of the script to

#!/bin/sh
like image 113
David Maze Avatar answered Oct 18 '22 03:10

David Maze


This can also happen if the line endings of the script is wrong, i.e. \r\n instead of \r

this can be checked using the file path/to/script.sh command which tells if the script has CR-LF line endings

If its a one off script dos2unix can be used to change it to \r\n to \n

If its a git repository setting the autocrlf option to input would work

How to change line-ending settings

like image 4
tejas Avatar answered Oct 18 '22 03:10

tejas