Docker Community Forums

Share and learn in the Docker community.

Docker volume create <fails absolute path>

docker

(Frankfont) #1

I’m running Docker version 17.09.0-ce, build afdb6d4 in an Ubuntu 16.04 LTS VirtualBox VM on a Windows10 host and am struggling to create a volume that is not inside the /var/lib/docker/volumes folder.

Steps to reproduce simple success...

First see what is already there…

  • root# ls /var/lib/docker/volumes
  • f600d20a3525561b6a0a150a5d33a289c0d8f924951fa6dccf4de9e82cb36b02 metadata.db

    Create volume INSIDE the docker managed /var/lib/docker/volumes folder…

  • root# docker volume create mydatavol
  • mydatavol
  • root@room4mevirtualbox:/var/lib/docker/myenv/dev-ahrq# ls /var/lib/docker/volumes
  • f600d20a3525561b6a0a150a5d33a289c0d8f924951fa6dccf4de9e82cb36b02 metadata.db mydatavol

    Steps to reproduce unhappy experience

  • root# docker volume create /home/frank/mydatavol
  • Error response from daemon: create /home/frank/mydatavol: "/home/frank/mydatavol" 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
  • root# docker volume create /home/frank/mydatavol/
  • Error response from daemon: create /home/frank/mydatavol/: "/home/frank/mydatavol/" 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
  • root# docker volume create ./home/frank/mydatavol/
  • Error response from daemon: create ./home/frank/mydatavol/: "./home/frank/mydatavol/" 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
  • root# docker volume create //home/frank/mydatavol/
  • Error response from daemon: create //home/frank/mydatavol/: "//home/frank/mydatavol/" 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
  • root# docker volume create --name=/home/frank/mydatavol/
  • Error response from daemon: create /home/frank/mydatavol/: "/home/frank/mydatavol/" 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

    Same error whatever syntax (also whatever path I have tried, not just home) … error message tells me to provide absolute path, which is what I think I am doing. Any insight appreciated.

    Update: As a workaround, creating volume in docker managed area then moving that physical folder to a new location and then placing a symbolic link with pointing to it (same name as the moved folder) seems to satisfy the containers searching for it. Same end result as what I was trying to achieve; not as elegant perhaps.


  • (Sam) #2

    note you are supplying the volume logical NAME (no path is allowed in the NAME)

    the ‘volume’ storage is in the docker volumes path.

    your using link is just a tricky way of mapping the logical NAME to a location ‘in’ the docker volumes path.