configuration->images->image->build->assembly->targetDir not working despite no dockerfile
See original GitHub issueUsing XML config (not Dockerfile), the plugin consistently builds an image containing the jar file under /maven/
directory, despite having targetDir
configured to /
Info
The docs say that targetDir
defines where the artifact is included, but I can’t get the plugin to accept my value, which is /
or the root.
I’ve tried both <targetDir></targetDir>
and <targetDir>/</targetDir>
It ignores the setting and places the jar in the /maven/
directory like this:
[INFO] DOCKER> Step 2/5 : COPY maven /maven/
I see in the docs there’s a comment that the targetDir
is ignored when a Dockerfile
is in use, but in this case there isn’t.
I can work around this by declaring <name>/</name>
which gives me
[INFO] DOCKER> Step 2/5 : COPY / ///
and the jar ends up in root.
Took me a while to discover that. I assume this would be instantly reproducible in any project. Here’s my XML:
<plugin>
<groupId>io.fabric8</groupId>
<artifactId>docker-maven-plugin</artifactId>
<configuration>
<logStdout>true</logStdout>
<outputDirectory>target/docker-build</outputDirectory>
<verbose>true</verbose>
<images>
<image>
<name>${gem.docker.registry}/tardis/tardis</name>
<build>
<tags>
<tag>latest</tag>
<tag>${git.branch}-${project.version}</tag>
<tag>${git.branch}-latest</tag>
</tags>
<entryPoint>
<exec>
<arg>java</arg>
<arg>-Dlogging.file=/logs/tardis.log</arg>
<arg>-Djava.security.auth.login.config=/config/login.conf</arg>
<arg>-Djava.security.krb5.conf=/config/krb5.conf</arg>
<arg>-jar</arg>
<arg>tardis.jar</arg>
</exec>
</entryPoint>
<from>frolvlad/alpine-oraclejdk8:slim</from>
<volumes>
<volume>/tmp</volume>
</volumes>
<runCmds>
<run>mkdir /logs</run>
</runCmds>
<assembly>
<targetDir></targetDir>
<inline>
<files>
<file>
<source>${project.build.directory}/${build.finalName}.${project.packaging}</source>
<outputDirectory>/</outputDirectory>
<destName>tardis.jar</destName>
</file>
</files>
<fileSet>
<directory>${project.build.directory}/config</directory>
<outputDirectory>/config</outputDirectory>
</fileSet>
</inline>
</assembly>
</build>
</image>
</images>
</configuration>
</plugin>
- d-m-p version : 0.22.1
- Maven version (
mvn -v
) : 3.3.9 - Docker version : 17.06.2
Issue Analytics
- State:
- Created 6 years ago
- Comments:8
Top Results From Across the Web
docker build exits successfully but no built image show up in ...
If I run docker image ls , though, the images do show up. Reinstalled Docker and the problem has gone away, for now...
Read more >docker build - Docker Documentation
In this scenario, there is no context. By default the docker build command will look for a Dockerfile at the root of the...
Read more >Docker - Container is not running - Stack Overflow
The container will always exit (stop running) if the command is non-blocking, this is the case with bash. In this case, a workaround...
Read more >9 Common Dockerfile Mistakes - Runnablog
We work with Dockerfiles on a daily basis; all the code we run for ... RUN apt-get update && \ apt-get install -y...
Read more >How to Debug and Fix Common Docker Issues - DigitalOcean
In this troubleshooting guide aimed at people new to Docker, you'll troubleshoot problems when building Docker images, resolve naming ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
You mapping were simply a bit off. I fixed it with this:
targetDir
to/
target/classes
as they are in src/main/resources.config
was mentioned twice: Ininclude
and in thedirectory
The snippet above works for me when running
mvn package
.Does it work for you, too ?
Right! Sorry, I’m new to docker. I thought that tar image was the same as the final docker image but obviously not. Trying to take shortcuts were there weren’t any 👎
I think what was also concerning me was the directory name ‘maven’ which just seemed wrong but now I realise it’s purely a temporary artifact of the plugin process.
Thanks for the help.