Docker Community Forums

Share and learn in the Docker community.

Invalid mount path: mount path must be absolute error (solved)

Hi, all,

I’m new to Docker and I have encountered my first error that I can’t seem to overcome or troubleshoot through. I need to use a Bind mount to mount a file I’m working with inside a container, but every rendition of my file path I try results in the following error:

docker: Error response from daemon: invalid mount config for type "bind": invalid mount path: 'C:\QIIME2\Indiana\Run2' mount path must be absolute. See 'docker run --help'.

This is the command I’m running:

docker run --rm -t -i --mount type=bind,source=C:\QIIME2\Indiana\Run2,target=C:\QIIME2\Indiana\Run2 bwawrik/qiime -i IndFun_S1_L001_R1_001.fastq -o seq_counts.txt

Approaching the issue using a Volume in place of a Bind results in a similar error:

docker run --rm -t -i -v C:\QIIME2\Indiana\Run2 bwawrik/qiime -i IndFun_S1_L001_R1_001.fastq -o seq_counts.txt     

docker: Error response from daemon: invalid volume spec "C:\\QIIME2\\Indiana\\Run2": invalid volume specification: 'C:\QIIME2\Indiana\Run2': invalid mount config for type "volume": invalid mount path: '\QIIME2\Indiana\Run2' mount path must be absolute. See 'docker run --help'.

I was led to this approach from a tutorial I’m working through for a different container (where I don’t have this issue) that has me define my Volume as C:\QIIME2\Indiana\Run2:/data. When I include the “:/data” bit at the end of the above command, Docker executes the command and runs the container script, which then fails to locate my file:

docker run --rm -t -i -v C:\QIIME2\Indiana\Run2:/data bwawrik/qiime -i IndFun_S1_L001_R1_001.fastq -o seq_counts.txt

Error in No filepaths match pattern/name 'IndFun_S1_L001_R1_001.fastq'. All patterns must be matched at least once.

I’m not entirely sure what “:/data” does, so that is part of my problem. When I include that end to my file path when using a Bind instead of a Volume, I still get the same error:

docker run --rm -t -i --mount source=C:\QIIME2\Indiana\Run2:/data,target=C:\QIIME2\Indiana\Run2:/data bwawrik/qiime -i IndFun_S1_L001_R1_001.fastq -o seq_counts.txt 
docker: Error response from daemon: invalid mount config for type "volume": invalid mount path: 'C:\QIIME2\Indiana\Run2:/data' mount path must be absolute. See 'docker run --help'.

For reference, here is the command from the other container tutorial that executes perfectly with no file path errors and takes the files located in the folder and generates new files in the same folder on my C: drive:

docker run --rm -t -i -v C:\QIIME2\Tutorials\qiime2-importing-tutorial:/data qiime2/core:2017.9 qiime tools import --type EMPSingleEndSequences --input-path emp-single-end-sequences --output-path emp-single-end-sequences.qza

I’ve spent three days trying to wrap my head around this issue and I’m at a complete loss. Any help with this would be greatly appreciated. Again, I’m pretty new to all of this so any information, such as why that :/data changes my error message or how to execute this properly, is welcome.


and the source path exists, right?

some other examples show removing the : and changing the \ to /

-v //c/QIIME2/Indiana/Run2:/data

it seems the parser is confused by the C:
invalid mount path: '\QIIME2\Indiana\Run2

The source path does exist. Running -v //c/QIIME2/Indiana/Run2:/data gave me the same error as -v C:\QIIME2\Indiana\Run2:/data:

Error in No filepaths match pattern/name 'IndFun_S1_L001_R1_001.fastq'. All patterns must be matched at least once.

And sticking it into my Bind Mount command yields another error:

docker run --rm -t -i --mount type=bind,source=//c/QIIME2/Indiana/Run2:/data,target=//c/QIIME2/Indiana/Run2:/data bwawrik/qiime -i IndFun_S1_L001_R1_001.fastq -o seq_counts.txt

docker: Error response from daemon: invalid mount config for type "bind": bind source path does not exist.

that is the -i parm, not the -v parm
-i IndFun_S1_L001_R1_001.fastq

note that the docker runtime is NOT in ‘this’ (the current directory) folder…

also, please show the output of dir C:\QIIME2\Indiana\Run2 on the host


I think that issue is stemming from my working folder not mounting to the container. The IndFun_S1_L001_R1_001.fastq file is contained within C:\QIIME2\Indiana\Run2 and no matter how I code it (e.g C:\QIIME2\Indiana\Run2\IndFun_S1_L001_R1_001.fastq; %cd%IndFun_S1_L001_R1_001.fastq, etc.), I run into that error. I was under the impression that despite the container script being in Python, my Windows path should be fine since it was mounted to the container.

Here’s the output you requested:

