1
votes

I created a docker image from a Dockerfile that has an environment to to run robot framework ready. I want to run a local file using the docker image and save the output of the test locally.

I know I can mount a file when I run an image and execute the test.

$ docker create -ti -v /path/to/file/testWithRobot/robottest.robot:/test/robottest.robot dc3dccfee60 robot test/robottest.robot

and then I know to save a file from docker is cp

I have 2 problems, I know that as soon as I stop that instance of docker the file gets removed, or better said when I start the mage again is a different instance of it. if I go inside the docker image mounting the file and running the tests I know the output files gets saved in the root

Output:  /output.xml
Log:     /log.html
Report:  /report.html

how do I save those files output.xml, log.html, and report.xml into the host. I am hoping I can use one command to run tests and save. I hope I explained well enough quite new to docker.

1

1 Answers

2
votes

Just run a container using:

docker run --name mytests -v /path/to/file/testWithRobot/robottest.robot:/test/robottest.robot dc3dccfee60 robot test/robottest.robot

and grab the contents using the name we set:

docker cp mytests:/output.xml .
docker cp mytests:/log.html .
docker cp mytests:/report.html .

Then you can delete the stopped container with:

docker rm mytest

Also, using this approach you won't face file permission and ownership issues.