List data in Dockerfile running with -v

Dear all,

I run a docker which starte a python script. This python scripts needs certain paths. But something with the paths must be wrong.
I know that I can have a look into the created docker with: sudo docker run -it neurolab/abnormalityindex:1.1 /bin/bash
but not when I mount with -v.
So how can I see in the docker container when I run it which files are inlcuded when using -v. Something like: ls -R /data

docker run -it \
-v /Users/neurolab/Desktop/Pipeline_test2/:/data \
-v /Users/neurolab/Desktop/Pipeline_test2/:/output
-v /Users/neurolab/Desktop/Pipeline_test2/:/data/sub-1 \
-v /Users/neurolab/Desktop/Programmes/freesurfer/license.txt/:/opt/freesurfer/license.txt \
-v /Users/neurolab/Deskto/Pipeline_test2_ciftify/:/data/ciftify
-v “/Volumes/Extreme SSD/final_ciftify_GSP_concat_ICA-AROMA/:/data/reference”
neurolab/abnormalityindex:1.1 python Pipeline_main2.py /data /data/sub-1 1 /opt/freesurfer/license.txt /ICA-AROMA-master/ /data/ciftify /data/ciftify /data/reference 1 1 1 1 1 1 1 /output

I’m not sure why it would not work in combination with -v. (I’d guess it’s because you actually already run another command, some specific Python script, in the 2nd example, which you’re not doing in the first? So, it’s unrelated to using -v then.)

However, you don’t need to set it up when starting the container. Instead, start it as usual, and then use another docker exec to get to the running container. Something like:

docker exec -it <container-name> /bin/bash

See docker exec | Docker Documentation.

Thanks a lot for your quick reply. With your suggested command it does not find the container, but I can execute it

docker run -it \
-v /Users/neurolab/Desktop/Pipeline_test2/:/data \
-v /Users/neurolab/Desktop/Pipeline_test2/:/output 
-v /Users/neurolab/Desktop/Pipeline_test2/:/data/sub-1 \
-v /Users/neurolab/Desktop/Programmes/freesurfer/license.txt/:/opt/freesurfer/license.txt \
-v /Users/neurolab/Deskto/Pipeline_test2_ciftify/:/data/ciftify 
-v “/Volumes/Extreme SSD/final_ciftify_GSP_concat_ICA-AROMA/:/data/reference” 
neurolab/abnormalityindex:1.1 /bin/bash

But no folder /data or /output shows up then in the docker container?

Are you sure the new command is not giving you errors? I see curly quotes in the last -v line. Also, it seems the 3rd and 6th lines are missing the trailing \ to concatenate the lines? And one line uses Deskto rather than Desktop. So, is this the exact command you ran?

Aside:

As you did not specify --name some-name in the 2nd example in your first post, Docker will assign a random name, which you should be able to see when using docker ps. But of course the command from your last post should do to investigate as well.

Sorry this is the correct command which I used:

docker run -it \

-v /Users/neurolab/Desktop/Pipeline_test2/:/data \

-v /Users/neurolab/Desktop/Pipeline_test2/:/output \

-v /Users/neurolab/Desktop/Pipeline_test2/:/data/sub-1 \

-v /Users/neurolab/Desktop/Stephan/Programmes/freesurfer/license.txt/:/opt/freesurfer/license.txt \

-v /Users/neurolab/Desktop/Pipeline_test2_ciftify/:/data/ciftify \

-v "/Volumes/Extreme SSD/final_ciftify_GSP_concat_ICA-AROMA/:/data/reference" \

neurolab/abnormalityindex:1.1 /bin/bash

Where do you mean should I specify --name some-name? And where should I put docker ps to see the created folders in the docker container?

You don’t need to do that to fix your problem. But I was responding to your “With your suggested command it does not find the container”, whatever that means exactly. If you want to use, say, docker exec -it my-container-name /bin/bash to connect to a running container named “my-container-name”, then you’ll need to use --name my-container-name in the docker run command that you use to start your application. If you do not use --name then just type docker ps in another command prompt to see the list of generated names, and use that name in the docker exec command. (The Docker Desktop GUI will show the name as well, and when hovering a running container’s name it will even offer a “CLI” option to open a prompt in that running container.)

