简体   繁体   English

未找到 Docker entrypoint.sh

[英]Docker entrypoint.sh not found

Following the instructions as outlined to deploy Duo CloudMapper to AWS environment and getting an error按照概述将 Duo CloudMapper 部署到 AWS 环境并收到错误的说明

Docker File Docker 文件

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现在构建 docker 映像

C:\> docker build -t cloudmapper .

When I run the docker using the below command I get an error当我使用以下命令运行 docker 时出现错误

C:/> docker run -t cloudmapper

Error错误

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

Verified that the file exists in the appropriate location验证文件是否存在于适当的位置附上截图

Using Docker on Windows 10在 Windows 10 上使用 Docker

Image in the dockerfile is python:3.7-slim dockerfile 中的图像为 python:3.7-slim

Assuming the images are removed and replaced with text and the question doesn't get closed.假设图像被删除并替换为文本并且问题没有关闭。

bash can return "file not found" when bash 可以返回“找不到文件”时

  • the entrypoint shell script is not marked executable入口点 shell 脚本未标记为可执行
  • the hash bang in the entrypoint shell script points to a binary that does not exist入口点 shell 脚本中的 hash bang 指向不存在的二进制文件
  • the shell script actually does not exist. shell 脚本实际上不存在。

You can fix the first problem by ensuring you use the new --chmod flag to ensure the executable bit is set:您可以通过确保使用新的 --chmod 标志来确保设置了可执行位来解决第一个问题:

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.此集成的 COPY --chmod 仅适用于启用 buildkit 的构建,因此您可能需要强制 buildkit,或将 chmod 拆分为单独的显式RUN步骤。

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:如果您使用像 alpine 这样的轻量级基础映像,则可以通过确保entrypoint.sh的第一行使用 sh 而不是 bash 来解决第二个问题:

#!/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.此外,如果特别是在 Windows 上,请确保所有文件,尤其是 entrypoint.sh 文件,都设置为 utf-8 编码,并带有 lf 样式的行尾。 As linux doesn't understand the cr, it will try to execute /bin/sh<cr> as the shell which clearly doesn't exist.由于 linux 不理解 cr,它会尝试执行/bin/sh<cr>作为 shell 显然不存在。

-- edited to add cr-lf revelation. -- 编辑添加 cr-lf 启示。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM