- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我在子目录中有 docker-compose 的小配置,其中包含 Dockerfiles 和 .dockerignore 文件。我不明白为什么我的图像在构建后包含所有内容,即使我在 .dockerignore 中有一些要忽略的项目。这是我所拥有的
docker-compose.yml
docker
├── app
│ ├── Dockerfile
│ └── .dockerignore
└── web
├── Dockerfile
├── nginx.conf
└── .dockerignore
.dockerignore 示例:
**/.dockerignore
docker-compose.yml
log
**/log
../../log
我只是按如下方式运行:
docker-compose up -d --build --no-cache
以上都没有被忽略..我做错了什么?
docker-compose version 1.23.2, build 1110ad01
为应用服务添加 Dockerfile(请参阅 docker-compose)。 Docker-compose 使用 ROR app 和 nginx 打包了两个镜像。对于两个 dockerfile,我都有 dockerignore。所以我的理解是我可以说出我想要的。但事实并非如此。如何忽略包中的某些文件?或者我应该把我的 Dockerfile 和 dockerignore 放在不同的路径中,因为构建只在上下文中工作..我很困惑。
FROM ruby:2.4.1
RUN apt-get update -qq && apt-get install -y build-essential libpq-dev nodejs imagemagick
# Configuring main directory
RUN mkdir -p /var/www/example.com
WORKDIR /var/www/example.com
# Setting env up
ENV RAILS_ENV='production'
ENV RACK_ENV='production'
# Adding gems
COPY Gemfile Gemfile
COPY Gemfile.lock Gemfile.lock
RUN bundle install --jobs 20 --retry 5 --without development test
# Adding project files
COPY . .
EXPOSE 3000
CMD ["bundle", "exec", "puma", "-C", "config/puma.rb"]
所以我认为
COPY . .
首先检查 .dockerignore .. 没有?
最佳答案
你有 2 Dockerfiles
,它们有各自的上下文。在每个上下文(文件夹)中,您都有 .dockerignore
,这是正确的。但是.dockerignore
不在构建上下文之外工作,这意味着使用 ../../
是错的。
我猜你是假设这些文件适用于 docker
文件夹,但实际上它们适用于 docker/app
和 docker/web
分别。
构建过程如下:
第一 docker cli
打包上下文(如果未明确指定,则包含 Dockerfile
的文件夹)并将其发送到 docker daemon
.没什么外 此文件夹已发送。它是为 COPY
明确写的命令,用于将上下文项放入容器:
The
src
path must be inside the context of the build; you cannot COPY ../something /something, because the first step of a docker build is to send the context directory (and subdirectories) to the docker daemon.
.dockerignore
, 忽略的文件
排除在外 包装前。
关于Docker-compose 和 .dockerignore,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53945934/
我的文件夹结构是这样的 - myapp -- public -- other_dirs -- docker // contain all the Dockerfiles and configurati
怎么样.dockerignore处理异常? 例如,我想忽略 src/ 中的所有内容。目录,除了 src/web/public . 我试过了... .git src !src/web/public 似乎
考虑以下典型 python项目结构: fooproject - main.py - src/ - test/ - logs/ - Dockerfile - .dockerign
我正在用 docker 构建一个 Django 应用程序。 我想知道对于 Django 或使用 docker 的一般开发工作,.dockerignore 中通常包含哪些文件。 我暂时想到以下几点: .
我有一个 .dockerignore 文件,但是对于一个用例,我想在命令行中指定 .dockerignore 的内容,例如: docker build --ignore="node_modules"
我有一个如下所示的文件夹结构。我想忽略 .git 的所有子文件夹(及其所有内容),但包括直接在 .git 中的所有文件(例如 FETCH_HEAD 和 HEAD)。 如何在 .dockerignore
我不太明白 .dockerignore 是如何工作的。是否打算像下面这样使用: 首先我在其中添加一些内容,例如 *.md 然后我把这个.dockerignore放入容器中。 然后我运行并进入容器。 我
我在 Dockerfile: ENV DATARATOR_HOME /usr/local/share/datarator RUN mkdir -p $DATARATOR_HOME COPY . $DA
如何在 docker 镜像的所有子目录中排除 python 生成的文件,如 *.pyc? 我在上下文目录的根目录下添加了.dockerignore: # Ignore generated files
我找不到很多 .dockerignore 文件应该是什么样子的示例。 使用 puppet 在 docker 容器上安装一些包会导致图像从 600MB 爆炸到 3GB。我正在尝试使用 .dockerig
我有以下docker文件: FROM my-reg:7678/py:v11 copy . /app/ # more commands... 我想复制.的内容,但不包含2个子文件夹:.git和data我
我有一个简单的 .dockerignore 文件,其中包含以下内容: .git/ .idea/ venv/ 我的 docker-compose.yml 文件挂载卷: version: "3" serv
我试图阻止我的 Drupal Composer 项目中的文件和文件夹列表包含在 docker 镜像中,但作为意外的副作用,它还排除了一些未在 .dockerignore 中明确定义的文件夹。这是我正在
在 official documentation我在 .dockerignore 中找不到有关内容区分大小写的信息文件。 我们可以控制 .dockerignore 文件中内容的区分大小写吗? 例如:我
不使用 .dockerignore文件,有没有办法在通过以下命令构建图像时跳过构建上下文的发送? docker build . 换句话说,我希望构建上下文为空,而无需手动创建一个空目录,然后将其传递给
我在子目录中有 docker-compose 的小配置,其中包含 Dockerfiles 和 .dockerignore 文件。我不明白为什么我的图像在构建后包含所有内容,即使我在 .dockerig
我正在尝试从我的 Docker 镜像中排除项目所有目录中的所有隐藏文件(以点开头)。 排除.git和.gitingore:.git* 要排除所有 .keep 文件:**/.keep 有效 对于所有隐藏
在同一个目录中,我有两个 Dockerfiles,我想为每个目录添加一个单独的 .dockerignore。 目前,我有: Dockerfile.npm Dockerfile.nginx 但是我可以有
我试图否定 .dockerignore 中的模式。 Globbing 是使用 Go 的 filepath.Match 规则完成的。检查后source , 看来我们可以使用 ^ 字符来否定一个模式。 .
我曾经在 .dockerignore 中列出 tests 目录,这样它就不会被包含在我用来运行 Web 服务的镜像中。 现在我正在尝试使用 Docker 来运行我的单元测试,在这种情况下,我希望包含
我是一名优秀的程序员,十分优秀!