How to delete files on host created by container?

I use a docker command line to share filesystem like this:

docker run --rm -it -v /home/docker/vol/svn/:/data/svn/ devbase /bin/bash

Then compile the codes in the container and it will generate some binary files in volume

I want to delete binary files on host but i don’t have root permission

Unfortunately, files created by container belong to the root user

So how can i delete those binary files on host without root OR is there a way to modify file permission in container?

Thanks a lot

Can you chmod the file permissions after generating the binary files?

If you had a running container you could use

docker exec -it devbase rm /data/svn/path/to/file

Cheers,
Tom

2 Likes

I think I have the same problem. Something went wrong with an npm install in my node docker container. Files were created in a node_modules/.bin that have ??? as metadata when i ls -la. I cannot chown or chmod them. If I try to delete them back on my Windows host, I get a permissions error.

How can I get rid of these files?

I have the same problem. The only way I’ve found to remove the files is to reboot my machine. It hasn’t been clear to me what causes the files to show as ???, but once they do I have to reboot to fix it. I’ve seen it happen to a bunch of different files and types of files.

If there is a way to remove them without rebooting, that would be great. It would also be helpful if there was a way to find them so at least I would know the root cause of random issues that pop up.

Thanks

You can do something as described here:

docker exec <container> rm -rf <YourFile>

Or here:

    docker exec 765511b2869e sh -c 'rm -rf /backup/*.zip'