Giter Site home page Giter Site logo

devplayer0 / docker-net-dhcp Goto Github PK

View Code? Open in Web Editor NEW
196.0 10.0 55.0 266 KB

Docker network driver for networking on a host bridge with DHCP-allocated IP addresses

License: GNU General Public License v3.0

Dockerfile 0.82% Makefile 2.51% Python 14.22% Go 80.66% Shell 1.79%

docker-net-dhcp's Introduction

docker-net-dhcp

docker-net-dhcp is a Docker plugin providing a network driver which allocates IP addresses (IPv4 and optionally IPv6) via an existing DHCP server (e.g. your router).

When configured correctly, this allows you to spin up a container (e.g. docker run ... or docker-compose up ...) and access it on your network as if it was any other machine! Probably not a great idea for production, but it's pretty handy for home deployment.

Usage

Installation

The plugin can be installed with the docker plugin install command:

$ docker plugin install ghcr.io/devplayer0/docker-net-dhcp:release-linux-amd64
Plugin "ghcr.io/devplayer0/docker-net-dhcp:release-linux-amd64" is requesting the following privileges:
 - network: [host]
 - host pid namespace: [true]
 - mount: [/var/run/docker.sock]
 - capabilities: [CAP_NET_ADMIN CAP_SYS_ADMIN CAP_SYS_PTRACE]
Do you grant the above permissions? [y/N] y
release-linux-amd64: Pulling from ghcr.io/devplayer0/docker-net-dhcp
Digest: sha256:<some hash>
<some id>: Complete
Installed plugin ghcr.io/devplayer0/docker-net-dhcp:release-linux-amd64
$

Note: If you get an error like invalid rootfs in image configuration, try upgrading your Docker installation.

Other tags

There are a number of supported tags for different architectures and versions, the format is <version>-<os>-<architecture>. For example, latest-linux-arm-v7 would install the newest build for ARMv7 (e.g. for Raspberry Pi).

Version

  • release: The latest release (can be upgraded via docker plugin upgrade)
  • x.y.z: A specific (semver) release (e.g. 0.1.0)
  • latest: Build of the newest commit

OS

Currently only linux is supported.

Architecture

  • amd64: Intel / AMD 64-bit
  • 386: Intel / AMD legacy 32-bit
  • arm64-v8: ARMv8 64-bit
  • arm-v7: ARMv7 (e.g. Raspberry Pi)

Unfortunately Docker plugin images don't support multiple architectures per tag.

Network creation

In order to create a Docker network using net-dhcp, you'll need a pre-configured bridge interface on the host. How you set this up will depend on your system, but the following (manual) instructions should work on most Linux distros:

# Create the bridge
$ sudo ip link add my-bridge type bridge
$ sudo ip link set my-bridge up

# Assuming 'eth0' is connected to your LAN (where the DHCP server is)
$ sudo ip link set eth0 up
# Attach your network card to the bridge
$ sudo ip link set eth0 master my-bridge

# If your firewall's policy for forwarding is to drop packets, you'll need to add an ACCEPT rule
$ sudo iptables -A FORWARD -i my-bridge -j ACCEPT

# Get an IP for the host (will go out to the DHCP server since eth0 is attached to the bridge)
# Replace this step with whatever network configuration you were using for eth0
$ sudo dhcpcd my-bridge

Once the bridge is ready, you can create the network:

$ docker network create -d ghcr.io/devplayer0/docker-net-dhcp:release-linux-amd64 --ipam-driver null -o bridge=my-bridge my-dhcp-net
<some network id>
$

# With IPv6 enabled
# Although `docker network create` has a `--ipv6` flag, it doesn't work with the null IPAM driver
$ docker network create -d ghcr.io/devplayer0/docker-net-dhcp:release-linux-amd64 --ipam-driver null -o bridge=my-bridge -o ipv6=true my-dhcp-net
<some network id>
$

Note: The null IPAM driver must be used, or else Docker will try to allocate IP addresses from its choice of subnet - this can cause IP conflicts since the bridge is connected to your local network!

Container creation

Once you've set up a network, you can create some containers:

$ docker run --rm -ti --network my-dhcp-net alpine
/ # ip address show
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
159: my-bridge0@if160: <BROADCAST,MULTICAST,UP,LOWER_UP,M-DOWN> mtu 1500 qdisc noqueue state UP qlen 1000
    link/ether 86:41:68:f8:85:b9 brd ff:ff:ff:ff:ff:ff
    inet 10.255.0.246/24 brd 10.255.0.255 scope global test0
       valid_lft forever preferred_lft forever
/ # ip route show
default via 10.255.0.123 dev my-bridge0
10.255.0.0/24 dev my-bridge0 scope link  src 10.255.0.246
/ #

Or, in a Docker Compose file:

version: '3'
services:
  app:
    hostname: my-http
    image: nginx
    mac_address: 86:41:68:f8:85:b9
    networks:
      - dhcp
networks:
  dhcp:
    external:
      name: my-dhcp-net

The above Compose file assumes your network has already been created with docker network create. This is the recommended way to use docker-net-dhcp, since it allows the network to be shared among multiple compose projects and other containers. However, you can also create the network as part of the Compose definition. In this case Docker Compose will manage the network itself (for example deleting it when docker-compose down is run).

version: '3'
services:
  app:
    image: nginx
    hostname: my-server
    networks:
      - dhcp
networks:
  dhcp:
    driver: ghcr.io/devplayer0/docker-net-dhcp:release-linux-amd64
    driver_opts:
      bridge: my-bridge
      ipv6: 'true'
      ignore_conflicts: 'false'
      skip_routes: 'false'
    ipam:
      driver: 'null'