Also, as docker ps is really basic Docker knowledge, I very much suggest following the interactive tutorial at Overview of the get started guide | Docker Docs.

What exactly does that mean?

As far as I can see, your command should work (even despite the trailing / in /Stephan/Programmes/freesurfer/license.txt/). I’d try with one line of -v ... at a time and see when things no longer work.

The following debugging with busybox works for me, on a Mac running Linux containers:

mkdir ~/Desktop/Pipeline_test2
touch ~/Desktop/Pipeline_test2/my-file.txt
mkdir -p ~/Desktop/Stephan/Programmes/freesurfer
touch ~/Desktop/Stephan/Programmes/freesurfer/license.txt
mkdir ~/Desktop/Pipeline_test2_ciftify
touch ~/Desktop/Pipeline_test2_ciftify/my-ciftify.txt

docker run --rm -it \
-v ~/Desktop/Pipeline_test2/:/data \
-v ~/Desktop/Pipeline_test2/:/output \
-v ~/Desktop/Pipeline_test2/:/data/sub-1 \
-v ~/Desktop/Stephan/Programmes/freesurfer/license.txt/:/opt/freesurfer/license.txt \
-v ~/Desktop/Pipeline_test2_ciftify/:/data/ciftify \
-v "/Volumes/Macintosh HD/Users/Shared/:/data/reference" \
busybox

…with in the busybox prompt:

/ # ls -la /data
total 4
drwxr-xr-x    6 root     root           192 Jul 14 15:44 .
drwxr-xr-x    1 root     root          4096 Jul 14 15:44 ..
drwxr-xr-x    3 root     root            96 Jul 14 15:44 ciftify
-rw-r--r--    1 root     root             0 Jul 14 15:44 my-file.txt
drwxrwxrwt    5 root     root           160 Jul  3 11:20 reference
drwxr-xr-x    6 root     root           192 Jul 14 15:44 sub-1

/ # ls -la /output
total 4
drwxr-xr-x    6 root     root           192 Jul 14 15:44 .
drwxr-xr-x    1 root     root          4096 Jul 14 15:51 ..
drwxr-xr-x    2 root     root            64 Jul 14 15:44 ciftify
-rw-r--r--    1 root     root             0 Jul 14 15:44 my-file.txt
drwxr-xr-x    2 root     root            64 Jul 14 15:44 reference
drwxr-xr-x    2 root     root            64 Jul 14 15:44 sub-1

/ # ls -la /data/sub-1
total 0
drwxr-xr-x    6 root     root           192 Jul 14 15:44 .
drwxr-xr-x    6 root     root           192 Jul 14 15:44 ..
drwxr-xr-x    2 root     root            64 Jul 14 15:44 ciftify
-rw-r--r--    1 root     root             0 Jul 14 15:44 my-file.txt
drwxr-xr-x    2 root     root            64 Jul 14 15:44 reference
drwxr-xr-x    2 root     root            64 Jul 14 15:44 sub-1

/ # ls -la /opt/freesurfer/license.txt
-rw-r--r--    1 root     root             0 Jul 14 15:44 /opt/freesurfer/license.txt

/ # ls -la /data/ciftify
total 0
drwxr-xr-x    3 root     root            96 Jul 14 15:44 .
drwxr-xr-x    6 root     root           192 Jul 14 15:44 ..
-rw-r--r--    1 root     root             0 Jul 14 15:44 my-ciftify.txt

/ # ls -la /data/reference
total 0
drwxrwxrwt    5 root     root           160 Jul  3 11:20 .
drwxr-xr-x    6 root     root           192 Jul 14 15:44 ..
<redacted>

/ # exit

(Scroll above code block to see all. And yes, mapping the same source to both /data and /data/sub-1 yields confusing output of the ls /data/sub-1 command.)

So I guess we’ll need to know more about the neurolab/abnormalityindex:1.1 image you’re using, and about the exact results for your ls commands.

Great, thanks a lot. It works now!