aws / aws-lambda-base-images

Apache License 2.0
646 stars 107 forks source link

Docker build error with exec: "/bin/sh": stat /bin/sh: no such file or directory #156

Open codeloversa opened 2 months ago

codeloversa commented 2 months ago

I have build the base image for python3.9 by the instructions in the readme.

but when I reference the image to build another docker images, there is a build error:

" > [2/8] RUN mkdir -p /function:
0.278 runc run failed: unable to start container process: exec: "/bin/sh": stat /bin/sh: no such file or directory
------
Dockerfile_aws_lambda:10
--------------------
   8 |     
   9 |     # Copy function code
  10 | >>> RUN mkdir -p ${FUNCTION_DIR}
  11 |     COPY ./lambda_function.py ${FUNCTION_DIR}
  12 |     COPY ./Pipfile* ${FUNCTION_DIR}
--------------------
ERROR: failed to solve: process "/bin/sh -c mkdir -p ${FUNCTION_DIR}" did not complete successfully: exit code: 1
"

FYI, here is my docker file


"# Define custom function directory
ARG FUNCTION_DIR="/function"

FROM python3.9:local

# Include global arg in this stage of the build
ARG FUNCTION_DIR

# Copy function code
RUN mkdir -p ${FUNCTION_DIR}
COPY ./lambda_function.py ${FUNCTION_DIR}
COPY ./Pipfile* ${FUNCTION_DIR}
COPY ./pip.conf /etc/pip.conf

WORKDIR ${FUNCTION_DIR}

# Install the pipevn
RUN python -m pip install pipenv==2022.4.21

#Install the dependencies and create virtual environment at currently folder
RUN PIPENV_PIPFILE=./Pipfile PIPENV_VENV_IN_PROJECT=1 pipenv install

ENTRYPOINT [ "/.venv/bin/python", "-m", "awslambdaric" ]

# Set the CMD to your handler (could also be done as a parameter override outside of the Dockerfile)
CMD [ "lambda_function.handler" ]"

Could you give some advice?