Docker Community Forums

Share and learn in the Docker community.

Error running Getting Started example

I am leaning Docker by using the Getting Started tutorial but am having a problem with the “Starting a Dev-Mode Container” example. When I run:
docker run -dp 3000:3000 -w /app -v "$(pwd):/app" node:12-alpine sh -c "yarn install && yarn run dev"
I get the error:
docker: Error response from daemon: create $(pwd): "$(pwd)" 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.

Additionally, I created a volume with the following inspect data:
[
{
“CreatedAt”: “2020-08-15T20:01:33Z”,
“Driver”: “local”,
“Labels”: {},
“Mountpoint”: “/var/lib/docker/volumes/todo-db/_data”,
“Name”: “todo-db”,
“Options”: {},
“Scope”: “local”
}
]
but the Mountpoint directory does not exist.
wsl ls -l /var/lib
total 20
drwxr-xr-x 2 root root 4096 Apr 16 2019 apk
drwxr-xr-x 2 root root 4096 Apr 16 2019 arpd
drwxr-xr-x 2 root root 4096 Apr 16 2019 iptables
drwxr-xr-x 2 root root 4096 Apr 16 2019 misc
drwxr-xr-x 2 root root 4096 Apr 16 2019 udhcpd

Any help resolving these problems will be greatly appreciated. I am running Windows 10 Pro, 1904.450 with WSL2, 120.2212.31.0 and Docker engine v19.03.12.

For the docker volume in your first question, can you try:

docker run -it --rm -p 3000:3000 -w /app -v "$PWD":/app node:12-alpine sh

If this works, the next step would be:

docker run -it --rm -p 3000:3000 -w /app -v "$PWD":/app node:12-alpine "yarn install && yarn run
 dev"

Related to the location of the volume, I am suspecting you were checking the location after the volume was defined via the command line. Check the location after you have your container up. I am thinking the volume is created when the container this volume is associated to is span up. In general, you do not need to interact with this volume as it will be manage by docker. You can copy content from your local host using docker cp for instance.

Thanks for you help and suggestions. I am still getting the “invalid characters for a local volume name” error. I think that you are correct about the second but cannot check it until a solve the first issue,
Thanks again for your suggestions.

Here are some quick solutions to help get back on track. These examples assume the Docker host is a machine called default.

REGENERATE CERTIFICATES
Some errors explicitly tell you to regenerate certificates. You might also try this for other errors that are certificate and/or connectivity related.

docker-machine regenerate-certs default Regenerate TLS machine certs? Warning: this is irreversible. (y/n): y Regenerating TLS certificates RESTART THE DOCKER HOST docker-machine restart default
After the machine starts, set the environment variables for the command window.

eval (docker-machine env default)
Run docker-machine ls to verify that the machine is running and that this command window is configured to talk to it, as indicated by an asterisk for the active machine (*).

docker-machine ls NAME ACTIVE DRIVER STATE URL SWARM DOCKER ERRORS default * virtualbox Running tcp://192.168.99.101:2376 v1.10.1 STOP THE MACHINE, REMOVE IT, AND CREATE A NEW ONE. docker-machine stop default
Stopping “default”…
Machine “default” was stopped.

$ docker-machine rm default
About to remove default
Are you sure? (y/n): y
Successfully removed default
You can use the docker-machine create command with the virtualbox driver to create a new machine called default (or any name you want for the machine).

$ docker-machine create --driver virtualbox default
Running pre-create checks…
(default) Default Boot2Docker ISO is out-of-date, downloading the latest release…
(default) Latest release for github.com/boot2docker/boot2docker is v1.10.1
(default) Downloading

Docker is up and running!
To see how to connect your Docker Client to the Docker Engine running on this virtual machine, run: docker-machine env default
Set the environment variables for the command window.

eval (docker-machine env default)
Run docker-machine ls to verify that the new machine is running and that this command window is configured to talk to it, as indicated by an asterisk for the active machine (*).