Note:

  • It will take a bit longer than usual for the container to start, as a DHCP lease needs to be obtained before creating it
  • Once created, a persistent DHCP client will renew the DHCP lease (and then update the default gateway in the container) when necessary - this client runs separately from the container
  • Use --mac-address to specify a MAC address if you've configured reserved IP addresses on your DHCP server, or if you want a container to re-use an old lease
  • Add --hostname my-host to have the DHCP transmit this name as the host for the container. This is useful if your DHCP server is configured to update DNS records from DHCP leases.
  • If the docker run command times out waiting for a lease, you can try increasing the initial timeout value by passing -o lease_timeout=60s when creating the network (e.g. to increase to 60 seconds)
  • By default, a bridge can only be used for a single DHCP network. There is additionally a check to see if a bridge is is used by any other Docker networks. To disable this check (it's also possible this check might mistakenly detect a conflict), pass -o ignore_conflicts=true when creating the network.
  • docker-net-dhcp will try to copy static routes from the host bridge to the container. To disable this behaviour, pass -o skip_routes=true when creating the network.

Debugging

To read the plugin's log, do cat /var/lib/docker/plugins/*/rootfs/var/log/net-dhcp.log (as root). You can also use docker plugin set ghcr.io/devplayer0/docker-net-dhcp:release-linux-amd64 LOG_LEVEL=trace to increase log verbosity.

Implementation

Fundamentally, the same mechanism is used by net-dhcp as Docker's bridge driver to wire up networking to containers. That is, a bridge on the host is used as a switch so that containers can communicate with each other - veth pairs connect each container's network namespace to the bridge.

  • While Docker creates and manages its own bridges (and routes and filters traffic), net-dhcp uses an existing bridge on the host, bridged with the desired local network.
  • Instead of allocating IP addresses from a static pool stored on the Docker host, net-dhcp relies on an external DHCP server to provide IP addresses

Flow

  1. Container creation request is made
  2. A veth pair is created and the host end is connected to the bridge (at this point both interfaces are still in the host namespace)
  3. A DHCP client (BusyBox udhcpc) is started on the container end (still in the host namespace) - initial IP address is provided to Docker by the plugin
  4. Docker moves the container end of the veth pair into the container's network namespace and sets the IP address - at this point udhcpc must be stopped
  5. net-dhcp starts udhcpc on the container end of the veth pair in the container's network namespace (but still in the plugin PID namespace - this means that the container can't see the DHCP client)
  6. udhcpc continues to run, renewing the lease when required, until the container shuts down

docker-net-dhcp's People

Contributors

200success avatar devplayer0 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

docker-net-dhcp's Issues

Host system not not reachable anymore after a while

I have performed the setup as suggested in "Network creation" as well as creating the network.
After container creation, things seem to work perfectly, but after a while, I lose connectivity to the host system, I cannot reach the docker host.
The containers running seem to be ok and running. The host system network is not reachable anymore.

The docker host is a raspberry pi 4/4GB
Docker version is 20.10.11, build dea9396

The network connection is lost after running ip link command.

After running command

sudo ip link set eth0 master my-bridge

