简体   繁体   中英

How to access generated files inside Docker image

So basically I have a python script that will write to a file once it is done running. How do I access this file? My end goal is to run the docker image on jenkins and then read the xml file that the python script generates.

 FROM python:3 ADD WebChecker.py / ADD requirements.txt / ADD sites.csv / RUN pip install -r requirements.txt CMD [ "python", "./WebChecker.py" ] 

That is my Dockerfile. I have a print("Finished") in there and it is printing so that means everything is working fine. It's just now I need to see my output.xml file.

You should have done it now by following above comments. In case if you still stuck, you may give a try as below:

Build:

docker build -t some_tag_name_to_your_image .

After build is completed, you may run a container and get the xml file as below:

1. Write output file to bind volume

Run your container as below:
docker run -d --rm --name my_container \\ -v ${WORKSPACE}:/path/to/xml/file/in/container \\ some_tag_name_to_your_image

Once the xml file generated, that will be available at the Jenkins-host:${WORKSPACE}

Notes:
${WORKSPACE} is an env variable set by Jenkins. Read more env-vars here
Read more about bind mount here

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