Search code examples
dockersyntaxdocker-command

How does docker recognize if run -v option refers to host directory or a docker volume?


When executing docker run with option -v a:b, a could refer either to a directory on the host, or a docker volume name. How does docker recognize which one is it?


Solution

  • How does docker recognize which one is it?

    If a contains a / slash, it is a directory. Otherwise, it is a volume name.