将文件从容器复制到本地文件系统

时间:2020-04-06 19:17:19

标签: linux docker dockerfile linux-mint

历史

我的docker构建文件在我的Linux Mint VM上工作了多年,没有任何问题。当我需要重新创建VM时,我再次安装了所有内容,包括docker.io。 我为这个错误而战。我已经验证了最终文件位于docker映像内,但是当我尝试将其复制到容器外部的目录时,它表示该文件不存在。

我遵循了Exploring Docker container's file system上的指南,并验证了文件确实在容器中。

环境

  • Linux Mint 19(Tricia)
  • 通过snap安装的Docker

命令

docker cp {CONTAINER_ID}:/container_path /local_path

enter image description here

问题

stat /container_path: no such file or directory

enter image description here

1 个答案:

答案 0 :(得分:0)

解决方案就是通过 snap 卸载docker,然后通过 apt 重新安装。该解决方案仍然缺少更多信息,因为尚不知道问题是否真的由 snap 安装的docker版本引起。

sudo snap remove docker
sudo apt install docker.io