amazon-web-services - 在 Docker 中访问文件时出现权限被拒绝错误

标签 amazon-web-services docker testing dockerfile

我正在尝试在 AWS Sagemaker 上部署模型并使用以下 docker 文件:

FROM ubuntu:16.04

#MAINTAINER Amazon AI <sage-learner@amazon.com>


RUN apt-get -y update && apt-get install -y --no-install-recommends \
 wget \
 python3.5-dev \
 gcc \
 nginx \
 ca-certificates \
 libgcc-5-dev \
 && rm -rf /var/lib/apt/lists/*

# Here we get all python packages.
# There's substantial overlap between scipy and numpy that we eliminate by
# linking them together. Likewise, pip leaves the install caches populated which uses
# a significant amount of space. These optimizations save a fair amount of space in the
# image, which reduces start up time.
RUN wget https://bootstrap.pypa.io/3.3/get-pip.py && python3.5 get-pip.py && \
    pip3 install numpy==1.14.3 scipy lightfm scikit-optimize pandas==0.22.0 flask gevent gunicorn && \
    rm -rf /root/.cache

# Set some environment variables. PYTHONUNBUFFERED keeps Python from buffering our standard
# output stream, which means that logs can be delivered to the user quickly. PYTHONDONTWRITEBYTECODE
# keeps Python from writing the .pyc files which are unnecessary in this case. We also update
# PATH so that the train and serve programs are found when the container is invoked.

ENV PYTHONUNBUFFERED=TRUE
ENV PYTHONDONTWRITEBYTECODE=TRUE
ENV PATH="/opt/program:${PATH}"

# Set up the program in the image
COPY lightfm /opt/program
WORKDIR /opt/program

docker容器构建成功,但是当我写如下命令时:

docker run XYZ train

在我的本地甚至 Sagemaker 上,我收到以下错误:

standard_init_linux.go:207: exec user process caused "permission denied"

在 docker 文件中,我正在复制一个名为 Lightfm 的文件夹,其中有一个名为“train”的文件。

有人能帮忙吗?

我的 DOCKER 构建的输出:

$ docker build -t lightfm .
Sending build context to Docker daemon  41.47kB
Step 1/9 : FROM ubuntu:16.04
 ---> 5e13f8dd4c1a
Step 2/9 : RUN apt-get -y update && apt-get install -y --no-install-recommends  wget  python3.5-dev  gcc  nginx  ca-certificates  libgcc-5-dev  && rm -rf /var/lib/apt/lists/*
 ---> Using cache
 ---> 14ae3a1eb780
Step 3/9 : RUN wget https://bootstrap.pypa.io/3.3/get-pip.py && python3.5 get-pip.py &&     pip3 install numpy==1.14.3 scipy lightfm scikit-optimize pandas==0.22.0 flask gevent gunicorn &&     rm -rf /root/.cache
 ---> Using cache
 ---> 5a2727e27385
Step 4/9 : ENV PYTHONUNBUFFERED=TRUE
 ---> Using cache
 ---> 43bf8c5e8414
Step 5/9 : ENV PYTHONDONTWRITEBYTECODE=TRUE
 ---> Using cache
 ---> 7d2c45d61cec
Step 6/9 : ENV PATH="/opt/program:${PATH}"
 ---> Using cache
 ---> f3cc6313c0d9
Step 7/9 : COPY lightfm /opt/program
 ---> ad929ba84692
Step 8/9 : WORKDIR /opt/program
 ---> Running in a040dd0bab03
Removing intermediate container a040dd0bab03
 ---> 8f53c5a3ba63
Step 9/9 : RUN chmod 755 serve
 ---> Running in 5666abb27cd0
Removing intermediate container 5666abb27cd0
 ---> e80aca934840
Successfully built e80aca934840
Successfully tagged lightfm:latest
SECURITY WARNING: You are building a Docker image from Windows against a non-Windows Docker host. All files and directories added to build context will have '-rwxr-xr-x' permissions. It is recommended to double check and reset permissions for sensitive files and directories.

最佳答案

假设 train 是您要运行的可执行文件,请授予它 exec 权限。在 COPY lightfm/opt/program 行之后,添加 RUN chmod +x/opt/program/train

关于amazon-web-services - 在 Docker 中访问文件时出现权限被拒绝错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57377852/

相关文章:

java - 亚马逊 beantalk tomcat 基本身份验证

amazon-web-services - AWS ECS上的Kafka,如何在没有已知实例的情况下处理advertised.host?

dockerfile 不更新容器

javascript - 测试 for-in 循环有什么意义吗?

javascript - 测试 :id routes

java - 我们可以在 TestNG 中将两个注释(IRetryAnalyzer 和优先级)类型作为一个类型传递吗

java - 如何解决加载 Mirth Connect Administrator 时弹出的 java 错误

python - AWS ElastiCache 描述 CacheClusters

amazon-web-services - AWS CDK : Adding new stack not working (not showing up)

mongodb - Docker添加其他参数以启动