Paul M
Paul M

Reputation: 4157

Docker invalid characters for volume when using relative paths

Ive been given a docker container which is run via a bash script. The container should set up a php web app, it then goes on to call other scripts and containers. It seems to work fine for others, but for me its throwing an error.

This is the code

sudo docker run -d \
   --name eluci \
   -v ./config/eluci.settings:/mnt/eluci.settings \
   -v ./config/elucid.log4j.settings.xml:/mnt/eluci.log4j.settings.xml \
   --link eluci-database:eluci-database \
   /opt/eluci/run_eluci.sh

This is the error

docker: Error response from daemon: create ./config/eluci.settings: 
"./config/eluci.settings" 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.

Im running docker on a centos VM using virtualbox on a windows 7 host.

From googling it seems to be something to do with the mount, however I dont want to change it in case the setting it breaks or is relied upon in another docker container. I still have a few more bash scripts to run, which should orchestrate the rest of the build process. As a complete newb to Docker, this has got me stumped.

Upvotes: 51

Views: 61779

Answers (1)

Ayushya
Ayushya

Reputation: 10417

The command docker run -v /path/to/dir does not accept relative paths, you should provide an absolute path. The command can be re-written as:

sudo docker run -d \
   --name eluci \
   -v "/$(pwd)/config/eluci.settings:/mnt/eluci.settings" \
   -v "/$(pwd)/config/elucid.log4j.settings.xml:/mnt/eluci.log4j.settings.xml" \
   --link eluci-database:eluci-database \
   /opt/eluci/run_eluci.sh

Upvotes: 91

Related Questions