containerd / containerd/nerdctl
Automatically start dhcp daemon in CNI_PATH
- Dominant language
- Go
- Stars
- 10.4k
- Forks
- 826
- Avg merge
- 1d 23h
- Merged PRs (30d)
- 44
Description
### What is the problem you're trying to solve
Currently you have to manually start the dhcp daemon (which is available inside `/libexec/cni` in the `nerdctl-full` releases).
When creating a macvlan network with dhcp enabled according to [the example in the docs](https://github.com/containerd/nerdctl/blob/main/docs/cni.md#macvlanipvlan-networks), `nerdctl` will show a warning and a hint:
```
nerdctl network create mac0 --driver macvlan --ipam-driver=dhcp
WARN[0000] cannot access dhcp socket "/run/cni/dhcp.sock" (hint: try running with `dhcp daemon --socketpath=/run/cni/dhcp.sock &` in CNI_PATH to launch the dhcp daemon)
1959a5c1a248f97c3e8bf5ad06e6335c57ad811b04470f086840600d575c2cd1
```
When trying to start a container with this network, an error will be thrown (unless I manually start the dhcp daemon with the command suggested in the hint):
```
nerdctl run -d --name nginx --net mac0 nginx:alpine
FATA[0000] failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: error during container init: error running hook #0: error running hook: exit status 1, stdout: , stderr: time="2023-08-31T20:00:04+02:00" level=fatal msg="failed to call cni.Setup: plugin type=\"macvlan\" failed (add): error dialing DHCP daemon: dial unix /run/cni/dhcp.sock: connect: connection refused"
Failed to write to log, write /var/lib/nerdctl/1935db59/containers/default/5b8708fdabf45d58d5d58e74964ecc906d52615abc21aa42bb64f57de2317ffb/oci-hook.createRuntime.log: file already closed: unknown
```
### Describe the solution you'd like
It would be convenient if `nerdctl` could start the dhcp daemon when it realizes it's required by the container it tries to start. The `CNI_PATH` is known to the `nerdctl` command, so it should already know where to find the dhcp binary.
### Additional context
I'm trying to [start containerd + nerdctl in a portable way](https://github.com/Jip-Hop/ubernerd). Therefore it would be great if there's an options to specify the daemonSocketPath when creating the network, to prevent using the default: /run/cni/dhcp.sock. This still needs to be implemented according to this TODO:
https://github.com/containerd/nerdctl/blob/7f88bdd002dbd4d6ae6f33e110d4f5da06cd16ee/pkg/netutil/netutil_unix.go#L184-L185
But I suppose that would be another feature request.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.