我想在docker中运行一些测试,因此在现有的容器中加载我的更新代码,以节省重建映像的所有时间。
对于这个问题,docker cp似乎是一个理想的解决方案--但它似乎不会覆盖我现有的文件,下面是我做的一个简短的测试。我在本地创建了一个新文件,将其复制到我的容器中,在本地更改了该文件,然后再次复制,并比较了在容器上更改前后文件的内容。
>> 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)正如我们所看到的,这些更改尚未被复制。复制整个文件夹时也会发生同样的情况(我实际上打算这样做)。Docker Docs说:DEST_PATH exists and is a file the destination is overwritten with the source file’s contents,所以我想知道我在这里做错了什么。
容器的Docker镜像基于ubuntu:16.04。
这里真的很感谢你的帮助。
发布于 2018-03-08 21:34:12
Docker最近发布了一个更新,修复了这个问题。我在更新后运行了相同的过程(新版本是17.12.0-ce-mac55),现在覆盖工作了。
这可能是macOS High Sierra和新的文件系统APFS的问题。更新提到它修复了一个问题。
https://stackoverflow.com/questions/48582911
复制相似问题