Docker ignore target directories created by mave using .dockerignore file
It should be same as we do it in .gitignore
, so to ignore target folder just use target/
.
None of the answers above seemed to work for me (docker version 20.10.5). In the end, the following worked out OK:
.dockerignore:
**/target/
Here is an excerpt from the .dockerignore documentation:
Beyond Go’s filepath.Match rules, Docker also supports a specialwildcard string ** that matches any number of directories (includingzero). For example, **/*.go will exclude all files that end with .gothat are found in all directories, including the root of the buildcontext.