简体   繁体   中英

Unable to delete the files given by Docker with mounted volume

I am running a python script that downloads CSV file using some API with a docker run command.

I am using one Dockerfile to install all the OS level dependencies and requirements.

Once the build is created, I am using the following command :

docker run -v $(pwd)/Reports:/usr/src/app/Reports --rm ImgName python myScript.py -d 2015-11-25

As mentioned in the above command I have one directory named Reports . I have mounted that directory with Docker. The Script Executes successfully and downloads a CSV file but The Problem is, The Downloaded CSV file is in read-only mode. I am not able to delete it. I need to have the flexibility to delete any file downloaded via script.

  • Note: When I run the script without docker ie python myScript.py I can read, write and delete the file.*

Any feedback will be appreciated.

you can run docker with your own user with the following command:

docker run --user $(id -u):$(id -g) ...

This will make the container run as your user and all the files will be created with the right owner (see docker run docs ). Don't forget to delete the files you already have there or create a new folder for this

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