abiosoft / colima

Container runtimes on macOS (and Linux) with minimal setup
MIT License
19.3k stars 386 forks source link

After starting colima with default mount, cant mount a different directory before running colima delete #546

Open RoyNoymanW opened 1 year ago

RoyNoymanW commented 1 year ago

Description

Hey, We have couple of usages for running colima, for example:

  1. starting colima without mounts - exact command: colima start --memory 6 --cpu 4
  2. starting colima with mounts - exact command: colima start --memory 6 --cpu 4 --mount $HOME/a_project_directory:/a_path_in_container:w --mount-type 9p

The bug: Cant set a mount if sometime previously I started colima without a mount. Must use colima delete which clear a lot of cached resources.

An ls command output after the second start (with mount): colima:/$ ls -la

total 16 drwxr-xr-x 21 root root 420 Dec 28 08:03 . drwxr-xr-x 21 root root 420 Dec 28 08:03 .. drwxr-xr-x 3 root root 30 Dec 14 18:17 .modloop drwxr-xr-x 3 root root 60 Dec 28 08:03 Users drwxr-xr-x 2 root root 1840 Dec 28 08:03 bin drwxr-xr-x 14 root root 2800 Dec 28 08:03 dev drwxr-xr-x 31 root root 4096 Dec 28 08:03 etc drwxr-xr-x 3 root root 4096 Dec 28 08:02 home drwxr-xr-x 10 root root 1040 Dec 28 08:03 lib drwxr-xr-x 6 root root 120 Dec 28 08:03 media drwxr-xr-x 4 root root 80 Dec 28 08:03 mnt drwxr-xr-x 3 root root 60 Dec 28 08:03 opt dr-xr-xr-x 170 root root 0 Dec 28 08:03 proc drwx------ 2 root root 4096 Dec 28 08:01 root drwxr-xr-x 7 root root 500 Dec 28 08:03 run drwxr-xr-x 2 root root 3320 Dec 28 08:03 sbin drwxr-xr-x 2 root root 40 Dec 28 08:03 srv dr-xr-xr-x 13 root root 0 Dec 28 08:03 sys drwxrwxrwt 5 root root 4096 Dec 28 08:02 tmp drwxr-xr-x 8 root root 160 Dec 28 08:03 usr drwxr-xr-x 13 root root 300 Dec 28 08:03 var

Version

Colima Version: 0.5.1 Lima Version: 0.14.2 Qemu Version: 7.2.0

Operating System

Output of colima status

First run - colima start --memory 6 --cpu 4:

INFO[0000] colima is running using QEMU INFO[0000] arch: x86_64 INFO[0000] runtime: docker INFO[0000] socket: unix:///Users/royno/.colima/default/docker.sock

Second run (after colima stop, without delete):

INFO[0000] colima is running using QEMU INFO[0000] arch: x86_64 INFO[0000] runtime: docker INFO[0000] mountType: 9p INFO[0000] socket: unix:///Users/royno/.colima/default/docker.sock

Reproduction Steps

  1. start without mount (colima start --memory 6 --cpu 4)
  2. stop colima - colima stop
  3. start with mount colima start --memory 6 --cpu 4 --mount $HOME/a_project_directory:/a_path_in_container:w --mount-type 9p

Expected behaviour

The expected behavior is having the new mounted directory instead of the default (/Users/)

Additional context

This can only be solved by running colima delete.

One more thing that might be related: Its true to any 2 different mounts (here the first one is just the default one)

abiosoft commented 1 year ago

After looking into this a bit more, it looks to be specific to 9p mounts. Setting mount type to 9p afterwards misbehaves if the VM was not created with 9p mount.

RoyNoymanW commented 1 year ago

Im not sure about it because when running these commands:

colima delete colima start --memory 6 --cpu 4 --mount $HOME/Project_A:/Path_Project_A:w --mount-type 9p colima stop colima start --memory 6 --cpu 4 --mount $HOME/Project_B:/Path_Project_B:w --mount-type 9p

I get the same issue. Is it something that will be fixed or this is the expected behavior?

abiosoft commented 1 year ago

Ideally, switching mount types should be avoided.

It was enabled for flexibility purposes but considering it is not behaving as desired it makes more sense to prevent it. i.e. changing mount type would require resetting the VM.

RoyNoymanW commented 1 year ago

Looking at the colima start --help, seems that 9p is the default behaviour so in the scenario I described, there's no mount types change. --mount-type string volume driver for the mount (9p, sshfs, virtiofs) (default "9p") But even when I mention the mount type from first place, its the same problem

igor-petrik-invitae commented 1 year ago

I am having the same issue of not being able to change mounts after starting the VM unless I delete the VM; I am using virtiofs mount type. I created the VM with this mount type and did not change it.