简体   繁体   中英

how to copy file from docker container to host using shell script?

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

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 (ie * 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM