这是我的Dockerfile
:
FROM debian:latest
LABEL MAINTAINER DINESH
LABEL version="1.0"
LABEL description="First image with Dockerfile & DINESH."
RUN apt-get clean
RUN apt-get update
RUN apt-get install -qy git
RUN apt-get install -qy locales
RUN apt-get install -qy nano
RUN apt-get install -qy tmux
RUN apt-get install -qy wget
RUN apt-get install -qy python3
RUN apt-get install -qy python3-psycopg2
RUN apt-get install -qy python3-pystache
RUN apt-get install -qy python3-yaml
RUN apt-get -qy autoremove
# ** ERROR IS BELOW **
ADD .bashrc /root/.bashrc
ADD .profile /root/.profile
ADD app /app
RUN locale-gen C.UTF-8 && /usr/sbin/update-locale LANG=C.UTF-8
ENV PYTHONIOENCODING UTF-8
ENV PYTHONPATH /app/
当我运行此命令
docker build -t myimage .
时,下面给出了错误。"Step 17/20 : ADD app /app
ADD failed: stat /var/lib/docker/tmp/docker-builder687980062/.bashrc: no such file or directory"
我已授予上述给定路径许可,但未解决。请让我知道如何解决。
最佳答案
首先,请确保文件位于正确的目录中。错误提示no such file or directory
请代替添加尝试使用COPY为我工作
COPY .bashrc /root/
COPY .profile /root/
还要使文件位于源位置和目标位置是正确的。
另外,按照最佳做法,您可以合并行并执行单个命令
RUN apt-get update -yq \
&& apt-get install -y python3-dev build-essential -yq \
&& apt-get install curl -yq \
&& pip install -r requirements.txt \
&& apt-get purge -y --auto-remove gcc python3-dev build-essential
关于docker - Docker镜像构建在文件添加时失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62214849/