Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Docker copy file to host, after entrypoint execution

I have a docker file, that creates an image of my automation project that runs maven to execute some tests, how can I copy something from docker back to host AFTER those tests were executed ? Simply adding copy command in Dockerfile, after ENTRYPOINT will start copying straight after executing first command from entrypoint command.

Dockerfile:

ADD src /usr/src/app/src/
ADD features /usr/src/app/features/
ADD Config.properties /usr/src/app/

ENTRYPOINT ["sh", "/usr/local/bin/mvn-entrypoint.sh"]

mvn-entrypoint.sh

#!/bin/bash

echo "PLEASE WAIT..."
sleep 10
echo "STARTING AUTOMATION TESTING"
mvn verify -q -D browser=chrome
exec "$@"
like image 274
Matthewek Avatar asked Dec 08 '25 06:12

Matthewek


1 Answers

Use docker volume.

Run your container with docker run -v host/path:/temp imageID cp mvnOutputPath /temp

cp mvnOutputPath /temp is the docker command CMD, executed by exec "$@" in your entrypoint

like image 128
Siyu Avatar answered Dec 09 '25 21:12

Siyu