简体   繁体   中英

Docker mount vol error: includes invalid characters for a local volume name

There are a lot of questions regarding this same error msg as below, but I can't find a solution still.

docker: Error response from daemon: create /Users/siyang/Desktop/source: 
"/Users/Jake/Desktop/source" includes invalid characters for a local volume name, 
only "[a-zA-Z0-9][a-zA-Z0-9_.-]" are allowed. 
If you intended to pass a host directory, use absolute path.

This is the docker command I ran. I am using absolute paths and with the characters allowed.

docker run \
    -p 5000:5000 \
    --mount type=volume,source=/Users/jake/Desktop/source,target=/data \
    --name testvol test

Surprisingly, it ran fine when I do a bind-mount with the same command.

docker run \
    -p 5000:5000 \
    --mount type=bind,source=/Users/jake/Desktop/source,target=/data \
    --name test test

[UPDATE]

I am using macOS Big Sur, Docker v3.2.2.

You should not be using a volume mount if you intend to have a host directory mapped to your container. I don't think the volume mount is doing what you intended.

From the docs:

Volumes are the preferred mechanism for persisting data generated by and used by Docker containers. While bind mounts are dependent on the directory structure and OS of the host machine, volumes are completely managed by Docker.

Bind mounts are for mapping a directory on your host to a directory in the container.

Volume mounts are for mapping an existing Docker volume (ie created with docker volume create VOLUMENAME ). Docker volumes cannot have / in the name.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM