SelfhostedPro / yacht-api

Backend API for Yacht
44 stars 4 forks source link

Cant Deploy in Windows Docker #1

Open wickedyoda opened 1 year ago

wickedyoda commented 1 year ago

Windows 11 Enterprise Docker Desktop 4.18.0 (104112) Docker integrated into WSL2 Linux Install

From within WSL2 Debian linux:

traver@abcwhyme:~$ docker run -d --name yacht_api --restart unless-stopped -p 3000:3000 -v /var/run/docker.sock:/var/run/docker.sock -v /config:yacht_data ghcr.io/selfhostedpro/yacht-api:main docker: Error response from daemon: invalid volume specification: '/run/desktop/mnt/host/wsl/docker-desktop-bind-mounts/Debian/01d0ea696869632ca69da251f24e240d02568620b21f5f327df24ca685cef5a1:yacht_data': invalid mount config for type "bind": invalid mount path: 'yacht_data' mount path must be absolute. See 'docker run --help'.

From Window Command:

PS C:\Users\trave> docker run -d --name yacht_api --restart unless-stopped -p 8001:3000 -v /var/run/docker.sock:/var/run/docker.sock -v /config:yacht2 ghcr.io/selfhostedpro/yacht-api:main docker: Error response from daemon: invalid volume specification: '/config:yacht2': invalid mount config for type "bind": invalid mount path: 'yacht2' mount path must be absolute. See 'docker run --help'. PS C:\Users\trave> docker run -d --name yacht_api --restart unless-stopped -p 8001:3000 -v /var/run/docker.sock:/var/run/docker.sock -v config:yacht2 ghcr.io/selfhostedpro/yacht-api:main docker: Error response from daemon: invalid volume specification: 'config:yacht2': invalid mount config for type "volume": invalid mount path: 'yacht2' mount path must be absolute. See 'docker run --help'. PS C:\Users\trave> docker volume create yacht_data yacht_data PS C:\Users\trave>

Supporting Info: image

image

wickedyoda commented 1 year ago

I had a brain fart to what I read last night

So default docker volume location is /var/lib/docker/volume/vol_name this is an absolute path as per linux because it contains no spaces.

Docker in WSL is using a Debian WSL2 installed host, its seeing the volume data location as machine-UUID-something/mnt/c/program files/docker/... because its seeing the path with "program files" its not seen as an absolute path. In Windows the with a path needs to be absolute but contains spaces, you add a " around it. Making it "machine-UUID-something/mnt/c/program files/docker/..."

Thats why docker kept saying unable to mount because it path must be absolute. The path showing program files error, i disregarded at the time as not being sufficient and didn't add to my screenshots. I found this from the powershell prompt in Windows.

When you open a debian prompt and run docker from within it, is where it shows the "machine-UUID-something/mnt/c/program files/docker/..." path because its how WSL translates.

In WSL2, you browse the local C drive by going to /mnt/c/... for your path. If you have multiple drives then your have c, d, e, and so on...

Not breaking it down to elementary here thinking you dont know, but its helped me ration it out in my head. Your be amazed what my brain can process to theory of a dead man at 75mph...

So, my question is how do we correct this? When I get home, im gonna try a direct bind mount to c:\docker\volume a path with no spaces within windows, already absolute. Will let you know.