C:\QIIME2\Indiana\Run2>dir C:\QIIME2\Indiana\Run2
 Volume in drive C is Windows
 Volume Serial Number is D661-BCB2

 Directory of C:\QIIME2\Indiana\Run2

11/13/2017  05:06 PM    <DIR>          .
11/13/2017  05:06 PM    <DIR>          ..
10/18/2017  08:13 AM     2,297,782,630 IndFun_S1_L001_R1_001.fastq
10/17/2017  08:58 PM     2,309,980,676 IndFun_S1_L001_R2_001.fastq
11/16/2017  04:06 PM               890 QIIME2 Indiana Code.txt
11/13/2017  10:32 AM             9,130 Run 2 metadata.xlsx
               4 File(s)  4,607,773,326 bytes
              2 Dir(s)  110,330,286,080 bytes free

ok, on the first error…

there are a bunch of parms, -v -rm -t
then the name of the image bwawrik/qiime
then the command (and its parms to pass to the container) -i IndFun_S1_L001_R1_001.fastq -o seq_counts.txt

that happens INSIDE the container…
so the path inside would be /data/IndFun_S1_L001_R1_001.fastq
and the runtime is sitting at the root NOT the volume location…

i see u mentioned not knowing what /data meant

the -v is source_path (host):container_path (inside container)

net, you have to tell docker, where in the containers file system the host volume should be located (mounted in linux terms)

Ah! I think I understand now. Essentially, I need to write my mounting as: -v source_path (In Windows terms):container_path (In Linux terms) and then the python script should be able to locate the file I’m specifying? i.e. tell Docker to mount this path like that inside the container? I’ll give that a shot.

Do you have any idea why the --mount command doesn’t think my file path is absolute when I use type=bind? This will probably become a non-issue if I get the volume mounting to work like we just discussed, but it will still nag at me…

Also, thanks so much for your help. I’ve really learned a lot from all this!

well, one would expect that if the container is running Windows, then the container_path should be in windows terms.
I ’ think’ the base drive is C: and /data would be C:/data by default…

for debugging I think if you remove your python script and its parms and use cmd instead, then u will get a command prompt from the container where you can use DIR to look around…and test your script…

just catching up on docker from a couple years ago and haven’t seen the --mount/bind approach… so not really sure what its does

well, the syntax for bind is a verbose kind of -v

–mount type= , source=, target=

as such the source and target paths must be real paths…

you specified

that makes the source path not valid… (because u didn’t know at the time what the :/data meant on -v)…

so your bind should have been (to match the -v version)

–mount type=bind,source=//c/QIIME2/Indiana/Run2,target=/data
and source=c:\QIIME2\Indiana\Run2
might work as well. (note the ‘:’ is used as a source/target separator in -v syntax, so its hard for the parser to figure out what u mean)

1 Like

Okay, thanks to your help I’ve finally gotten it to work! The source/target separator was throwing the whole script off. Additionally, all my file paths needed to be hard-coded in to both find the file and create files in the specified folder. Here’s the working code for both the Volume and Bind mount approach with my specific file paths included:

docker run --rm -t -i -v %cd%://c/QIIME2/Indiana/Run2 bwawrik/qiime -i //c/QIIME2/Indiana/Run2/IndFun_S1_L001_R1_001.fastq -o //c/QIIME2/Indiana/Run2/seq_counts.txt

docker run --rm -t -i --mount type=bind,source=//c/QIIME2/Indiana/Run2,target=//c/QIIME2/Indiana/Run2 bwawrik/qiime -i //c/QIIME2/Indiana/Run2/IndFun_S1_L001_R1_001.fastq -o //c/QIIME2/Indiana/Run2/seq_counts.txt

Now, docker successfully mounts my folder inside the container, executes the python script with my file, generates the output file of interest in the folder, and then closes the container.

Again, thank you so much for all the help. Hopefully this thread is useful for others who are struggling with this specific syntax for attaching folders to containers properly.

1 Like

you probably could have used %cd% in the source of the bind type as well as those should not be sensitive to the : in the normal windows paths.

thanks for showing both approaches, -v and -mount type=bind

I was seeing the same error, thought I’d share my ‘fix’ in case it helps someone.
Was trying run a windows container, cosmosdb emulator, on a windows pc. I was running the command they provide in their Docker Hub.
My DockerDesktop was set to run Linux containers but I had checked the ‘Experimental’ option and was passing the --platform windows switch, so I figured that should work.
However, for this scenario you must have DockerDesktop set to run Windows containers as the default. Also pass the --platform switch and experimental must be checked.
I’m also now running the edge version, not sure if that is essential.

To anyone who has a similar problem, check to make sure that you’re enclosing the source and target file paths in double char quotes “” and not single quotes. That simple difference raises this error as well (at least on Windows).

1 Like