abiosoft / colima

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

Custom network range when using --network-address #573

Open splazit opened 1 year ago

splazit commented 1 year ago

Description

First of all, I would like to thank you for such good project. My company is starting to move away from Docker Desktop to Colima/Rancher Desktop but I personally prefer CLI style so Colima fits my style more.

I'm not sure if this feature is already available or how to do it, but what I would like to do is when creating a new Colima vm with --network-address flag, I would like to customize the network for that. Right now it seems it defaults to 192.168.106.x. My use case it that when I connected to my company VPN, there's a certain subnet networks I can configure so that traffic won't go to the VPN, but the 192.168.106.x is not in the list and I cannot access the Colima vm when I'm on VPN.

jandubois commented 1 year ago

Unless colima does something special, the subnets are configured in Lima via the ~/.lima/_config/networks.yaml file. You should stop all your VMs before editing this file.

abiosoft commented 1 year ago

Unless colima does something special, the subnets are configured in Lima via the ~/.lima/_config/networks.yaml file. You should stop all your VMs before editing this file.

Nothing too special other than choosing 192.160.106.x range instead of the default 192.168.105.x.

It is possible to include the ability for users to specify a custom range. However, considering that the new VZ driver do not (yet) have that capability, I am a bit hesitant to welcome the idea.

splazit commented 1 year ago

Thanks for prompt response.

Yeah, I’ve tried that but it does not take effective, I also tried to update the /etc/sudoers.d/colima.

It seems to me that it’s hard coded in here: https://github.com/abiosoft/colima/blob/main/daemon/process/vmnet/vmnet.go#L23

I could be wrong though.

From: Abiola Ibrahim @.> Date: Thursday, January 5, 2023 at 12:38 PM To: abiosoft/colima @.> Cc: Hieu Nguyen @.>, Author @.> Subject: Re: [abiosoft/colima] Custom network range when using --network-address (Issue #573)

Unless colima does something special, the subnets are configured in Lima via the ~/.lima/_config/networks.yaml file. You should stop all your VMs before editing this file.

Nothing too special other than choosing 192.160.106.x range instead of the default 192.168.105.x.

It is possible to include the ability for users to specify a custom range. However, considering that the new VZ driver do not (yet) have that capability, I am a bit hesitant to welcome the idea.

— Reply to this email directly, view it on GitHubhttps://github.com/abiosoft/colima/issues/573#issuecomment-1372648997, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AAAXNUZEC7R6NOEDKWVIL5DWQ4PJVANCNFSM6AAAAAATSJCYYE. You are receiving this because you authored the thread.Message ID: @.***>

abiosoft commented 1 year ago

It seems to me that it’s hard coded in here: https://github.com/abiosoft/colima/blob/main/daemon/process/vmnet/vmnet.go#L23

@splazit yeah it is. You need to change that line and the next, then you'd also need to modify https://github.com/abiosoft/colima/blob/main/embedded/network/sudo.txt accordingly.

After that, make && make install and you should be good to go.

splazit commented 1 year ago

thanks for the pointer. Would it possible to have this configurable in ~/.colima/_templates/defaultor use the values from ~/.lima/_config/networks.yaml as mentioned above?

splazit commented 1 year ago

tried to compile a new binary but unfortunately it does not work as I can't even create a new vm.

abiosoft commented 1 year ago

tried to compile a new binary but unfortunately it does not work as I can't even create a new vm.

can you share the error you are getting?

splazit commented 1 year ago

I use this command w/ the new compiled colima: colima start -a x86_64 -c 6 -d 120 -m 8 --vm-type qemu --network-address

Console output: ` INFO[0000] starting colima INFO[0000] runtime: docker INFO[0000] preparing network ... context=vm WARN[0015] error starting network: error at 'preparing network': error running [/opt/local/bin/colima daemon status default], output: "time=\"2023-01-05T22:53:13-07:00\" level=fatal msg=\"pid file not found: stat /Users/xxxxxx/.colima/default/daemon/daemon.pid: no such file or directory\"", err: "exit status 1" context=vm INFO[0015] creating and starting ... context=vm WARN[0015] error setting up reachable IP address: vmnet socket file not found: stat /Users/xxxxxxx/.colima/default/daemon/vmnet.sock: no such file or directory

[hostagent] Waiting for the essential requirement 1 of 5: "ssh" [hostagent] Waiting for the essential requirement 1 of 5: "ssh" [hostagent] Waiting for the essential requirement 1 of 5: "ssh" [hostagent] Waiting for the essential requirement 1 of 5: "ssh" [hostagent] Waiting for the essential requirement 1 of 5: "ssh" [hostagent] Waiting for the essential requirement 1 of 5: "ssh"`

Orgil commented 1 year ago

@abiosoft exact same error i get when i tried to compile. please make it possible to configurable.

chrisRedwine commented 1 year ago

I have an unconfirmed theory that this might be the cause of some interference I've noticed between running colima and microk8s/multipass (which also uses the 192.160.106.x range) simultaneously on macOS.

katzelad commented 2 months ago

@abiosoft Was there any progress with this? I also need to use Colima with Testcontainers alongside a corporate VPN and this is a major blocker preventing me to do so. Is there any workaround other than compilation from source? Thanks

splazit commented 2 months ago

Btw, I no longer need to use Colima and opted for using Lima with the Rancher ISO image. It’s lighter and been working quite well for me.

From: Elad @.> Date: Monday, July 22, 2024 at 8:32 AM To: abiosoft/colima @.> Cc: Hieu Nguyen @.>, Mention @.> Subject: Re: [abiosoft/colima] Custom network range when using --network-address (Issue #573)

@abiosofthttps://github.com/abiosoft Was there any progress with this? I also need to use Colima with Testcontainers alongside a corporate VPN and this is a major blocker preventing me to do so. Is there any workaround other than compilation from source? Thanks

— Reply to this email directly, view it on GitHubhttps://github.com/abiosoft/colima/issues/573#issuecomment-2243111386, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AAAXNU74JWNBO4S44XMSQIDZNUJXRAVCNFSM6AAAAABLIOP3J2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDENBTGEYTCMZYGY. You are receiving this because you were mentioned.Message ID: @.***>