Docker entrypoint.sh not found

Viewed 3031

Following the instructions as outlined to deploy Duo CloudMapper to AWS environment and getting an error

Docker File

FROM python:3.7-slim as cloudmapper

LABEL maintainer="https://github.com/0xdabbad00/"
LABEL Project="https://github.com/duo-labs/cloudmapper"

WORKDIR /opt/cloudmapper
ENV AWS_DEFAULT_REGION=us-east-1 

RUN apt-get update -y
RUN apt-get install -y build-essential autoconf automake libtool python3.7-dev python3-tk jq awscli

COPY cloudmapper/. /opt/cloudmapper
COPY entrypoint.sh /opt/cloudmapper/entrypoint.sh

# Remove the demo data
RUN rm -rf /opt/cloudmapper/account-data/demo

# Install the python libraries needed for CloudMapper
RUN cd /opt/cloudmapper && pip install -r requirements.txt


ENTRYPOINT /opt/cloudmapper/entrypoint.sh

Now building the docker image

C:\> docker build -t cloudmapper .

When I run the docker using the below command I get an error

C:/> docker run -t cloudmapper

Error

/bin/sh: 1: /opt/cloudmapper/entrypoint.sh: not found

Verified that the file exists in the appropriate location screenshot attached

Using Docker on Windows 10

Image in the dockerfile is python:3.7-slim

1 Answers

Assuming the images are removed and replaced with text and the question doesn't get closed.

bash can return "file not found" when

  • the entrypoint shell script is not marked executable
  • the hash bang in the entrypoint shell script points to a binary that does not exist
  • the shell script actually does not exist.

You can fix the first problem by ensuring you use the new --chmod flag to ensure the executable bit is set:

COPY --chmod=0755 *.sh /opt/cloudmapper/
ENTRYPOINT ["/opt/cloudmapper/entrypoint.sh"]

ps. This integrated COPY --chmod only works with buildkit enabled builds, so you might need to force buildkit, or split the chmod into a separate explicit RUN step.

The 2nd issue can be dealt with by ensuring the first line of entrypoint.sh uses sh rather than bash if you are using a lightweight base image like alpine:

#!/bin/sh
set -e
# etc

Also, if on Windows especially, ensure ALL files, especially the entrypoint .sh file, are set to utf-8 encoding with lf style line endings. As linux doesn't understand the cr, it will try to execute /bin/sh<cr> as the shell which clearly doesn't exist.

-- edited to add cr-lf revelation.

Related