Table of Contents
How to fix- Execution build and start of goal io.fabric8:docker-maven-plugin:0.20.0:build failed: A tar file cannot include itself.
Introduction
When using fabric8:docker-maven-plugin I got this error and below fix helped me to fix this.
I assume this error occurs when you use dockerFileDir or dockerFile tag in maven plugin, it seems the tar file which is generated inside /target/docker/tmp/ is trying to include itself to create a docker image
FIX
The easiest fix for this problem is to create a file named .maven-dockerignore , this file is used for excluding files from builds
So adding a file .maven-dockerignore with the content
target/docker/
will avoid adding the target directory when creating a docker image
You can keep this file at Project root level like .gitignore, .dockerignore
1 2 3 4 5 6 7 | Project-ROOT |.maven-dockerignore |.gitignore |/src |/target |
This doesn’t help if your Dockerfile is in the target. If you place it in the:
${project.basedir}/Dockerfile
It just works (even without ignore file).