colima icon indicating copy to clipboard operation
colima copied to clipboard

Change default bridge subnet with containerd runtime

Open obeone opened this issue 3 years ago • 3 comments

Describe the Issue

The default bridge subnet is 10.4.0.0/24, and it's a big problem for me : I already use this subnet... I can't find how to change it

Version

Colima Version:

colima version 0.4.2 git commit: f112f336d05926d62eb6134ee3d00f206560493b

runtime: containerd arch: x86_64 client: v0.20.0 server: v1.5.8

Lima Version:

limactl version 0.11.0

Qemu Version

qemu-img version 7.0.0

Operating System

  • [X] macOS Intel
  • [ ] macOS m1
  • [ ] Linux

To Reproduce

Steps to reproduce the behavior:

  1. run colima start

Expected behavior

Having the ability to choose the default bridge subnet

obeone avatar Jun 05 '22 23:06 obeone

I have not considered this before, I can see that it is the default config for containerd https://github.com/containerd/nerdctl/blob/ae1399aee52c79ac5294769577db322e116d2cf2/docs/cni.md#basic-networks.

You can easily create a separate network with a different subnet e.g.

nerdctl network create mynet --driver bridge --subnet=10.100.5.0/24

However, it does not look like the default can be overridden. You would need to specify the network (e.g. --net=mynet) for your containers.

An issue can be created on the nerdctl project https://github.com/containerd/nerdctl for this.

abiosoft avatar Jun 06 '22 07:06 abiosoft

I opened a ticket (https://github.com/containerd/nerdctl/issues/1091)

I found a quick and dirty solution on a linux host with bare containerd/nerdctl

nerdctl network ls
NETWORK ID    NAME                  FILE
0             bridge
0             bridge                /etc/cni/net.d/nerdctl-bridge.conflist
              host
              none

By creating a config file and setting same ID and name, it use this bridge (yep, clearly dirty !). But I didn’t found where cni/net.d are stored in colima

obeone avatar Jun 06 '22 12:06 obeone

You can do that by creating the file in same location in the VM.

You can enter the VM with colima ssh and use vi or install any editor of choice with apk e.g.apk add nano.

abiosoft avatar Jun 06 '22 12:06 abiosoft