Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Docker run command, volumes error when using relative paths

I'm trying to make a docker run and build command out of the compose file below.

So far I have come up with this:

docker build --tag testenvironment/nodejs ./node_js
docker run -p 8080:8080 -v ./node_js:/home/app/chat -v /home/app/chat/node_modules --name nodejs testenvironment/nodejs

I'm stuck here because it gives the following error:

C:\Program Files\Docker Toolbox\docker.exe: Error response from daemon: create ./node_js: "./node_js" includes invalid characters for a local volume name, only "[a-zA-Z0-9][a-zA-Z0-9_.-]" are allowed. If you intented to pass a host directory, use absolute path. See 'C:\Program Files\Docker Toolbox\docker.exe run --help'.

Compose file:

node:
  build: ./node_js
  command: node server.js
  depends_on:
    - mongo
  links:
    - mongo      
  environment:
    NODE_ENV: development  
  ports:
    - '8080:8080'
  volumes:
    - ./node_js:/home/app/chat
    - /home/app/chat/node_modules

Can anybody tell me how to convert the volumes from the compose file to a docker run command? Thanks in advance.

I am using the Docker Toolbox for Windows 10.

like image 988
Jan Avatar asked Jun 01 '17 14:06

Jan


People also ask

How do I get a docker volume path?

Docker automatically creates a directory for the volume on the host under the /var/lib/docker/volume/ path. You can now mount this volume on a container, ensuring data persistence and data sharing among multiple containers.

Which docker allows containers to run with persistent volumes?

Docker has an option to allow specific folders in a container to be mapped to the normal filesystem on the host. This allows us to have data in the container without making the data part of the Docker image, and without being bound to AUFS.

What is the default location of docker volumes?

Volumes are stored in a part of the host filesystem which is managed by Docker ( /var/lib/docker/volumes/ on Linux).


1 Answers

This part:

docker run -p 8080:8080 -v ./node_js:/home/app/chat ....

Should be:

docker run -p 8080:8080 -v $(pwd)/node_js:/home/app/chat

docker run requires an absolute path for volumes (as a difference from compose)

like image 85
Robert Avatar answered Oct 05 '22 18:10

Robert