- mongodb - 在 MongoDB mapreduce 中,如何展平值对象?
- javascript - 对象传播与 Object.assign
- html - 输入类型 ="submit"Vs 按钮标签它们可以互换吗?
- sql - 使用 MongoDB 而不是 MS SQL Server 的优缺点
文档说可以。
https://docs.docker.com/engine/reference/builder/
You can even use the .dockerignore file to exclude the Dockerfile and .dockerignore files. These files are still sent to the daemon because it needs them to do its job. But the ADD and COPY instructions do not copy them to the image.
但是当我将 dockerfile 放入 .dockerignore 时,我得到了
Sending build context to Docker daemon 1.646MB
Error response from daemon: Cannot locate specified Dockerfile: Dockerfile
最佳答案
是的,你可以;你甚至可以把 .dockerignore
本身扔进去!
您可能做了其他不正确的事情 - 可能在错误的目录中?
目录列表:
➜ ls -la
total 16
drwxr-xr-x 4 tj wheel 128 Nov 30 13:42 .
drwxrwxrwt 7 root wheel 224 Nov 30 13:42 ..
-rw-r--r-- 1 tj wheel 26 Nov 30 13:41 .dockerignore
-rw-r--r-- 1 tj wheel 28 Nov 30 13:42 Dockerfile
文件内容:
➜ cat .dockerignore
.dockerignore
Dockerfile
➜ test_docker_ignore cat Dockerfile
FROM ubuntu:16.04
ADD . .
构建一次;将 --no-cache
指定为详细:
➜ docker build -t test --no-cache .
Sending build context to Docker daemon 3.072kB
Step 1/2 : FROM ubuntu:16.04
---> 20c44cd7596f
Step 2/2 : ADD . .
---> 4d8ded297954
Successfully built 4d8ded297954
Successfully tagged test:latest
向 Dockerfile
添加一些内容并重建:构建将使用缓存,因为它忽略了对 Dockerfile
➜ echo "# A Test Comment" >> Dockerfile
➜ docker build -t test .
Sending build context to Docker daemon 3.072kB
Step 1/2 : FROM ubuntu:16.04
---> 20c44cd7596f
Step 2/2 : ADD . .
---> Using cache
---> 4d8ded297954
Successfully built 4d8ded297954
Successfully tagged test:latest
关于docker - dockerfile可以放在.dockerignore中吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47580298/
我的文件夹结构是这样的 - 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 来运行我的单元测试,在这种情况下,我希望包含
我是一名优秀的程序员,十分优秀!