Docker run command gives source path doesn't exist error although path exists

I ran stat command from user’s home. Path /mnt1 does exist.
When you say /mnt1 doesn’t exist on the host, you mean it is not added to docker host? Is there a way we can check if it is present on the host or not?

As mentioned in my first post, I’m trying to mount /mnt1/vendor_build/06_11

All of the tests indicates it doesn’t. When you try to mount a folder into a Docker container, Docker tries to create it if it is not there. When your user doesn’t have permission to create the source path, you normally get “permission denied”. Since Docker usually runs as root even if your user is not root, Docker would still create the folder unless you ar using rootless Docker. In that case Docker is not running as root, so you could get “permission denied”.

Somemetimes the root filesystem is read-only, so you don’t get “permission denied” but “filesystem is read-only”. This is how you can reproduce it (and how I did):

truncate --size 2G disk.img
mkfs.ext4 disk.img
mkdir mount-test
mount -o ro ./disk.img ./mount-test
docker run --rm -it -v $PWD/mount-test/subfolder:/host ubuntu ls -l /host

Since I created a virtual disk and mounted as read-only, I got the same error as you.

/mnt1 is not an existing folder in Linux by default. If you created it, it must be somwhere else, not where Docker can see it.

This is why I asked for your Docker version, because depending on the installation method, you can have different docker daemons. A snap package cannot see everything on the host (at least not by default). Originally you installed docker.io, and docker-ce after that, but something is still not right here.

An other issue could be remote connection. When your Docker client is on your machine, but the daemon is on a remote server. Or in a virtual machine. This is how Docker Desktop works.

I am talking about the Docker host, yes. Although the docker host can be a emote server or a VM as I mentioned it in the previous paragraph.

We just did :slight_smile: This is why I asked you to run the docker commands, but I will add an other test command in the next test, because I didn’t think of remote servers previously.

Please, run the folowing commands and share the outputs:

snap list | grep docker

docker context ls

ls -la /

Make sure you run each command in the same terminal on the same host.

Thanks for the explanation. Here is the output of the commands you mentioned:

sduddell@sduddella:/mnt1$ snap list | grep docker
docker 20.10.17 2285 latest/stable canonical** -

sduddell@sduddella:/mnt1$ docker context ls
NAME DESCRIPTION DOCKER ENDPOINT KUBERNETES ENDPOINT ORCHESTRATOR
default * Current DOCKER_HOST based configuration unix:///var/run/docker.sock swarm

sduddell@sduddella:/mnt1$ ls -la /
total 8388744
drwxr-xr-x 28 root root 4096 Nov 16 06:30 .
drwxr-xr-x 28 root root 4096 Nov 16 06:30 …
drwxr-xr-x 2 root root 4096 Nov 3 06:24 bin
drwxr-xr-x 4 root root 4096 Nov 17 06:20 boot
drwxr-xr-x 2 root root 4096 Aug 20 2020 cdrom
drwxr-xr-x 17 root root 4280 Nov 21 11:26 dev
drwxr-xr-x 149 root root 12288 Nov 22 06:52 etc
drwxr-xr-x 5 root root 4096 Jul 6 12:46 home
lrwxrwxrwx 1 root root 34 Nov 16 06:30 initrd.img → boot/initrd.img-4.15.0-197-generic
lrwxrwxrwx 1 root root 34 Nov 16 06:30 initrd.img.old → boot/initrd.img-4.15.0-196-generic
drwxr-xr-x 27 root root 4096 Nov 4 13:06 lib
drwxr-xr-x 2 root root 4096 Nov 4 13:07 lib32
drwxr-xr-x 2 root root 4096 Nov 4 13:07 lib64
drwxr-xr-x 2 root root 4096 Nov 4 13:07 libx32
drwx------ 2 root root 16384 Aug 20 2020 lost+found
drwxr-xr-x 3 root root 4096 Nov 19 13:50 media
drwxr-xr-x 2 root root 4096 Feb 3 2020 mnt
drwxrwxr-x 4 sduddell sduddell 4096 Nov 19 14:03 mnt1
drwxr-xr-x 5 root root 4096 Oct 4 11:57 opt
dr-xr-xr-x 433 root root 0 Nov 21 11:26 proc
drwx------ 6 root root 4096 Nov 23 05:19 root
drwxr-xr-x 39 root root 1240 Nov 23 16:40 run
drwxr-xr-x 3 root root 4096 Oct 3 07:24 s
drwxr-xr-x 2 root root 12288 Nov 4 13:07 sbin
drwxr-xr-x 6 root root 4096 Jun 1 2021 snap
drwxr-xr-x 2 root root 4096 Feb 3 2020 srv
-rw------- 1 root root 8589934592 Aug 20 2020 swap.img
dr-xr-xr-x 13 root root 0 Nov 22 09:44 sys
drwxrwxrwt 22 root root 12288 Nov 23 16:21 tmp
drwxr-xr-x 14 root root 4096 Jul 6 12:56 usr
drwxr-xr-x 14 root root 4096 Aug 20 2020 var
lrwxrwxrwx 1 root root 31 Nov 16 06:30 vmlinuz → boot/vmlinuz-4.15.0-197-generic
lrwxrwxrwx 1 root root 31 Nov 16 06:30 vmlinuz.old → boot/vmlinuz-4.15.0-196-generic

Now that is a problem. Remove the snap version of Docker this way:

sudo snap remove --purge docker

Then try the original docker run command again. If it doesn’t work, try to reinstall docker-ce again. If that doesn’t work either, share the exact commands that you used to install Docker CE, not just the link to the documentation, because that can contain something that you forgot to run. Since the snap package was installed, there is a good chance that this was the cause of everything even though you installed Docker CE as well, but the client still used the snap version.

Let’s see what happens when you remove the snap package.

After removing snap, I got the error that docker itself is not present. I cleaned up everything properly and installed docker again, I somehow don’t get this error anymore.
Thanks a lot for your support.