gpt4 book ai didi

docker - .dockerignore 提到的文件不会被忽略

转载 作者:IT老高 更新时间:2023-10-28 12:47:38 26 4
gpt4 key购买 nike

我在 Dockerfile:

ENV DATARATOR_HOME /usr/local/share/datarator
RUN mkdir -p $DATARATOR_HOME
COPY . $DATARATOR_HOME

.dockerignore文件:

/Gemfile.lock
/coverage
/spec
*.bundle
*.so
*.o
*.a
mkmf.log
*.swp
/.*
/tmp
/log

但是,一旦在构建的容器中显示文件,我也可以看到那些应该被忽略的文件:

/usr/local/share/datarator # ls -lha
total 128
drwxr-xr-x 10 root root 4.0K Mar 29 21:01 .
drwxr-xr-x 4 root root 4.0K Mar 29 21:00 ..
drwxr-xr-x 2 root root 4.0K Mar 29 21:01 .bundle
-rw-rw-r-- 1 root root 24 Mar 29 20:37 .coveralls.yml
-rw-rw-r-- 1 root root 81 Mar 29 20:37 .dockerignore
drwxrwxr-x 8 root root 4.0K Mar 29 20:37 .git
-rw-rw-r-- 1 root root 85 Mar 29 20:37 .gitignore
-rw-rw-r-- 1 root root 1.2K Mar 29 20:37 .travis.yml
-rw-rw-r-- 1 root root 509 Mar 29 20:37 .vimrc
-rw-rw-r-- 1 root root 959 Mar 29 20:37 Dockerfile
-rw-rw-r-- 1 root root 94 Mar 29 20:37 Gemfile
-rw-r--r-- 1 root root 2.7K Mar 29 21:01 Gemfile.lock
-rw-rw-r-- 1 root root 343 Mar 29 20:37 Guardfile
-rw-rw-r-- 1 root root 1.0K Mar 29 20:37 LICENSE.txt
-rw-rw-r-- 1 root root 71 Mar 29 20:37 Procfile
-rw-rw-r-- 1 root root 14.8K Mar 29 20:37 README.md
-rw-rw-r-- 1 root root 198 Mar 29 20:37 Rakefile
drwxrwxr-x 2 root root 4.0K Mar 29 20:37 bin
drwxrwxr-x 2 root root 4.0K Mar 29 20:37 config
-rw-rw-r-- 1 root root 97 Mar 29 20:37 config.ru
-rw-r--r-- 1 root root 16.0K Mar 29 21:01 datarator-0.0.1.gem
-rw-rw-r-- 1 root root 1.7K Mar 29 20:37 datarator.gemspec
drwxrwxr-x 4 root root 4.0K Mar 29 20:37 lib
drwxrwxr-x 2 root root 4.0K Mar 29 20:37 log
drwxrwxr-x 3 root root 4.0K Mar 29 20:37 spec
drwxrwxr-x 2 root root 4.0K Mar 29 20:37 tmp

如何实现忽略 .dockerignore 文件中提到的所有内容?

最佳答案

.dockerignore规则遵循filepath/#Match .

尝试(用于测试)Gemfile.lock 而不是 /Gemfile.lock

并检查您的 .dockerignore 文件中的 eol(行尾)字符是否为 unix 样式,而不是 Windows 样式。

显然,(docker 1.10,2016 年 3 月)使用以 / 开头的规则,例如 /xxx(或 /.*)is not well supported .

关于docker - .dockerignore 提到的文件不会被忽略,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36295418/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com