my server`s ssh connect is lost and can not ssh again.

I use the ipmi tool to log in to the server and run this command

sudo iptables -A FORWARD -i my-bridge -j ACCEPT

but this did not fix my problem.

My server does not have the dhcpcd command, because the server has been disconnected from the network and this command cannot be installed. I used the dhclient command to re-obtain the IP address. Now ssh can work, but there is still no network connection, so the dhchcd command cannot be installed.

RTNETLINK answers: Operation not supported

Hello @devplayer0 :)
I'm trying to setup your Docker plugin to give an own IP to every container of mine.
The most tedious problem is that I'm running Docker on a Synology NAS (DS920+, so Intel Gemini Lake CPU), and the preinstalled network tools seem quite limited.
In particular, you guide give me error attaching the eth0 network card to the newly created bridge.
After som googling, seems that some kernel modules are lacking, but I'm not sure how to proceed (which modules? how to compile them correctly in a pretty "close" environemnt like a Syno NAS, without a proper package manager?)
Could you please give me an hand?
Thanks in advance :)

root@DS:~#docker plugin install devplayer0/net-dhcp
Plugin "devplayer0/net-dhcp" is requesting the following privileges:
 - network: [host]
 - host pid namespace: [true]
 - mount: [/var/run/docker.sock]
 - capabilities: [CAP_NET_ADMIN CAP_SYS_ADMIN CAP_SYS_PTRACE CAP_SYS_RESOURCE]
Do you grant the above permissions? [y/N] Y
latest: Pulling from devplayer0/net-dhcp
f20d1e188e68: Download complete
Digest: sha256:fe6055ff762181da6a358dad689c6a8cfd5fa3687a3a1da9c4cec894eea6f41a
Status: Downloaded newer image for devplayer0/net-dhcp:latest
Installed plugin devplayer0/net-dhcp
root@DS:~# sudo ip link add dhcp-bridge type bridge
root@DS:~# sudo ip link set dhcp-bridge up
root@DS:~# sudo ip link set eth0 up
root@DS:~# sudo ip link set eth0 master dhcp-bridge
RTNETLINK answers: Operation not supported

I can set my physical network card as master to bridge card

b605@b605-HP-Z8-G4:~$ sudo ip link set eno1 master neu-bridge
RTNETLINK answers: Device or resource busy

and my config of network:
docker0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 172.17.0.1 netmask 255.255.0.0 broadcast 172.17.255.255
inet6 fe80::42:5dff:fe39:9568 prefixlen 64 scopeid 0x20
ether 02:42:5d:39:95:68 txqueuelen 0 (以太网)
RX packets 9285893 bytes 12491863784 (12.4 GB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 19893211 bytes 21876361822 (21.8 GB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

eno1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 219.216.64.199 netmask 255.255.255.0 broadcast 219.216.64.255
inet6 2001:da8:9000:a806:fbd3:4d6c:4f05:99e7 prefixlen 64 scopeid 0x0
inet6 2001:da8:9000:a806:7824:266:facc:9a0c prefixlen 64 scopeid 0x0
inet6 fe80::8e85:7289:1036:514d prefixlen 64 scopeid 0x20
ether 00:68:eb:c1:d1:04 txqueuelen 1000 (以太网)
RX packets 15263623 bytes 16110665592 (16.1 GB)
RX errors 0 dropped 14019 overruns 0 frame 0
TX packets 13545958 bytes 11349820611 (11.3 GB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
device interrupt 16 memory 0x90300000-90320000

enp4s0f2: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
ether 00:68:eb:c1:d1:07 txqueuelen 1000 (以太网)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10
loop txqueuelen 1000 (本地环回)
RX packets 28836 bytes 3205847 (3.2 MB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 28836 bytes 3205847 (3.2 MB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

neu-bridge: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet6 fe80::5cee:4ff:fe81:a3d9 prefixlen 64 scopeid 0x20
ether 5e:ee:04:81:a3:d9 txqueuelen 1000 (以太网)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 100 bytes 14296 (14.2 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

veth3752600: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet6 fe80::74d2:36ff:fe3b:6a1d prefixlen 64 scopeid 0x20
ether 76:d2:36:3b:6a:1d txqueuelen 0 (以太网)
RX packets 167082 bytes 457788318 (457.7 MB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 416829 bytes 306314984 (306.3 MB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

veth57d7fe5: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet6 fe80::bccb:f9ff:fe81:c817 prefixlen 64 scopeid 0x20
ether be:cb:f9:81:c8:17 txqueuelen 0 (以太网)
RX packets 20035 bytes 29285453 (29.2 MB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 21689 bytes 2286508 (2.2 MB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

vethb552f4b: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet6 fe80::ec6c:55ff:fe11:2dc9 prefixlen 64 scopeid 0x20
ether ee:6c:55:11:2d:c9 txqueuelen 0 (以太网)
RX packets 1334312 bytes 4002039826 (4.0 GB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 2469845 bytes 2983138662 (2.9 GB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

License?

What license is this plugin under? I could not find that information anywhere in this repo.

Thanks for the great project though!

NetworkDriver.CreateNetwork: 172.20.0.1/16 has host bits set

Fresh git clone of project
make install
docker network create -d devplayer0/net-dhcp:latest --ipam-driver=null -o bridge=br0 test-net

returns: Error response from daemon: NetworkDriver.CreateNetwork: 172.20.0.1/16 has host bits set
The address is that of my docker0 network.
644: docker0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default
link/ether 02:42:6c:62:49:62 brd ff:ff:ff:ff:ff:ff
inet 172.20.0.1/16 brd 172.20.255.255 scope global docker0
valid_lft forever preferred_lft forever

docker --version: Docker version 19.03.8, build afacb8b7f0

I realise this is not enough to work on. Happy to provide additional information, I'm just not sure what would be useful here.

Unable to create more than one network of this type.

Currently, I have several linux bridges configured in my centos installation, configured as such:

3: br0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
link/ether 00:00:00:00:00:00 brd ff:ff:ff:ff:ff:ff
inet 10.1.0.254/24 brd 10.1.0.255 scope global br0
valid_lft forever preferred_lft forever
4: br1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
link/ether 00:13:95:27:b1:4d brd ff:ff:ff:ff:ff:ff
inet 192.168.1.120/24 brd 192.168.1.255 scope global dynamic br1
valid_lft 77484sec preferred_lft 77484sec

In this case, br0 is not attached to any external network devices, but instead we have dnsmasq running to provide dhcp services for br0.
br1 is bridged to eth0 which is an external device connected to my router which obviously provides dhcp services for eth0 (any any interfaces connected to br1).

The error I get is "Error response from daemon: NetworkDriver.CreateNetwork: bridge already in use by Docker"
However as far as I can tell, docker is not using either of those bridges for anything else.

I can create a docker 'dhcp' network just fine by using either of those bridges. However once I have created a network using one of those bridges, I can't create another network using the other bridge. My end goal is to be able to create a network for each bridge, and attached each network to a running container so it would have 2 network interfaces - each connected to one of the above bridges, and with IP addresses issued via dhcp from each of those bridges.

Is this possible to do? Or is there some technical reason why we won't be able to create two separate docker networks of this type?

Thanks.

"docker network create" requires exactly 1 argument. error.

Fresh os & docker installation on RPI . My executed commands are:

docker plugin install ghcr.io/devplayer0/docker-net-dhcp:latest-linux-arm-v7
sudo ip link add my-bridge type bridge
sudo ip link set my-bridge up
sudo ip link set eth0 up
sudo ip link set eth0 master my-bridge
sudo iptables -A FORWARD -i docker-bridge -j ACCEPT
sudo dhcpcd docker-bridge

On the first try after this point ssh connection got disconnected. "disconnect: Broken pipe". I have to power cycle my RPI.
Also, not sure is this applicable on raspbian:
sudo iptables -A FORWARD -i docker-bridge -j ACCEPT

On the second try after entering

docker network create -d ghcr.io/devplayer0/docker-net-dhcp:latest-linux-arm-v7 --ipam-driver null -o bridge=my-bridge docker-dhcp-net 1050

yields "docker network create" requires exactly 1 argument.
See 'docker network create --help'.

Also, it will be nice to clarify what does represents. Probably, its the ID generated at the very beginning (after the first command". Adding that ID also produce the same error.

Docker service down after update

I have enabled your plugin with a bridge to obtain an DHCP address, it works nicely to have a pihole container with a real IP, but when I update docker on a centos7 (NethServer), the service docker fails to restart. I must restart the server to have the service up.

this is the gist of the messages log after the upgrade: https://gist.github.com/stephdl/11a7c903acef0ce25bd0498349fb3bad

upgraded from :

docker-ce-19.03.8-3.el7.x86_64      
containerd.io-1.2.6-3.3.el7.x86_64     
docker-ce-cli-19.03.8-3.el7.x86_64      

upgraded to :

containerd.io-1.2.13-3.2.el7.x86_64     
docker-ce-cli-19.03.11-3.el7.x86_64    
docker-ce-19.03.11-3.el7.x86_64 

Is it possible to set up this plugin along one interface in host mode?

First of all, I would like to congratulate the contributors of this amazing project.

My settings are the following:

  • I have a host with three interfaces: eth0, eth1 and eth2.
  • I need to interface a container with eth0 and eth1
  • On the eth0 interface there is a network with a dhcp server (10.10.0.0) . I need to set up the container with an IP from this network.
  • The eth1 interface is attached to a single board computer with static IP 192.168.1.3 (a robot)

Is it possible to expose to the container one interface with dhcp connected to the 10.10.0.0 network and a second interface eth1 in host mode?

A possible solution

I think that it is possible to create a bridge and bind both eth0 and eth1 to it with brctl addif bridge0 eth0 && brctl addif bridge0 eth0 and create the network with this bridge. Then I can hope that although I have one interface exposed into the container, the bridge will route the packages to the correct interface.

Documentation improvement

Hello!

For some reason I had to perform the following setting in order to have the DHCP client working.
sysctl -w net.bridge.bridge-nf-call-iptables=0

Otherwise I kept having the following error :
NetworkDriver.CreateEndpoint: failed to get initial IP address via DHCP: context deadline exceeded.

;-)

invalid rootfs in image configuration

On Arm Devices (I tested it with 2 Pi's) I get the following error:

$ sudo docker plugin install ghcr.io/devplayer0/docker-net-dhcp:release-linux-arm-v7
Error response from daemon: invalid rootfs in image configuration

Jun 11 17:05:57 raspberrypi dockerd[463]: time="2021-06-11T17:05:57.310918436+02:00" level=info msg="Attempting next endpoint for pull after error: invalid rootfs in image configuration"
Jun 11 17:05:57 raspberrypi dockerd[463]: time="2021-06-11T17:05:57.311169098+02:00" level=error msg="Handler for GET /v1.39/plugins/privileges returned error: invalid rootfs in image configuration"

On an x86 machine it worked for me.

Pi 1: Docker version 18.09.1, build 4c52b90
Pi 2: Docker version 19.03.15, build 99e3ed8919
x86: Docker version 20.10.7, build f0df350

help with generic error messages

Hi,

I'm using your plugin following your instructions but I'm getting very generic error messages during the container creation, for example:

docker run --rm -it --network dhcp-modem-net01 --name centos-test0 centos
docker: Error response from daemon: failed to create endpoint centos-test0 on network dhcp-net01: NetworkDriver.CreateEndpoint: local variable 'res' referenced before assignment.

or

docker: Error response from daemon: failed to create endpoint centos-test0 on network dhcp-net01: NetworkDriver.CreateEndpoint: 400 Bad Request: The browser (or proxy) sent a request that this server could not understand.

I'm not sure how can I start debugging those issues, any tip?

Thanks,

Federico.

Hang when containers set to start automatically

Thanks for this project - it is great. I have noticed a small problem however:

When a container uses this plugin, and its restart policy makes the container start automatically when Docker starts, this plugin appears to hang. This prevents the container from starting, and seems to block the Docker daemon from responding too. If I kill this plugin's process, Docker seems to recover (but the container obviously doesn't come up properly).

If the container is not set to start automatically, and I instead start it manually, everything works fine.

I have narrowed the problem down to this line - it seems the call to NetworkInspect never returns, even after several hours.

I thought the problem might be a race condition, where the network was not fully up before the plugin tries to inspect it. However, inserting a delay before the call does not appear to help.

The logs do not provide any clues.

Because the Docker daemon stops responding, I am unfortunately not able to get a stack trace from it.

Please could you let me know how I might diagnose the problem further? I'm using up to date versions of Docker, Ubuntu and the kernel. The only complicating factor is that it's on an armv7l SBC 🙈

Many thanks

Help wanted!

Hi @devplayer0 !

How is going with the golang version? Is the golang branch ready to run?

I am currently doing an experiment on my wireless bandwidth allocation system, and want to use docker containers to simulate the users. The problem I am facing is how to allocate IP address using the DHCP service on my router. So, the router can see the IP address of containers and control the bandwidth of them accordingly.

After days of searching and testing, I found you repo, which should perfectly solve my problem. But following your configuration guide, I got stuck on the last step like #2.

Set up commands:

root@aaron-ubuntu:/home/aaron/Downloads/docker# ip link add my-bridge type bridge
root@aaron-ubuntu:/home/aaron/Downloads/docker# ip link set my-bridge up
root@aaron-ubuntu:/home/aaron/Downloads/docker# ifconfig
docker0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        inet 172.17.0.1  netmask 255.255.0.0  broadcast 172.17.255.255
        ether 02:42:fe:25:45:2c  txqueuelen 0  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

enp0s25: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.1.72  netmask 255.255.255.0  broadcast 192.168.1.255
        ether 28:xxxxxxxxxxx:3f  txqueuelen 1000  (Ethernet)
        RX packets 89696  bytes 128312381 (128.3 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 12962  bytes 1441554 (1.4 MB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
        device interrupt 20  memory 0xf1500000-f1520000  

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 170  bytes 13353 (13.3 KB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 170  bytes 13353 (13.3 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

my-bridge: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 169.254.143.243  netmask 255.255.0.0  broadcast 169.254.255.255
        ether be:d9:5a:25:a5:c7  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 38  bytes 6374 (6.3 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

wlp3s0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        ether f4:b7:e2:c8:11:09  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

root@aaron-ubuntu:/home/aaron/Downloads/docker# ip link set enp0s25 up
root@aaron-ubuntu:/home/aaron/Downloads/docker# ip link set enp0s25 master my-bridge
root@aaron-ubuntu:/home/aaron/Downloads/docker# dhcpcd my-bridge
sending commands to master dhcpcd process
root@aaron-ubuntu:/home/aaron/Downloads/docker# ifconfig
docker0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        inet 172.17.0.1  netmask 255.255.0.0  broadcast 172.17.255.255
        ether 02:42:fe:25:45:2c  txqueuelen 0  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

enp0s25: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.1.72  netmask 255.255.255.0  broadcast 192.168.1.255
        ether 28:xxxxxxxxxxx:3f  txqueuelen 1000  (Ethernet)
        RX packets 89696  bytes 128312381 (128.3 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 12962  bytes 1441554 (1.4 MB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
        device interrupt 20  memory 0xf1500000-f1520000  

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 170  bytes 13353 (13.3 KB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 170  bytes 13353 (13.3 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

my-bridge: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 169.254.143.243  netmask 255.255.0.0  broadcast 169.254.255.255
        ether 28:xxxxxxxxxxx:3f  txqueuelen 1000  (Ethernet)
        RX packets 17  bytes 1022 (1.0 KB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 45  bytes 7814 (7.8 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

root@aaron-ubuntu:/home/aaron/Downloads/docker# docker network create -d devplayer0/net-dhcp:latest --ipam-driver null -o bridge=my-bridge my-dhcp-net
3c107622e099b754586c483073b1cb517d14ec8541d4fec047fd18aa2bd0240f
root@aaron-ubuntu:/home/aaron/Downloads/docker# ./docker  run --rm -ti --network my-dhcp-net alpine
./docker: Error response from daemon: failed to create endpoint charming_roentgen on network my-dhcp-net: NetworkDriver.CreateEndpoint: Timed out waiting for lease from udhcpc.

Below is the log:

root@aaron-ubuntu:/home/aaron/Downloads/docker# ./dockerd
INFO[2020-08-06T17:20:08.192055121+07:00] Starting up                                  
INFO[2020-08-06T17:20:08.193839368+07:00] parsed scheme: "unix"                         module=grpc
INFO[2020-08-06T17:20:08.193880534+07:00] scheme "unix" not registered, fallback to default scheme  module=grpc
INFO[2020-08-06T17:20:08.193990954+07:00] ccResolverWrapper: sending update to cc: {[{unix:///run/containerd/containerd.sock 0  <nil>}] }  module=grpc
INFO[2020-08-06T17:20:08.194008171+07:00] ClientConn switching balancer to "pick_first"  module=grpc
INFO[2020-08-06T17:20:08.194096651+07:00] pickfirstBalancer: HandleSubConnStateChange: 0xc0008cc770, CONNECTING  module=grpc
INFO[2020-08-06T17:20:08.194113055+07:00] blockingPicker: the picked transport is not ready, loop back to repick  module=grpc
INFO[2020-08-06T17:20:08.194609079+07:00] pickfirstBalancer: HandleSubConnStateChange: 0xc0008cc770, READY  module=grpc
INFO[2020-08-06T17:20:08.195795715+07:00] parsed scheme: "unix"                         module=grpc
INFO[2020-08-06T17:20:08.195880981+07:00] scheme "unix" not registered, fallback to default scheme  module=grpc
INFO[2020-08-06T17:20:08.195950908+07:00] ccResolverWrapper: sending update to cc: {[{unix:///run/containerd/containerd.sock 0  <nil>}] }  module=grpc
INFO[2020-08-06T17:20:08.196014803+07:00] ClientConn switching balancer to "pick_first"  module=grpc
INFO[2020-08-06T17:20:08.196270999+07:00] pickfirstBalancer: HandleSubConnStateChange: 0xc000622590, CONNECTING  module=grpc
INFO[2020-08-06T17:20:08.196324870+07:00] blockingPicker: the picked transport is not ready, loop back to repick  module=grpc
INFO[2020-08-06T17:20:08.197008530+07:00] pickfirstBalancer: HandleSubConnStateChange: 0xc000622590, READY  module=grpc
ERRO[0000]  * Running on unix:///run/docker/plugins/net-dhcp.sock (Press CTRL+C to quit)  plugin=03e99022fe5f1af88120c3e1044dadc75700a4c7c1ea39255ff1f00a9759a9a4
INFO[2020-08-06T17:20:11.844785741+07:00] [graphdriver] using prior storage driver: overlay2 
WARN[2020-08-06T17:20:11.861201865+07:00] Your kernel does not support swap memory limit 
WARN[2020-08-06T17:20:11.861260750+07:00] Your kernel does not support cgroup rt period 
WARN[2020-08-06T17:20:11.861289163+07:00] Your kernel does not support cgroup rt runtime 
WARN[2020-08-06T17:20:11.861309454+07:00] Your kernel does not support cgroup blkio weight 
WARN[2020-08-06T17:20:11.861327408+07:00] Your kernel does not support cgroup blkio weight_device 
INFO[2020-08-06T17:20:11.861687592+07:00] Loading containers: start.                   
ERRO[0003] <local> - - [06/Aug/2020 10:20:11] "POST /NetworkDriver.GetCapabilities HTTP/1.1" 200 -  plugin=03e99022fe5f1af88120c3e1044dadc75700a4c7c1ea39255ff1f00a9759a9a4
INFO[2020-08-06T17:20:12.004358538+07:00] Default bridge (docker0) is assigned with an IP address 172.17.0.0/16. Daemon option --bip can be used to set a preferred IP address 
INFO[2020-08-06T17:20:12.054813245+07:00] Loading containers: done.                    
INFO[2020-08-06T17:20:12.104819838+07:00] Docker daemon                                 commit=aeac9490dc graphdriver(s)=overlay2 version=19.03.0
INFO[2020-08-06T17:20:12.104910408+07:00] Daemon has completed initialization          
INFO[2020-08-06T17:20:12.172001924+07:00] API listen on /var/run/docker.sock           
ERRO[0272] <local> - - [06/Aug/2020 10:24:40] "POST /NetworkDriver.CreateNetwork HTTP/1.1" 200 -  plugin=03e99022fe5f1af88120c3e1044dadc75700a4c7c1ea39255ff1f00a9759a9a4
ERRO[0317] <local> - - [06/Aug/2020 10:25:26] "POST /NetworkDriver.CreateEndpoint HTTP/1.1" 500 -  plugin=03e99022fe5f1af88120c3e1044dadc75700a4c7c1ea39255ff1f00a9759a9a4
WARN[2020-08-06T17:25:26.126010029+07:00] 638a28b2d97b0408df2c8f05c498e5ee6881b385f872ffd37d5ba1108475349b cleanup: failed to unmount IPC: umount /var/lib/docker/containers/638a28b2d97b0408df2c8f05c498e5ee6881b385f872ffd37d5ba1108475349b/mounts/shm, flags: 0x2: no such file or directory 
ERRO[2020-08-06T17:25:26.135476524+07:00] 638a28b2d97b0408df2c8f05c498e5ee6881b385f872ffd37d5ba1108475349b cleanup: failed to delete container from containerd: no such container 
ERRO[2020-08-06T17:25:26.140326173+07:00] Handler for POST /v1.40/containers/638a28b2d97b0408df2c8f05c498e5ee6881b385f872ffd37d5ba1108475349b/start returned error: failed to create endpoint charming_roentgen on network my-dhcp-net: NetworkDriver.CreateEndpoint: Timed out waiting for lease from udhcpc 

Could you help to localize the error I might have? I got no internet connection after command ip link set enp0s25 master my-bridge

Could you release a golang (stable) version or give some instructions on how to compile the golang branch locally?

Looking forward to your reply and I appreciate your help very much!

Dockerd hangs when starting up with docker-net-dhcp enabled

The plugin works fine when creating new containers.
If I have an pre-existing container with a dhcp network assigned, when dockerd is started, the entire dockerd daemon becomes unresponsive when acquiring an address.

When started using dockerd -l debug

DEBU[2024-01-30T11:31:24.182790475+01:00] EnableService 66264b3f1f650a2a3ffa050c87cb63fe80dc1333f7650fd17eadb5f9d4d0647d START 
DEBU[2024-01-30T11:31:24.182815499+01:00] EnableService 66264b3f1f650a2a3ffa050c87cb63fe80dc1333f7650fd17eadb5f9d4d0647d DONE 
DEBU[2024-01-30T11:31:24.183107384+01:00] Assigning addresses for endpoint nginx_2's interface on network virbr0 

Any call to the API or on commandline just hangs, e.g. docker ps.

Disabling the plugin resolves the issue. It also seems to be hidden -occasionally- when using debug mode, so there might be a timing or race condition involved.

New error with latest Docker.

Error response from daemon: NetworkDriver.CreateNetwork: failed to retrieve list of networks from Docker: Error response from daemon: client version 1.13.1 is too old. Minimum supported API version is 1.24, please upgrade your client to a newer version

crkinard@thing1: /srv :$ docker version
Client: Docker Engine - Community
 Version:           25.0.1
 API version:       1.44
 Go version:        go1.21.6
 Git commit:        29cf629
 Built:             Tue Jan 23 23:09:23 2024
 OS/Arch:           linux/amd64
 Context:           default

Server: Docker Engine - Community
 Engine:
  Version:          25.0.1
  API version:      1.44 (minimum version 1.24)
  Go version:       go1.21.6
  Git commit:       71fa3ab
  Built:            Tue Jan 23 23:09:23 2024
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.6.27
  GitCommit:        a1496014c916f9e62104b33d1bb5bd03b0858e59
 runc:
  Version:          1.1.11
  GitCommit:        v1.1.11-0-g4bccb38
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0
networks:
  lan_dhcp:
    name: lan_dhcp
    driver: docker-net-dhcp:latest
    driver_opts:
      bridge: br0
    ipam:
      driver: "null"

Issues with DNS in Docker w/ this module?

I have an odd issue. Using this container with --net=host works fine, but when I try to launch the plexinc/pms-docker image, it fails to start properly because no DNS is resolved in the container and the software breaks hard. It appears to have /etc/resolv.conf pointing to 127.0.0.11, which is Docker's built-in forward to it's DNS server, and if I watch the system logs for it, it appears to fail at setting up some iptables rules for forwarding that (see attached system logs excerpt). It may be of note that my host system uses nftables (nixos 21.11). If I pop into a shell in the container, I can't resolve any hostnames at all. It's not clear why this container would have this problem. It appears that it may be caused by my nixos config, that may be trying to lock down the systemd service running the container. I see a related issue with similar looking error. Is there a way to disable trying to use Docker's DNS forwarding and just directly configure DNS over the bridge?

Thanks

journald.logs.docker.issue.txt

IPAM driver ?

Hello,

First of all thank you for the new implementation !
Many dreamed of it and you've delivered something working ;-)

I was wondering why do you need a whole network plugin in order to perform the DHCP requests, instead of having only an IPAM driver.
Or is this not pluggable/mixable within Docker ?

The thing is, we already have the bridge driver working and the macvlan bridge supported as well.
And all the interfaces setup are already working, all we needed was the IP assignment.

This could allow having DHCP over both normal and macvlan bridges and also allow having some services with a static user defined IP address and some with a DHCP lease.

What do you think of that? ;-)

Regards,

Olivier

Unable to install plugin

Hey. I'm trying to install this on a rpi3b+ but failing.
If I try to docker plugin install I get

Error response from daemon: dial unix /run/docker/plugins/f93f40fae3f3c9431dc6fdd279b2542a9c81e42a3d0c8703a15e538af2aed01c/net-dhcp.sock: connect: no such file or directory

If I build from source I get

Error response from daemon: dial unix /run/docker/plugins/1634f7b57818e5f8258a603efb05c6891577e597107d25dd20ee6a14e62009da/net-dhcp.sock: connect: connection refused

Any ideas?

Add support for non-amd64 platforms

Currently the only image for this plugin is amd64-based. It would be nice if other architectures (e.g. armv7h, aarch64) were supported. This might be slightly awkward to automate given the general weirdness around Docker plugin images.

docker network create --scope=swarm fails

Any way to get this driver to create a network with --scope=swarm instead of local scope? My main motivation for testing this is to give a few docker containers static IP addresses via my local dhcp server, since it's impossible to assign an address to a container attached to a macvlan network in swarm mode. I'm able to create dhcp networks with this driver in local scope on each individual node in the swarm, but that won't allow me to attach any swarm services to that network. When I run:

docker network create --scope=swarm -d ghcr.io/devplayer0/docker-net-dhcp:release-linux-amd64 --ipam-driver null -o skip_routes=true -o lease_timeout=60s -o bridge=vmbr1 dhcp-net-vmmbr1

I get:

Error response from daemon: rpc error: code = InvalidArgument desc = error during lookup of plugin null

Error response from daemon

Trying to run this in unraid tdarr container. Have gone through all the steps on your readme page and on the last one. Hit the go button to update the container and get the following error:

docker: Error response from daemon: failed to create endpoint tdarr on network media-dhcp-net: NetworkDriver.CreateEndpoint: failed to get bridge interface: Link not found.

The command failed.

This is what it is running:

docker run
-d
--name='tdarr'
--cpuset-cpus='4,5,6,7,16,17,18,19'
-e TZ="Europe/London"
-e HOST_OS="Unraid"
-e HOST_HOSTNAME="horizon"
-e HOST_CONTAINERNAME="tdarr"
-e 'serverIP'='tdarr'
-e 'internalNode'='false'
-e 'nodeIP'='tdarr'
-e 'nodeID'='Horizon_Node'
-e 'PUID'='99'
-e 'PGID'='100'
-e 'NVIDIA_VISIBLE_DEVICES'=''
-e 'NVIDIA_DRIVER_CAPABILITIES'=''
-l net.unraid.docker.managed=dockerman
-l net.unraid.docker.webui='http://[IP]:[PORT:8265]'
-l net.unraid.docker.icon='https://raw.githubusercontent.com/selfhosters/unRAID-CA-templates/master/templates/img/tdarr.png'
-p '8266:8266/tcp'
-p '8265:8265/tcp'
-p '8264:8264/tcp'
-v '/mnt/user/appdata/tdarr/server':'/app/server':'rw'
-v '/mnt/user/appdata/tdarr/configs':'/app/configs':'rw'
-v '/mnt/user/appdata/tdarr/logs':'/app/logs':'rw'
-v '/mnt/user/TV/':'/tv':'rw'
-v '/tmp/tdarr':'/temp':'rw'
-v '/mnt/user/movies':'/movies':'rw'
--runtime=nvidia
--net=media-dhcp-net
--hostname=tdarrserver 'ghcr.io/haveagitgat/tdarr'
14e22330ccaa2cfb96668059b5278256f38b34a4dc4a83c8534218eb49fa55e6
docker: Error response from daemon: failed to create endpoint tdarr on network media-dhcp-net: NetworkDriver.CreateEndpoint: failed to get bridge interface: Link not found.

The command failed.

Can't connect multiple networks to a single container

I have created two different networks attached to two different bridges. When i connect the first network to the container, it has no problems.
When i connect the 2nd one, i get this error:

Error response from daemon: failed to add interface 55c1b19cd7cc-dh to sandbox: error setting interface "55c1b19cd7cc-dh" routes to ["169.254.0.0/16"]: file exists

It doesn't matter which network goes first, the first will always succeed, and the second will fail with roughly that error.
I have needs for providing upwards of 5 or 6 networks from this plugin, all with different bridges, so I'm hoping there is a solution here.
Let me know if you need anything else from me to help sort this out.
Thanks.

Unable to start containers at boot time

I have the plugin installed and working correctly, for manually started containers. However, I have one container set to restart=always, which means it gets started at bootup. When docker attempts this it fails after 60 seconds with the error:

UnixHTTPConnectionPool(host='localhost', port=None): Read timed out. (read timeout=60)

The revelent section from the syslog:

Dec 20 08:05:18 Thor dockerd[1497]: level=error msg="Traceback (most recent call last):"
Dec 20 08:05:18 Thor dockerd[1497]: level=error msg="  File \"/usr/local/lib/python3.7/site-packages/flask/app.py\", line 1949, in full_dispatch_request" >
Dec 20 08:05:18 Thor dockerd[1497]: level=error msg="    rv = self.dispatch_request()" 
Dec 20 08:05:18 Thor dockerd[1497]: level=error msg="  File \"/usr/local/lib/python3.7/site-packages/flask/app.py\", line 1935, in dispatch_request"
Dec 20 08:05:18 Thor dockerd[1497]: level=error msg="    return self.view_functions[rule.endpoint](**req.view_args)"
Dec 20 08:05:18 Thor dockerd[1497]: level=error msg="  File \"/opt/plugin/net_dhcp/network.py\", line 139, in create_endpoint"
Dec 20 08:05:18 Thor dockerd[1497]: level=error msg="    bridge = net_bridge(network_id)"
Dec 20 08:05:18 Thor dockerd[1497]: level=error msg="  File \"/opt/plugin/net_dhcp/network.py\", line 58, in net_bridge"
Dec 20 08:05:18 Thor dockerd[1497]: level=error msg="    return ndb.interfaces[client.networks.get(n).attrs['Options'][OPT_BRIDGE]]"
Dec 20 08:05:18 Thor dockerd[1497]: level=error msg="  File \"/usr/local/lib/python3.7/site-packages/docker/models/networks.py\", line 180, in get"
Dec 20 08:05:18 Thor dockerd[1497]: level=error msg="    self.client.api.inspect_network(network_id, *args, **kwargs)"
Dec 20 08:05:18 Thor dockerd[1497]: level=error msg="  File \"/usr/local/lib/python3.7/site-packages/docker/utils/decorators.py\", line 19, in wrapped"
Dec 20 08:05:18 Thor dockerd[1497]: level=error msg="    return f(self, resource_id, *args, **kwargs)"
Dec 20 08:05:18 Thor dockerd[1497]: level=error msg="  File \"/usr/local/lib/python3.7/site-packages/docker/api/network.py\", line 211, in inspect_network>
Dec 20 08:05:18 Thor dockerd[1497]: level=error msg="    res = self._get(url, params=params)"
Dec 20 08:05:18 Thor dockerd[1497]: level=error msg="  File \"/usr/local/lib/python3.7/site-packages/docker/utils/decorators.py\", line 46, in inner"
Dec 20 08:05:18 Thor dockerd[1497]: level=error msg="    return f(self, *args, **kwargs)"
Dec 20 08:05:18 Thor dockerd[1497]: level=error msg="  File \"/usr/local/lib/python3.7/site-packages/docker/api/client.py\", line 230, in _get"
Dec 20 08:05:18 Thor dockerd[1497]: level=error msg="    return self.get(url, **self._set_request_timeout(kwargs))"
Dec 20 08:05:18 Thor dockerd[1497]: level=error msg="  File \"/usr/local/lib/python3.7/site-packages/requests/sessions.py\", line 546, in get"
Dec 20 08:05:18 Thor dockerd[1497]: level=error msg="    return self.request('GET', url, **kwargs)"
Dec 20 08:05:18 Thor dockerd[1497]: level=error msg="  File \"/usr/local/lib/python3.7/site-packages/requests/sessions.py\", line 533, in request"
Dec 20 08:05:18 Thor dockerd[1497]: level=error msg="    resp = self.send(prep, **send_kwargs)"
Dec 20 08:05:18 Thor dockerd[1497]: level=error msg="  File \"/usr/local/lib/python3.7/site-packages/requests/sessions.py\", line 646, in send"
Dec 20 08:05:18 Thor dockerd[1497]: level=error msg="    r = adapter.send(request, **kwargs)"
Dec 20 08:05:18 Thor dockerd[1497]: level=error msg="  File \"/usr/local/lib/python3.7/site-packages/requests/adapters.py\", line 529, in send"
Dec 20 08:05:18 Thor dockerd[1497]: level=error msg="    raise ReadTimeout(e, request=request)"
Dec 20 08:05:18 Thor dockerd[1497]: level=error msg="requests.exceptions.ReadTimeout: UnixHTTPConnectionPool(host='localhost', port=None): Read timed out.>
Dec 20 08:05:18 Thor dockerd[1497]: level=error msg="<local> - - [20/Dec/2019 08:05:18] \"POST /NetworkDriver.CreateEndpoint HTTP/1.1\" 500 -" plugin=ca4c>
Dec 20 08:05:18 Thor dockerd[1497]: level=warning msg="error locating sandbox id 81ebc1c5a56a16442533b78b3d16f22c61804edd2199bead971c6fe42a68a0f>
Dec 20 08:05:18 Thor dockerd[1497]: level=warning msg="08c4e7ed282f2970be6b95415b33a912bcd72e95aef6037037bf6f60977d2053 cleanup: failed to unmou>
Dec 20 08:05:18 Thor dockerd[1497]: level=error msg="08c4e7ed282f2970be6b95415b33a912bcd72e95aef6037037bf6f60977d2053 cleanup: failed to delete >
Dec 20 08:05:18 Thor dockerd[1497]: level=error msg="Failed to start container 08c4e7ed282f2970be6b95415b33a912bcd72e95aef6037037bf6f60977d2053:>
Dec 20 08:05:18 Thor dockerd[1497]: level=info msg="Loading containers: done."
Dec 20 08:05:18 Thor dockerd[1497]: level=info msg="Docker daemon" commit=633a0ea838 graphdriver(s)=overlay2 version=19.03.5
Dec 20 08:05:18 Thor dockerd[1497]: level=info msg="Daemon has completed initialization"
Dec 20 08:05:18 Thor dockerd[1497]: time="2019-12-20T08:05:18.936048081Z" level=info msg="API listen on /run/docker.sock"

This seems to suggest it's trying to access the Docker API before it's been made available. I'm not sure if that's a setup issue on my side or not, I can't see any options to delay starting containers until the API is available.

docker-net-dhcp equivalent for podman

Dear Developer,
Docker-net-dhcp is great, could you provide an equivalent plugin for podman.
Podman is now most integrated in gnome environment : gnome-pods, gnome-prompt ...

Thanks

Can not create network

$ sudo docker network create -d ghcr.io/devplayer0/docker-net-dhcp:release-linux-amd64 --ipam-driver null -o bridge=my-bridge my-dhcp-net
Error response from daemon: NetworkDriver.CreateNetwork: bridge already in use by Docker
```

