rancher-sandbox / rancher-desktop

Container Management and Kubernetes on the Desktop
https://rancherdesktop.io
Apache License 2.0
5.92k stars 281 forks source link

Nerdctl WSL linux bind mount not working in docker-compose #1338

Open benjaminpreiss opened 2 years ago

benjaminpreiss commented 2 years ago

Rancher Desktop Version

Version: 1.0.0-beta.1

Rancher Desktop K8s Version

1.22.5

What operating system are you using?

Other (specify below)

Operating System / Build Version

Windows 10 Pro, WSL2 debian

What CPU architecture are you using?

x64

Linux only: what package format did you use to install Rancher Desktop?

No response

Windows User Only

No response

Actual Behavior

My volume bind mounts in the docker-compose are ignored and cause the app to crash.

Steps to Reproduce

  1. create the following file structure:
- docker-compose.yml
- myapp/
- - volume/
  1. The docker-compose should look like this:
version: "3.9"
services:
  frontend:
    image: node:lts
    volumes:
      - ./myapp/volume:/home/node/app
  1. run nerdctl compose -f ./docker-compose.yml up --build

Result

I get the following output:

image

Expected Behavior

This should successfully run and build a container.

Additional Information

No response

benjaminpreiss commented 2 years ago

Might be related #1307

evertonlperes commented 2 years ago

Hi @benjaminpreiss Thanks for filing this issue. Have you faced the same behaviour using moby/dockerd container runtime?

You can pick between containerd or dockerd on Kubernetes Settings tab.

benjaminpreiss commented 2 years ago

@evertonlperes Hmm - I just tried. When I switch to moby and run docker-compose up --build I get the following error:

bash: docker-compose: command not found
evertonlperes commented 2 years ago

@evertonlperes Hmm - I just tried. When I switch to moby and run docker-compose up --build I get the following error:


bash: docker-compose: command not found

Gotcha. If you're using any package management (scoop, chocolatey, and etc), try to install docker-compose. RD does not install docker-compose by default, requiring a manual installation.

benjaminpreiss commented 2 years ago

@evertonlperes Ah, yeah I just saw that there is a pull request out there about that: https://github.com/rancher-sandbox/rancher-desktop/pull/1372

benjaminpreiss commented 2 years ago

@evertonlperes I guess with moby it works...

image

evertonlperes commented 2 years ago

Thanks for sharing @benjaminpreiss

Disregard the message below (and sorry to close it). Reopening the issue. I did replicate the issue on Ubuntu 20.04, after deleting my existing wsl distro and start fresh.

PS C:\Users\everton.peres> wsl
To run a command as administrator (user "root"), use "sudo <command>".
See "man sudo_root" for details.

test@Win11-RD:/mnt/c/Users/everton.peres$ ls
 AppData                                                                                        OneDrive
'Application Data'                                                                              Pictures
 Contacts                                                                                       PrintHood
 Cookies                                                                                        Recent
 Desktop                                                                                       'Saved Games'
 Documents                                                                                      Searches
 Downloads                                                                                      SendTo
 Favorites                                                                                     'Start Menu'
 Links                                                                                          Templates
'Local Settings'                                                                                Videos
 Music                                                                                          docker-compose.yml
'My Documents'                                                                                  multi-docker
 NTUSER.DAT                                                                                     ntuser.dat.LOG1
 NTUSER.DAT{b68b7f0d-775a-11ec-804c-00155d000701}.TM.blf                                        ntuser.dat.LOG2
 NTUSER.DAT{b68b7f0d-775a-11ec-804c-00155d000701}.TMContainer00000000000000000001.regtrans-ms   ntuser.ini
 NTUSER.DAT{b68b7f0d-775a-11ec-804c-00155d000701}.TMContainer00000000000000000002.regtrans-ms   projects
 NetHood
test@Win11-RD:/mnt/c/Users/everton.peres$ cd multi-docker/
test@Win11-RD:/mnt/c/Users/everton.peres/multi-docker$ nerdctl compose -f docker-compose.yml up --build
INFO[0000] Creating network nerdctl-tmp.4126906315_default
WARN[0000] Ignoring: volume: Bind: [CreateHostPath]
WARN[0000] Ignoring: volume: Bind: [CreateHostPath]
WARN[0000] Ignoring: volume: Bind: [CreateHostPath]
INFO[0000] Building image nerdctl-tmp.4126906315_worker
[+] Building 0.0s (0/0)
error: could not find /mnt/wsl/rancher-desktop/run/nerdctl-tmp.4126906315/worker: stat /mnt/wsl/rancher-desktop/run/nerdctl-tmp.4126906315/worker: no such file or directory
FATA[0000] unrecognized image format
FATA[0000] error while building image nerdctl-tmp.4126906315_worker: exit status 1
test@Win11-RD:/mnt/c/Users/everton.peres/multi-docker$

