The source path is not found and not know to docker - docker

$ winpty docker run -it -p 8080:80 -v $(pwd):/app -w "/app"
microsoft/aspnetcore-build /bin/bash
C:/Program Files/Docker/Docker/Resources/bin/docker.exe: Error response from
daemon: Mount denied:
The source path "C:/Users/Nutcha;C"
doesn't exist and is not known to Docker.
See 'C:/Program Files/Docker/Docker/Resources/bin/docker.exe run --help'.
My current workspace is in Document folder but this error happen what I suppose to do. I use Gitbash.
Thank you

Related

Docker command gives me error: could not find `Cargo.toml` in `/contract` or any parent directory. I think this is from a faulty docker command

I am trying to run a contract optimizer for my Secret Network app code. I am pretty sure that this error has nothing to do with Secret Network so that's not relevant. All you need to know is that my app is written in rust. I am 99% sure my problem is the fault of a bad docker command. I am running this command in the same directory of my app's code.
docker run --rm -v "$(pwd)":/contract \
--mount type=volume,source="$(basename "$(pwd)")_cache",target=/code/target \
--mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \
enigmampc/secret-contract-optimizer
I put the above docker command into a script and ran it. I got this in my terminal:
docker: Error response from daemon: invalid mount config for type "volume": invalid mount path: 'C:/Program Files/Git/code/target' mount path must be absolute.
See 'docker run --help'.
I tried to modify the command by adding an extra / to the start of the target value like this:
docker run --rm -v "$(pwd)":/contract \
--mount type=volume,source="$(basename "$(pwd)")_cache",target=//code/target \
--mount type=volume,source=registry_cache,target=//usr/local/cargo/registry \
enigmampc/secret-contract-optimizer
But then I got this error:
error: could not find `Cargo.toml` in `/contract` or any parent directory
So what is wrong with the docker command? I am running it in the same directory as the Cargo.toml file for my app.

Docker: error while creating mount source path. How can i fix it?

Tks all, idk why, but now its working
I learn to use docker. I try mount a host directory in a Docker container: >docker run -it -v /Users/Kell/Desktop/data:/home/data 77
And this is error: docker: Error response from daemon: error while creating mount source path '/Users/Kell/Desktop/data': mkdir /Users: file exists.
**I use windows and docker 20.10.12, 77 is imageID **
I tried in another disk and tried many ways but still not working. Can u help me ?
If you learning docker from scratch it is recommended to use --mount and not -v anymore: Mount > v
The syntax of --mount and -v differs, so here you' find both: How to mount
Path style in Windows depends on the console you are using. Some are just working in one and not in another.
Windows-Style: docker run --rm -ti -v C:\Users\user\work:/work alpine
Pseudo-Linux-Style in Windows: docker run --rm -ti -v /c/Users/user/work:/work alpine as well as //c/
Inside WSL: docker run --rm -ti -v /mnt/c/Users/user/work:/work alpine
See: Path conversion in Windows

Pass configuration file to mosquitto in Docker container

Trying to run masquitto Docker container on Windows. I have directory structure:
..
mosquitto
config
-- mosquitto.conf
data
log
I run command:
docker run -it -p 1883:1883 -p 9001:9001 -v mosquitto.conf:/mosquitto/config/mosquitto.conf -v /mosquitto/data -v /mosquitto/log eclipse-mosquitto
Got error:
docker: Error response from daemon: source /var/lib/docker/overlay2/c54f317f73085489398e1b2c4ffbc85fbdb18073e8a0fa60f11a7f7222fbc49d/merged/mosquitto/config/mosquitto.conf is not directory.
See 'docker run --help'.
What I do wrong?
UPD
I tried to provide full path to config file on host machine:
docker run -it -p 1883:1883 -p 9001:9001 -v C:/docker_tst/eclipse-mosquitto/mosquitto.conf:/mosquitto/config/mosquitto.conf eclipse-mosquitto
Got error:
docker: Error response from daemon: OCI runtime create failed: container_linux.go:370: starting container process caused: process_linux.go:459: container init caused: rootfs_linux.go:59: mounting "/run/desktop/mnt/host/c/docker_tst/eclipse-mosquitto/mosquitto.conf" to rootfs at "/var/lib/docker/overlay2/d9a7cbcb0f85b195dc5ee2d0999b3df8c84324552f6c45cf218876e9b96ed826/merged/mosquitto/config/mosquitto.conf" caused: not a directory: unknown: Are you trying to mount a directory onto a file (or vice-versa)? Check if the specified host path exists and is the expected type.
PS C:\docker_tst\eclipse-mosquitto>
From the comments, the solution was to provide an absolute path to the single mounted file, per this answer.
On Unix based systems or in Windows Subsystem for Linux, you can do this by running something like:
docker run -v $PWD/filename:/path/in/container IMAGE_NAME
However, the process is different on Windows, per this answer.
In PowerShell, you can run Get-Location or pwd to get the current directory where your file is and switch the \ to / (forward slashes). For this example, the solution was to use this command:
docker run -it -p 1883:1883 -p 9001:9001 -v C:/docker_tst/eclipse-mosquitto/mosquito/config/mosquito.conf:/mosquitto/config/mosquitto.conf eclipse-mosquitto