MAC address defining doesn't work

I tried to start container with predefined MAC address to setup static DHCP lease for container:
docker run --rm -ti --network shared-net --mac-address 66:5e:28:93:6f:60 alpine
In container MAC address defines successfully:

/ # ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
112: shared-bridge0@if113: <BROADCAST,MULTICAST,UP,LOWER_UP,M-DOWN> mtu 1500 qdisc noqueue state UP qlen 1000
link/ether 66:5e:28:93:6f:60 brd ff:ff:ff:ff:ff:ff
inet 192.168.28.101/24 brd 192.168.28.255 scope global shared-bridge0
valid_lft forever preferred_lft forever

But on my router it shows another MAC: 5e:f0:e1:a0:7d:17 for lease with this IP: 192.168.28.101.
I think that DHCP client that runs on host using random MAC every time.
And new random MAC is used when container created/restarts.
Or I can set static IP address, but I don't know how to do this with this docker network driver.
What I'm want to do is to connect docker container to linux bridge managed by systemd-networkd and set IP address to it. And I don't want to use pipework script for this because when host/container restarts it needs to be executed again.

NetworkDriver.CreateEndpoint: Timed out waiting for lease from udhcpc

<local> - - [10/May/2021 20:48:16] "POST /NetworkDriver.CreateNetwork HTTP/1.1" 200 -
<local> - - [10/May/2021 20:48:28] "POST /NetworkDriver.CreateEndpoint HTTP/1.1" 0 -
400 Bad Request: The browser (or proxy) sent a request that this server could not understand.
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/werkzeug/wrappers/json.py", line 119, in get_json
    rv = self.json_module.loads(data)
  File "/usr/local/lib/python3.9/site-packages/flask/json/__init__.py", line 253, in loads
    return _json.loads(s, **kwargs)
  File "/usr/local/lib/python3.9/json/__init__.py", line 359, in loads
    return cls(**kw).decode(s)
  File "/usr/local/lib/python3.9/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/local/lib/python3.9/json/decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/flask/app.py", line 1949, in full_dispatch_request
    rv = self.dispatch_request()
  File "/usr/local/lib/python3.9/site-packages/flask/app.py", line 1935, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/opt/plugin/net_dhcp/network.py", line 134, in create_endpoint
    req = request.get_json(force=True)
  File "/usr/local/lib/python3.9/site-packages/werkzeug/wrappers/json.py", line 128, in get_json
    rv = self.on_json_loading_failed(e)
  File "/usr/local/lib/python3.9/site-packages/flask/wrappers.py", line 27, in on_json_loading_failed
    raise BadRequest()
