Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Docker cp not overwriting files

Tags:

docker

I would like to run a few tests inside docker and therefore load my updated code inside an existing container to save on rebuilding the image all the time.

docker cp seems to be an ideal solution for this – but it does not seem to overwrite my existing files, here is a short test I did. I created a new file locally, copied it into my container, changed the file locally, copied it again and compared the contents of the file before and after changing on the container.

>> touch test123
>> docker cp test123 my-container:/
>> docker exec my-container cat /test123
(empty)
>> vi test123
(add some text on my local machine)
>> docker cp test123 my-container:/
>> docker exec my-container cat /test123
(empty)
>> vi test123
(check if the content was saved –> yes)

As we can see the changes have not been copied. The same happens when copying the whole folder (what I actually plan to do). The Docker Docs says: DEST_PATH exists and is a file the destination is overwritten with the source file’s contents, so I am wondering what I am doing wrong here.

The Docker image of the container is based on ubuntu:16.04.

Help is really appreciated here.

like image 726
Deproblemify Avatar asked Feb 02 '18 12:02

Deproblemify


1 Answers

Docker released an update recently that fixed the issue. I ran the same procedure after updating (new version is 17.12.0-ce-mac55) and the overwriting worked now.

It was probably an issue with macOS High Sierra and the new file system APFS. The update mentioned that it fixed an issue Disk/image corruption with large numbers of files.

like image 122
Deproblemify Avatar answered Nov 08 '22 05:11

Deproblemify