Closed
Description
Description
Unable to copy files in the target directory after tests have completed from container to host.
If this is already currently possible with the plugin, please let me know.
Info
- d-m-p version : 0.20.1
- Maven version (
mvn -v
) :
Apache Maven 3.3.9 (bb52d8502b132ec0a5a3f4c09453c07478323dc5; 2015-11-10T08:41:47-08:00)
Maven home: /Users/axiom/tools/JavaLib/main/build/apache-maven-3.3.9
Java version: 1.8.0_92, vendor: Oracle Corporation
Java home: /Library/Java/JavaVirtualMachines/jdk1.8.0_92.jdk/Contents/Home/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "mac os x", version: "10.10.5", arch: "x86_64", family: "mac"
-
Docker version : 17.03.1-ce, build c6d412e
-
If it's a feature request, what is your use case :
The use case I have is I'd like to copy the test results in my target directory in the post-integration-test phase from within the running container to the host.
Would be great if we could do something like this -
<executions>
<execution>
<id>copy</id>
<phase>post-integration-test</phase>
<configuration>
<fromContainerDirectory>./target/results/</fromContainerDirectory>
<toHostDirectory>./target/results</toHostDirectory>
</configuration>
<goals>
<goal>cp</goal>
</goals>
</execution>
</executions>
Metadata
Metadata
Assignees
Labels
No labels
Activity
testphreak commentedon Apr 5, 2017
I just realized that the solution I proposed above won't work in my case. Please disregard it.
How can I keep the container running after maven exits?
I would like to copy the files I need from the container before stopping the container.
Gengar003 commentedon Apr 5, 2017
I think the best solution is to use a docker volume mount to share the directory inside your container that contains the files you want, with the host machine.
The
d-m-p
documentation is here: https://dmp.fabric8.io/#start-volumesYour XML section might look like this:
Then, when your running container writes to its
target/results
directory, Docker will automatically write those files to your host machine'starget/results
directory, and when the container stops, those files will still be there for you.This will work with the existing docker-maven-plugin.
testphreak commentedon Apr 6, 2017
Thanks @Gengar003! That suggestion definitely put me on the right track!
NiasSt90 commentedon Mar 15, 2019
with volume-bind mounts you have another problem if your container is running under a $user account.
Because the $user account can't write into the
target/results
directory.Therefore a copy-goal will be useful.
In my case i want to measure code-coverage with a jacoco agent and pull the results out of the container to merge them with other jacoco-results.
Gengar003 commentedon Mar 15, 2019
I work around that by adding a
chmod a+rwx target/results
. I do that by having a script in my project that reads something like:testrun.sh
Then when I start a container that will write to
target/results
, I also:testrun.sh
testrun.sh
instead of the actual commandThis leaves the contents of the
target/results
directory world-accessible, so that no matter which user was used inside the container, the host will be able to read them.This does assume that the container you're running can
chmod
. If not, you could (although this starts to get clumsy) run another container after the first - something simple likealpine
- and just have it runchmod a+rwx target/results
as root.mabrarov commentedon Oct 20, 2020
This feature is still looking must have for me (I'm using builder image and need to copy built binaries from container to the maven project) because I use remote Docker instance and solution suggested in that comment doesn't work for such case while
docker cp
command works fine. Is it possible to reopen this feature request (issue) and implement it?Note: I cannot use multi-stage build due to old version of Docker (RHEL 7)
mabrarov commentedon Oct 25, 2020
I started implementation of this feature in master...mabrarov:copy_mojo.
Working example with usage of new version of docker-maven-plugin can be found in feature/docker-maven-plugin-copy-mojo branch of mabrarov/maven-docker-builder.
Volunteers wanted to complete and polish the changes. What's missing at the moment:
io.fabric8.maven.docker.config.handler.property.PropertyConfigHandler
class needs to be extended - need to implement loading ofio.fabric8.maven.docker.config.CopyConfiguration
from givenio.fabric8.maven.docker.config.handler.property.ValueProvider
.copy
goal.Here is one more (more complicated and closer to real project) sample using docker builder pattern and
copy
goal of d-m-p: https://github.com/mabrarov/redis-buildermabrarov commentedon Oct 26, 2020
@testphreak,
Could you please reopen this issue? I don't like duplicates, so prefer to not open a new issue, just because the old closed one was found not needed at the time it was closed.
Thank you.
testphreak commentedon Oct 26, 2020
@mabrarov reopened
mabrarov commentedon Nov 13, 2020
I opened pull request #1405. Though it lacks some of the things, but it already works for me in mabrarov/redis-builder.
mabrarov commentedon Nov 13, 2020
I suggest to look at mabrarov/redis-builder for those who wants to try
copy
goal implemented in pull request #1405. mabrarov/redis-builder contains travis/settings.xml Maven configuration file which points to Bintray repository where d-m-p built from the pull request #1405 can be found:qalinn commentedon Mar 1, 2021
When this will be released?
mabrarov commentedon Mar 1, 2021
Hi @qalinn,
Refer to #1412 (comment). I can work on pull request #1405 and complete it, but it doesn't look like it will be accepted before the mentioned cleanup.