How to Delete Files in a Bind Directory?

Hi
i’ve got a bind directory where the client puts in some files for my app to process.
During development, I have my own test files in that directory.

Question: How can I get Docker to ignore those files…as .dockerignore does not seem to work for bind directories

In my Dockerfile I tried removing them with
RUN rm -rf client/data/* # trying to target the original directory used for dev
RUN rm -rf client/data

and

RUN rm -rf /my_app/client/data/* # trying to target the final bind directory
RUN rm -rf /my_app/client/data

None of the above seems to work.

Much appreciation in advance
Graham

It is not clear what you mean by

Is it mounted to the container or to the host before you run docker build?

If it is mounted to the container

There is no way to do that. You can only change permissions to make sure not everyone can access everything, but you can’t bind mount a folder and not mount something in that folder.

You can’t do anything to solve it in a Dockerfile, since that only runs during the build process so before you mount anything. Even if it could run when you want it to run, it would remove the files on the host which you probably not want to do.

If it is mounted to the host before running docker build

It shouldn’t matter whether the files were mounted from somewhere else or existed in the project root directly.

Related topics

Since you started a similar topic before, I guess it is related to that issue