Here is a plugin defintion:
<plugin>
<groupId>io.fabric8</groupId>
<artifactId>docker-maven-plugin</artifactId>
<version>0.26.0</version>
<configuration>
<registry>000000000000.dkr.ecr.us-east-1.amazonaws.com/my-aws-registy-0000000000000:latest</registry>
<images>
<image>
<name>my-image</name>
<build>
<tags>
<tag>000000000000.dkr.ecr.us-east-1.amazonaws.com/my-aws-registy-0000000000000:latest</tag>
</tags>
<dockerFileDir>${project.build.directory}</dockerFileDir>
</build>
</image>
</images>
</configuration>
</plugin>
After resource phase Dockerfile
is copied to target
. When I try to invoke docker:build
goal I got:
[ERROR] Failed to execute goal io.fabric8:docker-maven-plugin:0.25.2:build (default-cli)
on project my-project: Execution default-cli of goal
io.fabric8:docker-maven-plugin:0.25.2:build failed: A tar file cannot include itself. -> [Help 1]
What I want - just simple execute docker build -t .
command via maven without any plugin packaging/building/assembly goals (or subgoals).
Yesp this plugin have a lot of possibilities, but I need just docker build without any tar
archiving and this have to be done from target
folder.
How to do that???
What docker does is to assemble all files that should be added to the image into a tar file and send this to the docker daemon for building the image.
The plugin creates this tar file in a sub-directory of the target
folder (which is your ${project.build.directory}
). Taking the target folder as base for the docker plugin implicitly includes the tar file that is created, therefore the error that you get.
What I was doing in a project is to copy all the files that should be added to the image (ADD
/COPY
) and the Dockerfile
to a ${project.build.directory}/dockerfile
directory and then create the image using <dockerFileDir>${project.build.directory}/dockfile</dockerFileDir>