1

I have created an image, which is an automation project. when I run container it executes all test inside the container then it generates the test report. I want to take this report out before deleting container.

    FROM maven:3.6.0-ibmjava-8-alpine

COPY ./pom.xml .

ADD ./src $HOME/src

COPY ./test-execution.sh /

RUN mvn clean install -Dmaven.test.skip=true -Dassembly.skipAssembly=true

ENTRYPOINT ["/test-execution.sh"]

CMD []

Below is shell file

 #!/bin/bash

echo parameters you provided : "$@" 

mvn test "$@"

cp api-automation:target/*.zip /Users/abcd/Desktop/docker_report
bugCracker
  • 3,656
  • 9
  • 37
  • 58
  • https://docs.docker.com/engine/reference/commandline/cp/ may help – lin Feb 25 '19 at 03:46
  • 1
    Another way to solve this (instead of copying files out of the container) is to `--volume` mount a directory from your host into the container where the output is produced. It's not clear from your question where this would be, but something along the lines of `--volume=/host/path/output:/container/path/output` – DazWilkin Feb 25 '19 at 03:57
  • Possible duplicate of [Copying files from Docker container to host](https://stackoverflow.com/questions/22049212/copying-files-from-docker-container-to-host) – David Maze Feb 25 '19 at 11:32

1 Answers1

0

You will want to use the docker cp command. See here for more details.

However, it appears docker cp does not support standard unix globbing patterns (i.e * in your src path).

So instead you will want to run:

docker cp api-automation:target/ /Users/abcd/Desktop/docker_report

However, then you will have to have a final step to remove all the non-zip files from your docker_report directory.

Jack Gore
  • 3,874
  • 1
  • 23
  • 32