Reputation: 2827
Docker: How to copy a file from one folder in a container to another?
Same question basically, but I'd like to move the file within the build process
I'm doing this right now:
COPY . /app
RUN mv backend/backend/local_settings.py.default backend/backend/local_settings.py
This is not working, though. It is corrupting the file system somehow. When I go to the folder this is what it happens when I type 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
If I type vim backend/
and tap TAB for autocompletion the file shows there!
bash-4.4# vim backend/
__init__.py settings.py local_settings.py.default wsgi.py
__pycache__/ local_settings.py urls.py
On top of that, when I run my command with docker run
I get the error:
The settings file import the 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'
The file is there, but it is not being recognized! When I go to the container in interactive mode, the command works.
EDIT Docker info
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
Stat on local_settings files
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
Upvotes: 1
Views: 402
Reputation: 3758
You are using overlay2
storage driver with backing file system which does not support d_type
. This makes overlay2
pretty mad in its behavior. According to official Docker documentation, such configuration is simply not supported because of issues like this:
The following backing filesystems are supported:
...
xfs
(RHEL 7.2 and higher), but only withd_type=true
enabled.
There also should be a warning about this misconfiguration in the log of your Docker daemon.
You have to recreate the backing file system, making it either ext4
or xfs
with d_type
support.
Upvotes: 1