【问题标题】:Exclude folders in .dockerignore排除 .dockerignore 中的文件夹
【发布时间】:2017-08-10 20:09:28
【问题描述】:

我试图阻止将我的 Drupal 作曲家项目中的文件和文件夹列表包含在 docker 映像中,但作为一个意外的副作用,它也排除了一些未在 @987654322 中明确定义的文件夹@。这是我正在使用的文件:

# root files
.gitignore
.gitmodules
.travis.yml
.gitlab-ci.yml
docker-compose.yml
LICENSE
phpunit.xml.dist
README.md

# folders
.c9
.git
backups/
vendor/
web/core/
web/modules/contrib/
web/profiles/
web/themes/contrib/

# web files
web/.csslintrc
web/.editorconfig
web/.eslintrc
web/.eslintignore
web/.gitattributes
web/.htaccess

# web sites files
web/sites/development.services.yml
web/sites/example.settings.local.php
web/sites/example.sites.php

# web sites default files
web/sites/default/files/
web/sites/default/default.services.yml
web/sites/default/settings.local.php

<all combinations of lines below, one at a time>

我已经在底部定义了我想要包含的文件夹,我已经尝试了下面我能想到的所有组合。到目前为止,运气不好,没有东西可以尝试。

# don't ignore comes last
!web/themes/custom
!web/libraries

# don't ignore comes last
!web/themes/custom/
!web/libraries/

# don't ignore comes last
!web/themes/custom/*
!web/libraries/*

# don't ignore comes last
*!web/themes/custom/*
*!web/libraries/*

我还尝试取消注释每个文件夹,但 web/themes/customweb/libraries 文件夹仍然没有出现在我的 docker 映像中。我还有一个包含这些文件夹的.gitignore 文件。也许这是造成这种奇怪行为的原因?

任何帮助将不胜感激。

【问题讨论】:

  • 我无法从您提供的详细信息中重现这一点。请按照this answer 中的步骤,将您的结果与构建的输出以及在您的构建目录中运行的find . 一起发布。
  • 问题已解决,请看下面的答案。

标签: docker dockerfile


【解决方案1】:

我正在使用 Gitlab CI 构建映像,但我忘记了我的 git 存储库没有我试图复制的文件夹。只有我的本地开发环境有这些文件夹。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-09-17
    • 2019-07-14
    • 2021-08-27
    • 2013-10-27
    • 1970-01-01
    • 2015-06-11
    • 2013-08-03
    • 2017-10-12
    相关资源
    最近更新 更多