gpt4 book ai didi

docker - 在构建过程中在Docker镜像中移动文件

转载 作者:行者123 更新时间:2023-12-02 19:27:22 25 4
gpt4 key购买 nike

Docker: How to copy a file from one folder in a container to another?

基本上是相同的问题,但我想在构建过程中移动文件

我现在正在这样做:

COPY . /app
RUN mv backend/backend/local_settings.py.default backend/backend/local_settings.py

但是,这不起作用。它以某种方式损坏了文件系统。当我转到文件夹时,这就是我键入 ls时发生的情况
bash-4.4# ls -liah
ls: ./local_settings.py.default: No such file or directory
total 28
555172697 drwxr-xr-x 1 root root 24 Mar 6 15:37 .
582753791 drwxr-xr-x 1 root root 65 Dec 11 16:57 ..
580798835 -rw-r--r-- 1 root root 0 Oct 3 20:27 __init__.py
580798836 drwxr-xr-x 1 root root 42 Mar 6 15:35 __pycache__
580798844 -rw-r--r-- 1 root root 3.7K Dec 11 16:57 settings.py
555172698 -rw-r--r-- 1 root root 2.8K Feb 8 19:11 local_settings.py
580798847 -rw-r--r-- 1 root root 3.6K Dec 11 16:57 urls.py
580798848 -rw-r--r-- 1 root root 392 Oct 3 20:27 wsgi.py

如果我键入 vim backend/并点击TAB以自动完成,则文件将显示在此处!
bash-4.4# vim backend/
__init__.py settings.py local_settings.py.default wsgi.py
__pycache__/ local_settings.py urls.py

最重要的是,当我使用 docker run运行命令时,出现错误:

设置文件导入local_settings。
Traceback (most recent call last):
05-Mar-2019 16:20:10 File "/app/backend/backend/settings.py", line 139, in <module>
05-Mar-2019 16:20:10 from .local_settings import *
05-Mar-2019 16:20:10 ImportError: No module named 'backend.local_settings'

该文件已存在,但未被识别!当我以交互方式进入容器时,该命令有效。

编辑
Docker信息
Server Version: 18.09.2
Storage Driver: overlay2
Backing Filesystem: xfs
Supports d_type: false
Native Overlay Diff: true
Kernel Version: 3.10.0-957.5.1.el7.x86_64

统计local_settings文件
bash-4.4# stat local_settings.py.default
stat: can't stat 'local_settings.py.default': No such file or directory
bash-4.4# stat local_settings.py
File: local_settings.py
Size: 2816 Blocks: 8 IO Block: 4096 regular file
Device: 2fh/47d Inode: 555172698 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root)
Access: 2019-03-05 20:17:27.000000000
Modify: 2019-02-08 19:11:12.000000000
Change: 2019-03-05 19:37:35.000000000

最佳答案

您正在将overlay2存储驱动程序与不支持d_type的支持文件系统一起使用。这就是overlay2 pretty mad in its behavior。根据official Docker documentation,由于以下问题,根本不支持这种配置:

The following backing filesystems are supported:

...

xfs (RHEL 7.2 and higher), but only with d_type=true enabled.


在Docker守护程序的日志中还应该有关于此配置错误的警告。
您必须 recreate the backing file system,使其具有 ext4支持的 xfsd_type

关于docker - 在构建过程中在Docker镜像中移动文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55026876/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com