title: AWS Lambda is Unable to find app.handler (Custom Docker Image)
body: <p>I want to deploy machine learning related code on AWS Lambda function as Docker image. Base Images provided by AWS for Python, don't allow to install using apt-get command. So I created custom docker image for AWS Lambda. Below is the code of my Dockerfile.</p>
  <p>ref: <a href="https://docs.aws.amazon.com/lambda/latest/dg/images-create.html#images-create-2" rel="noreferrer">Create an image from an alternative base image</a></p>
  <pre><code>ARG FUNCTION_DIR=&quot;/function&quot;
  
  FROM python:3.7-buster as build-image
  
  # Install aws-lambda-cpp build dependencies
  RUN apt-get update &amp;&amp; \
    apt-get install -y \
    g++ \
    make \
    cmake \
    unzip \
    libcurl4-openssl-dev
  
  RUN apt-get install -y python-opencv
  
  # Include global arg in this stage of the build
  ARG FUNCTION_DIR
  # Create function directory
  RUN mkdir -p ${FUNCTION_DIR}
  
  # Install the runtime interface client
  RUN pip install \
          --target ${FUNCTION_DIR} \
          awslambdaric
  
  FROM python:3.7-buster
  
  ARG FUNCTION_DIR
  # Set working directory to function root directory
  WORKDIR ${FUNCTION_DIR}
  
  # Copy in the build image dependencies
  COPY --from=build-image ${FUNCTION_DIR} ${FUNCTION_DIR}
  
  COPY requirements.txt /
  #RUN pip install -r /requirements.txt
  
  COPY .  /function
  ENV AWS_LAMBDA_RUNTIME_API=python3.7
  ENTRYPOINT [ &quot;/usr/local/bin/python&quot;, &quot;-m&quot;, &quot;awslambdaric&quot; ]
  CMD [ &quot;app.handler&quot; ]
  </code></pre>
  <p>My Folder structure is as below:</p>
  <pre><code>aws_lambda (Folder)
  - Dockerfile
  - app.py
  - function (Folder)
    - app.py
  - requirements.txt
  </code></pre>
  <p>When I run docker image, it shows error as below:</p>
  <pre><code>[ERROR] [1614258613176] LAMBDA_RUNTIME Failed to get next invocation. No Response from endpoint
  Traceback (most recent call last):
    File &quot;/usr/local/lib/python3.7/runpy.py&quot;, line 193, in _run_module_as_main
      &quot;__main__&quot;, mod_spec)
    File &quot;/usr/local/lib/python3.7/runpy.py&quot;, line 85, in _run_code
      exec(code, run_globals)
    File &quot;/function/awslambdaric/__main__.py&quot;, line 21, in &lt;module&gt;
      main(sys.argv)
    File &quot;/function/awslambdaric/__main__.py&quot;, line 17, in main
      bootstrap.run(app_root, handler, lambda_runtime_api_addr)
    File &quot;/function/awslambdaric/bootstrap.py&quot;, line 416, in run
      event_request = lambda_runtime_client.wait_next_invocation()
    File &quot;/function/awslambdaric/lambda_runtime_client.py&quot;, line 76, in wait_next_invocation
      response_body, headers = runtime_client.next()
  RuntimeError: Failed to get next
  Executing 'app.handler' in function directory '/function'
  </code></pre>
  <p>It seems it is unable to find /function directory but it is already there.</p>