werkzeug.exceptions.BadRequest: 400 Bad Request: The browser (or proxy) sent a request that this server could not understand.
<local> - - [10/May/2021 20:48:29] "POST /NetworkDriver.CreateEndpoint HTTP/1.1" 500 -
<local> - - [10/May/2021 20:48:40] "POST /NetworkDriver.CreateEndpoint HTTP/1.1" 500 -
<local> - - [10/May/2021 20:48:51] "POST /NetworkDriver.CreateEndpoint HTTP/1.1" 500 -
<local> - - [10/May/2021 20:49:02] "POST /NetworkDriver.CreateEndpoint HTTP/1.1" 500 -
<local> - - [10/May/2021 20:49:18] "POST /NetworkDriver.DeleteNetwork HTTP/1.1" 200 -
2021-05-10 21:23:18,532 [INFO] Creating network "f70003e0ba7478a179b6f00c01c93c65b154a52f8aae192ec2ce7b96d3191d6d" (using bridge "br0")
2021-05-10 21:23:27,415 [INFO] creating veth pair dh-941645c468a3 <=> 941645c468a3-dh
2021-05-10 21:23:27,847 [DEBUG] [udhcp#30075 event] {'type': <EventType.DECONFIG: 'deconfig'>}
2021-05-10 21:23:37,742 [ERROR] Timed out waiting for lease from udhcpc
Traceback (most recent call last):
  File "/opt/plugin/net_dhcp/network.py", line 199, in create_endpoint
    try_addr('v4')
  File "/opt/plugin/net_dhcp/network.py", line 190, in try_addr
    addr = dhcp.finish()
  File "/opt/plugin/net_dhcp/udhcpc.py", line 136, in finish
    self.await_ip()
  File "/opt/plugin/net_dhcp/udhcpc.py", line 124, in await_ip
    raise DHCPClientError(f'Timed out waiting for lease from udhcpc{self._suffix}')
net_dhcp.udhcpc.DHCPClientError: Timed out waiting for lease from udhcpc

Not working with existing br0 interface

docker network create -d ghcr.io/devplayer0/docker-net-dhcp:release-linux-amd64 --ipam-driver null -o bridge=br0 -o ipv6=true --subnet 2602:fe43:f00:fc91:xxxx:xxxx:xxxx:xxxx/64 external_ipv6
br0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.1.5  netmask 255.255.0.0  broadcast 192.168.255.255
        inet6 fe80::3e4a:92ff:fef5:bc08  prefixlen 64  scopeid 0x20<link>
        inet6 2602:fe43:f00:fc91:xxxx:xxxx:xxxx:xxxx  prefixlen 64  scopeid 0x0<global>
        ether 3c:xx:xx:xx:xx:xx  txqueuelen 1000  (Ethernet)
        RX packets 7215935  bytes 9902612238 (9.9 GB)
        RX errors 0  dropped 75  overruns 0  frame 0
        TX packets 3777284  bytes 1131167161 (1.1 GB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
└─> docker run --rm -ti --network external_ipv6 alpine
docker: Error response from daemon: failed to create endpoint confident_gould on network external_ipv6: NetworkDriver.CreateEndpoint: failed to get initial IP address via DHCP: context deadline exceeded.

my bridge interface works fine, as it has a dhcp6 address from my /64 subnet.

└─> ping6 ipv6.google.com
PING ipv6.google.com(iad30s43-in-x0e.1e100.net (2607:f8b0:4004:82f::200e)) 56 data bytes
64 bytes from iad30s43-in-x0e.1e100.net (2607:f8b0:4004:82f::200e): icmp_seq=1 ttl=118 time=17.6 ms
64 bytes from iad30s43-in-x0e.1e100.net (2607:f8b0:4004:82f::200e): icmp_seq=2 ttl=118 time=17.4 ms
64 bytes from iad30s43-in-x0e.1e100.net (2607:f8b0:4004:82f::200e): icmp_seq=3 ttl=118 time=18.5 ms
64 bytes from iad30s43-in-x0e.1e100.net (2607:f8b0:4004:82f::200e): icmp_seq=4 ttl=118 time=18.1 ms

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.