Error accesing file in container

Hello, I am trying to run a image from an online source and the command looks like this

docker run -it --rm --user root --platform linux/amd64 \
-v $PWD/data:/input_BIDS:ro \
-v $PWD/preprocess_outputs/:/preprocess_outputs/:rw,Z \
-v $PWD/confound_correction_outputs:/confound_correction_outputs/ \
ghcr.io/cobralab/rabies:latest -p MultiProc --local_threads 4 --scale_min_memory 0.7 confound_correction preprocess_outputs/ confound_correction_outputs/ --conf_list WM_signal CSF_signal mot_6 --smoothing_filter 0.3

and I get the following error
FileNotFoundError: [Errno 2] No such file or directory: 'preprocess_outputs/rabies_preprocess.pkl'

I checked with

docker run -it --rm --user root --entrypoint /bin/bash --platform linux/amd64 \
-v $PWD/data:/input_BIDS:ro \
-v $PWD/preprocess_outputs/:/preprocess_outputs/ \
-v $PWD/confound_correction_outputs:/confound_correction_outputs/ \
ghcr.io/cobralab/rabies:latest

And the file and folder are where they are supposed to be in the container. The file is also present locally on the computer in the specified path.

Any insights?

So the file exists on your host at this path $PWD/preprocess_outputs/rabies_preprocess.pkl and is not expected to come from the image?

1 Like

Yes, that’s correct.

Then it should work as it is. Since you added :Z you must have a selinux based system, which should take care of selinux permissions as well. I don’t recall what the difference of :Z and :z is, but I do remember there is one.

My bad, I missed this is a relative and not and absolute path. Please share your Dockerfile, so we get an idea of what the WORKDIR is.

The problem seems to be in the command after the image name, where you have provided the output directories for the confound_correction subcommand using relative paths. Change the docker run command as follows:

docker run -it --rm --user root --platform linux/amd64 \
-v $PWD/data:/input_BIDS:ro \
-v $PWD/preprocess_outputs/:/preprocess_outputs/:rw,Z \
-v $PWD/confound_correction_outputs:/confound_correction_outputs/ \
ghcr.io/cobralab/rabies:latest -p MultiProc --local_threads 4 --scale_min_memory 0.7 confound_correction /preprocess_outputs/ /confound_correction_outputs/ --conf_list WM_signal CSF_signal mot_6 --smoothing_filter 0.3

Note the absolute paths after confound_correction. It should work then.

Thank you so much! I feel so dumb but that was it. I appreciate the help