我试图为python应用程序创建一个Docker映像,并获得以下错误
=> ERROR [7/9] RUN chown -R myuser:mygrp app/csv/ resources/datafeed.id 0.4s
------
> [7/9] RUN chown -R myuser:mygrp app/csv/ resources/datafeed.id:
#11 0.325 chown: cannot access 'app/csv/': No such file or directory
#11 0.325 chown: cannot access 'resources/datafeed.id': No such file or directory
------
executor failed running [/bin/sh -c chown -R myuser:mygrp app/csv/ resources/datafeed.id]: exit code: 1我的Dockerfile如下:
FROM python:3.8-slim-buster
WORKDIR app/
COPY requirements.txt .
RUN pip install -r requirements.txt
RUN groupadd -r -g 2000 mygrp && useradd -u 2000 -r -g mygrp myuser
RUN chown -R myuser:mygrp app/csv/ resources/datafeed.id
RUN chmod -R 700 app/csv/
COPY app .
USER myuser
CMD [ "python", "./main_async.py" ]另外,我的项目结构也有以下文件:
Project-folder/app/csv
Project-folder/resources/datafeed.id发布于 2022-06-11 03:21:50
你的命令顺序不对。
WORKDIR app/
...
RUN chown -R myuser:mygrp app/csv/ resources/datafeed.id
RUN chmod -R 700 app/csv/
COPY app .RUN 命令将运行容器中的任何<process>。在当前的Dockerfile中,您是尚未在容器中复制的chown-ing文件。
先做COPY。
确保将正确的参数传递给COPY,这通常应该是:
COPY <source on the host> <dest on the container>因此,如果您正在从Project-folder目录构建:
WORKDIR app
...
# Copy files from the host into the container.
# Since `WORKDIR` is already set, this copies
# all files in the current directory on
# host to under WORKDIR
COPY . .
RUN chown -R myuser:mygrp app/csv/ resources/datafeed.id
RUN chmod -R 700 app/csv/https://stackoverflow.com/questions/72581372
复制相似问题