Docker: Invalid characters (%cd%) for local volume - Windows 10 - docker

When trying to mount a local volume using docker run on Windows 10, Docker version 20.10.12, using
docker run -it -v -p 3000:3000 %cd%:/usr/src/app rails6
I get the error response:
docker: Error response from daemon: create %cd%: "%cd%" 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.

The solution was to run in PowerShell, using the delimited, automatic variable ${pwd}.
docker run -it -v -p 3000:3000 ${pwd}:/usr/src/app rails6

Related

Running docker container on windows with a volume gives me an error

I'm trying to run a simple docker image with a volume
docker run -dit -v J:\dvolumes:/data ubuntu
However I get the following error
docker: Error response from daemon: invalid mode: data.
I'm guessing it's thinking the ':' after the J is what separates the volume but I don't really know how to make it think otherwise (if that's the case).
Any help would be greatly appreciated
Issue was that I was trying to run the container in WSL2 so I should be using linux paths
WSL2
docker run -dit -v /j/dvolumes:/data ubuntu
Windows
docker run -dit -v j:/dvolumes:/data ubuntu

docker is displaying error regarding absolute path while installing label-studio

I am working on NER ML model which requires label-studio to be get installed on the pc. I am using this command
`docker run -it -p 8080:8080 -v `pwd`/mydata:/label-studio/data heartexlabs/label-studio:latest`
for installation of label-studio in terminal but getting the below error.
docker: Error response from daemon: create `pwd`/mydata: "`pwd`/mydata" 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.
The docker is running on windows 10.
Any help in this regard will be highly appreciated.
Thank You
`pwd` can't be used on Windows, it's linux-only. Replace it with absolute paths please, e.g.:
docker run -it -p 8080:8080 -v c:/projects/mydata:/label-studio/data heartexlabs/label-studio:latest

Docker run -v : Unable to mount a bind volume : "invalid volume specification"

I'm quite new to Docker. I'm running on Windows 10 Enterprise and am trying to containerize an existing app that runs on windows (so it's a Windows container). I don't know if this matters but the container is rather large (8 GB).
I need to share a config file (that lives on the host) with the container that the app will use when starting. I was thinking that a bind volume was simplest.
Problem: On running the image I get docker: Error response from daemon: invalid volume specification: '<source path>:<target path>'
Container was built with this command:
docker build -t my_image .
Here is the Dockerfile:
FROM mcr.microsoft.com/dotnet/framework/runtime:4.8
WORKDIR /app
COPY . .
ENTRYPOINT .\application.exe ..\Resources
Here is what I've tried
docker run -it -v c:/Users/my_user:/app my_image
I've tried every combination of C:/, C:\, C:\\, /c/, //c/, \c\, \\c\, etc.
I've tried multiple combinations of /app, //app, \app, \app, C:\app, etc.
I've also tried with and without :rw appended to the end
I've tried the ```--mount``` syntax which consistently outputs: docker: Error response from daemon: invalid mount config for type "bind": invalid mount path: '/app'. (tried a bunch of variations of /app here too)
I've tried every possible combination (except the right one). Please help!
Since you are using a Windows container, your file path will change. Try the below command, from the docs Persistent Storage in Windows Containers
docker run -it -v c:\Users\my_user:c:\app my_image
If you are using a powershell and trying to run docker using docker run command you can try this approach. It worked for me in windows powershell (vs code powershell)
docker run -v ${pwd}\src:/app/src -d -p 3000:3000 --name react-app-c2 react-app-image
Here react-app-c2 is container name and react-app-image is image name
-v is for volume and ${pwd} is for current working directory
/app/src is for the containerdirectory.

Docker: Issue creating a Portainer container

I'm trying to create a Portainer container in Windows 10 (and Docker ToolBox), but I'm getting an error using this docker run command:
docker run --name portainer --restart unless-stopped -p 9090:9000 -e TZ=America/Chicago -it --mount src=/var/run/docker.sock,dst=/var/run/docker.sock,type=volume --mount src="/c/Users/My Cloud/AppData/Roaming/DockerConfigs/Portainer/Data",dst=/data,type=bind portainer/portainer
Is giving me this error:
docker: Error response from daemon: create /var/run/docker.sock: "/var/run/docker.sock" 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.
If I follow the Windows example on the Portainer page replace the --mount version of the docker.sock path with the -v version instead, like this:
-v /var/run/docker.sock:/var/run/docker.sock
I get this error instead:
2019/02/13 19:47:49 invalid argument
But the container does get created; however, it ignored the specified ports in the command-line, and when I try to manually re-add them using Kitematic, it starts a bootloop on that container, and the container is unusable, I end up having to scrap it.
Anyone know what I'm missing? I'm just now learning my way around Docker.

Error response from daemon: Invalid container name (tomcat:8.0), only [a-zA-Z0-9][a-zA-Z0-9_.-] are allowed

I'm trying to run a docker container by Vagrant Docker provision:
d.run "tomcat:8.0", args: "-it -d -p 8888:8888 --name tomcat8"
Vagrant pulls the image fine, but when it comes to running the container I get a:
Error response from daemon: Invalid container name (tomcat:8.0), only
[a-zA-Z0-9][a-zA-Z0-9_.-] are allowed
I would like to keep the :8.0 so that I'm sure I run the right image version.
Well it turned out that Vagrant by default uses the image name as container name even if I used the --name arg.
In my case that was unfortunate since I was pulling from the official Tomcat repository at Dockerhub and hence could not change the image name.
What I found was that Vagrant has an extra setting called auto_assign_name which must be set to false in order to use the --name arg.
So a working Vagrant line would be:
d.run "tomcat:8.0", args: "-it -p 8080:8080 --name tomcat8", auto_assign_name: false

Resources