【问题标题】:Docker - Copy files from external locations on host machine into containersDocker - 将文件从主机上的外部位置复制到容器中
【发布时间】:2019-09-17 12:58:03
【问题描述】:

我需要在几种不同的操作系统类型上测试我的团队软件,我决定利用 Docker 来提供帮助。

我基本上想要做的是在某个中心位置签出我们的回购树。然后我想要几个不同操作系统类型的容器,它们在构建时都将 git 树复制到它们的根文件夹中。这样做的原因是我希望所有容器始终测试相同的软件补丁。

这是我设置 docker 容器目录结构的方法:

docker_containers/
    GIT_TREE/
    container_ubuntu14/
        git_tree/ (symbolic link to ../GIT_TREE)
        build.sh  (docker build commands specific to this os type)
        Dockerfile
        run.sh (docker run commands for use post build)
    container_ubuntu18/
        git_tree/ (symbolic link to ../GIT_TREE)
        build.sh  (docker build commands specific to this os type)
        Dockerfile
        run.sh (docker run commands for use post build)
    container_centos7/
        git_tree/ (symbolic link to ../GIT_TREE)
        build.sh  (docker build commands specific to this os type)
        Dockerfile
        run.sh (docker run commands for use post build)

如您所见,每种容器类型都有一个符号链接,指向我的 git 树检出的主目录。对于每个实例,在Dockerfile 中有一行COPY git_tree /。我尝试将符号链接复制到新容器的根目录,但每次都会收到以下错误:

COPY failed: stat /home/user/docker_fs/tmp/docker-builder474024999/home/user/docker_containers/GIT_TREE: no such file or directory

【问题讨论】:

  • IIRC Docker 无论如何都拒绝从当前目录树之外复制内容。一个简单但粗略的解决方法是将您想要的内容临时复制到ADDCOPY 到当前目录树中。
  • 用你的布局,也许构造每个Dockerfile,这样你就可以docker run subdir

标签: docker ubuntu centos dockerfile redhat


【解决方案1】:

应该是 GIT_TREE 而不是 GIT-TREE?

【讨论】:

  • 不,对不起,这个名字无关紧要,我只需要一个占位符来为我的项目命名
  • 您的错误日志显示它正在寻找的路径是 GIT-TREE,而您的实际文件夹名称应该是 GIT_TREE,可能是您的代码中某处输入了错误的路径。
  • GIT_TREE 这个名字只是我随机输入的,因为我不想写我的项目的实际名称。我认为问题在于 docker 无法正确访问链接
猜你喜欢
  • 2014-03-29
  • 2015-07-08
  • 1970-01-01
  • 2014-05-19
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多