moby: Cannot mount a volume with '/' in it's name
ErrorCodeVolumeName error is generated: “%s includes invalid characters for a local volume name, only [a-zA-Z0-9][a-zA-Z0-9_.-] are allowed”
Possible root cause: the constant in https://github.com/docker/docker/blob/master/utils/names.go lacks forward slash in regexp.
const RestrictedNameChars = [a-zA-Z0-9][a-zA-Z0-9_.-]
About this issue
- Original URL
- State: closed
- Created 9 years ago
- Comments: 18 (7 by maintainers)
Commits related to this issue
- fixes #17734, clear message for host volumes not starting with / Signed-off-by: Muayyad Alsadi <alsadi@gmail.com> — committed to muayyad-alsadi/docker by muayyad-alsadi 8 years ago
- Merge pull request #27985 from muayyad-alsadi/17734-better-message-for-host-volumes fixes #17734, clear message for host volumes not starting with / — committed to moby/moby by vieux 8 years ago
- fixes #17734, clear message for host volumes not starting with / Signed-off-by: Muayyad Alsadi <alsadi@gmail.com> — committed to vieux/docker by muayyad-alsadi 8 years ago
I’ve just bitten by this too. Any chance the message could be fixed to reflect the fact that paths are allowed but must be absolute?
Clay, problem is resolved, thank you!
I was violating this requirement: The host-dir can either be an absolute path or a name value.
In my case host volume path was relative. I was actually deceived by the error message:
Error response from daemon: volumes/adms1/app includes invalid characters for a local volume name, only [a-zA-Z0-9][a-zA-Z0-9_.-] are allowed
For those it is not clear, here is a great explanation from #34532 by @thaJeztah https://github.com/moby/moby/issues/34532#issuecomment-322738970 about the invalid characters in the volume name.
should be
note that paths like
~/foo
or$HOME/foo
are expanded to an absolute path (/home/username/foo
) by your shell, before invoking docker.Or in this case, docker-compose. It worked with ${PWD} in the docker-compose.yml file.
@thaJeztah here you go