.dockerignore: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
 
(One intermediate revision by the same user not shown)
Line 12: Line 12:


⚠️ If a file or directory matches one of the <code>.dockerignore</code> patterns, it will not be possible to add it to the image with <code>COPY</code>.
⚠️ If a file or directory matches one of the <code>.dockerignore</code> patterns, it will not be possible to add it to the image with <code>COPY</code>.
<syntaxhighlight lang='text'>
=> ERROR [2/4] COPY ./common/docker/VERSION-base /automation                0.0s
------
> [2/4] COPY ./common/docker/VERSION-base /automation:
------
failed to compute cache key: "/common/docker/VERSION-base" not found: not found
</syntaxhighlight>
Also, the documentation says the semantics is similar to <code>[[.gitingore]]<code>'s, but if a directory name is specified, it is not examined recursively. For example, if <code>.dockerignore</code> contains:
<syntaxhighlight lang='text'>
venv/
</syntaxhighlight>
then a directory <code>./src/main/python/venv</code> is not ignored, the full path relative to the docker context root must be specified:
<syntaxhighlight lang='text'>
src/main/python/venv/
</syntaxhighlight>

Latest revision as of 05:23, 11 May 2022

External

Internal

Overview

Contains files and directories from the build context that won't be uploaded to the docker host when the image is built. .dockerignore supports exclusion patterns similar to .gitignore.

⚠️ If a file or directory matches one of the .dockerignore patterns, it will not be possible to add it to the image with COPY.

 => ERROR [2/4] COPY ./common/docker/VERSION-base /automation                0.0s
------
 > [2/4] COPY ./common/docker/VERSION-base /automation:
------
failed to compute cache key: "/common/docker/VERSION-base" not found: not found

Also, the documentation says the semantics is similar to .gitingore's, but if a directory name is specified, it is not examined recursively. For example, if .dockerignore contains:

venv/

then a directory ./src/main/python/venv is not ignored, the full path relative to the docker context root must be specified:

src/main/python/venv/