Docker遵循外部环境中的符号链接 [英] Docker follow symlink outside context
问题描述
parent_dir
- common_files
- file.txt
- dir1
- Dockerfile
- 符号链接 - > ../common_files
在上面的例子中,当我建立docker时,我想要将file.txt复制里面dir1。但是我不想保留多个file.txt副本。
根据此链接,与码头版本0.10 ,docker build必须
在容器的根目录中遵循符号链接进行ADD构建指令。
但是,当我使用Dockerfile中的任意一行生成时,我无法使用这样的文件或目录:
添加符号链接/路径/ dirname
或
添加符号链接/ file.txt /path/file.txt
mount选项不会为我解决(跨平台...)。
我尝试过 tar -czh。 | docker build -t
没有成功。
有没有办法让Docker遵循符号链接,并将common_files / file.txt复制到内置的容器?
这是不可能的,不会被实现。请查看有关github问题#1676 的讨论:
我们不允许这样做,因为它不重复。您的机器上的符号链接与我的机器不一样,并且相同的Dockerfile将产生两个不同的结果。还有/ etc / paasswd的符号链接会导致问题,因为它会链接主机文件而不是本地文件。
Yet another Docker symlink question. I have a bunch of files that I want to copy over to all my Docker builds. My dir structure is:
parent_dir
- common_files
- file.txt
- dir1
- Dockerfile
- symlink -> ../common_files
In above example, I want file.txt to be copied over when I docker build inside dir1. But I don't want to maintain multiple copies of file.txt. Per this link, as of docker version 0.10, docker build must
Follow symlinks inside container's root for ADD build instructions.
But I get no such file or directory when I build with either of these lines in my Dockerfile:
ADD symlink /path/dirname
or
ADD symlink/file.txt /path/file.txt
mount option will NOT solve it for me (cross platform...).
I tried tar -czh . | docker build -t
without success.
Is there a way to make Docker follow the symlink and copy the common_files/file.txt into the built container?
That is not possible and will not be implemented. Please have a look at the discussion on github issue #1676:
We do not allow this because it's not repeatable. A symlink on your machine is the not the same as my machine and the same Dockerfile would produce two different results. Also having symlinks to /etc/paasswd would cause issues because it would link the host files and not your local files.
这篇关于Docker遵循外部环境中的符号链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!