Skip to main content

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

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

 

Related Posts

Leave a Reply

Your email address will not be published. Required fields are marked *

Bitnami