Unfortunately, I cannot reproduce the error on nerdctl.

~~Looks like you have an error on your mount paths in your docker-compose file. As you're using your docker-compose file, outside of your project folder, you need to configure it accordingly.~~

Here's an example of a volume mount, where the docker-compose is outside of the project folder:

 client:
    container_name: client-container
    build:
      dockerfile: Dockerfile.dev
      context: ./multi-docker/client
    volumes:
      - ./multi-docker/client:/multi-docker/app/volume

Closing this issue for now. Feel free to reopen, if you find another issues.

Thank you.

jandubois commented 2 years ago

Might be related #1307

Have you since upgraded to 1.0.0 and checked if the issue was fixed by #1307? Because that fix is only in the final release and not the beta.

benjaminpreiss commented 2 years ago

@jandubois I remember that in Rancher Desktop the version was just 1.0.0 - not 1.0.0-beta or something like that.

maybeec commented 2 years ago

I am running a fresh Rancher Desktop 1.0.0, installed for the first time, having WSL integration with Ubuntu 20.04 enabled. dockerd runtime active Running docker-compose shows me unrecognized command on windows cmd. There is no silent installation as contributed by #1372 if I got it right.

jandubois commented 2 years ago

@maybeec The docker-compose integration will be included in the 1.1.0 release; for now you have to install it manually.

benjaminpreiss commented 2 years ago

@evertonlperes Any progress on this? How can I help?

evertonlperes commented 2 years ago

@evertonlperes Any progress on this? How can I help?

It seems to be an issue and it only happens into the wsl, outside it works nicely. Also, I'll tag this issue https://github.com/containerd/nerdctl/issues/472, where other users are facing a similar issue.

I'm not sure if it's a issue at our side (Rancher Desktop) and will be nice to have @mook-as thoughts on this.

Outside WSL

PS C:\Users\everton.peres\multi-docker> nerdctl compose -f .\docker-compose.yml up --build
WARN[0000] Ignoring: volume: Bind: [CreateHostPath]
INFO[0000] Ensuring image node:lts
INFO[0000] Creating container multi-docker_frontend_1
INFO[0000] Attaching to logs

Inside WSL Debian 10

test@WinPRO-RDTest:~/multi-docker$ nerdctl compose -f docker-compose.yml up --build
INFO[0000] Creating network nerdctl-tmp.1298910539_default
WARN[0000] Ignoring: volume: Bind: [CreateHostPath]
INFO[0000] Ensuring image node:lts
INFO[0000] Creating container nerdctl-tmp.1298910539_frontend_1
FATA[0000] failed to create shim: OCI runtime create failed: container_linux.go:
380: starting container process caused: process_linux.go:545: container init cau
sed: rootfs_linux.go:75: mounting "/mnt/wsl/rancher-desktop/run/nerdctl-tmp.1298
910539/test" to rootfs at "/home/node/app" caused: stat /mnt/wsl/rancher-desktop
/run/nerdctl-tmp.1298910539/test: no such file or directory: unknown
FATA[0000] error while creating container nerdctl-tmp.1298910539_frontend_1: exi
t status 1
jotahe commented 2 years ago

Hi @evertonlperes and everyone, I got the same error you mentioned:

 nerdctl compose -f ./nerdctlexa.yml up --build
INFO[0000] Creating network nerdctl-tmp.3466118414_default 
INFO[0000] Building image nerdctl-tmp.3466118414_web    
[+] Building 0.0s (0/0)
error: could not find /mnt/wsl/rancher-desktop/run/nerdctl-tmp.3466118414/web/build: stat /mnt/wsl/rancher-desktop/run/nerdctl-tmp.3466118414/web/build: no
 such file or directory
FATA[0000] unrecognized image format
FATA[0000] error while building image nerdctl-tmp.3466118414_web: exit status 1

Seems that is always looking for a path related to rancher mount directory. This is the docker compose i am trying to run:

version: '3.9'
services:
  web:
    build:
      context: ./web/build/
      dockerfile: Dockerfile-alpine
      args:
        environment: dev
        status: stable
    ports:
        - 80:80