Docker volume mount fails with the below error

Docker volume mount fails with the below error.
I'm trying to run a container with a config file in the volume and it fails with the below errors.
root#ip-172-31-21-249:~/data# docker run -it -p 8080:8080 -p 29418:29418 -v /root/data:/var/gerrit/etc/ forkub
error: could not lock config file /var/gerrit/etc/gerrit.config: Permission denied
root#ip-172-31-21-249:~/data# docker run -it -p 8080:8080 -p 29418:29418 -v /root/data:/var/gerrit/etc forkub
error: could not lock config file /var/gerrit/etc/gerrit.config: Permission denied
root#ip-172-31-21-249:~/data# docker run -it -p 8080:8080 -p 29418:29418 -v /root/data/:/var/gerrit/etc forkub
error: could not lock config file /var/gerrit/etc/gerrit.config: Permission denied
root#ip-172-31-21-249:~/data# docker run -it -p 8080:8080 -p 29418:29418 -v /root/data/:/var/gerrit/etc/ forkub
error: could not lock config file /var/gerrit/etc/gerrit.config: Permission denied
root#ip-172-31-21-249:~/data# docker run -it -p 8080:8080 -p 29418:29418 -v /root/data/:/var/gerrit/etc/gerrit.config forkub
docker: Error response from daemon: OCI runtime create failed: container_linux.go:349: starting container process caused "process_linux.go:449: container init caused \"rootfs_linux.go:58: mounting \\\"/root/data\\\" to rootfs \\\"/var/lib/docker/overlay2/0a5356aed5a1aa1d1359912ccba7547db55b0377b3a509b898828734868e335a/merged\\\" at \\\"/var/lib/docker/overlay2/0a5356aed5a1aa1d1359912ccba7547db55b0377b3a509b898828734868e335a/merged/var/gerrit/etc/gerrit.config\\\" caused \\\"not a directory\\\"\"": unknown: Are you trying to mount a directory onto a file (or vice-versa)? Check if the specified host path exists and is the expected type.
ERRO[0000] error waiting for container: context canceled
Any suggestions on fixing this is really appreciated.
Thank you,
Anish
Probably the process in the container does not run as root but as some other user. The file belongs to root though and is not readable by the user that runs the process. So the process can not read the file.
So you need to make sure that the user that runs the process in the container can access those files. The easiest way would be to make /root/data world read-/writeable (chmod -R 777 /root/data) but this is obviously not the best way. The right way to do this, would be to find out which user is running the process in the container and change the ownership of /root/data and everything in it to that user.
The problem with docker run -it -p 8080:8080 -p 29418:29418 -v /root/data/:/var/gerrit/etc/gerrit.config forkub is, that you are trying to mount a directory /root/data to a file. This does not work.

Error response from daemon: Mount denied - Error got while running docker application, which was working last night

Suddenly my docker run stopped working last night, which was working before. docker build is working fine, but I get the below error when trying to run the container.
Command
docker run -it --rm -p 9001:4200 -v ${pwd}/src:/app/src angularclient
Error message
C:\Program Files\Docker\Docker\Resources\bin\docker.exe: Error
response from daemon: Mount denied: The source path
"E:/Karthik/angular/src" doesn't exist and is not known to Docker. See
'C:\Program Files\Docker\Docker\Resources\bin\docker.exe run --help'.
I tried running the following command in the power shell:
refreshenv
set MSYS_NO_PATHCONV=1
set COMPOSE_CONVERT_WINDOWS_PATHS=1
try this:
docker run -it --rm -p 9001:4200 -v E:/Karthik/angular/src:/app/src angularclient
It seems that you can't use ${pwd} and ./ on win cmd and Git Bash. You can only use absolute paths.
Add this on your ~/.bash_profile:
export MSYS_NO_PATHCONV=1
Add / to prefix of path as below.
docker run -it --rm -p 9001:4200 -v /${pwd}/src:/app/src angularclient
Ensure the drive is shared in Docker settings "Shared Drives".
Create the full path if it doesn't already exist.
Add trailing / to the path.

Resources