devplayer0 / docker-net-dhcp

Docker network driver for networking on a host bridge with DHCP-allocated IP addresses
GNU General Public License v3.0
203 stars 55 forks source link

New error with latest Docker. #42

Open crkinard opened 9 months ago

crkinard commented 9 months ago

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"
relet commented 9 months ago

I just got the same. The issue might be with the release version, and rebuilding the plugin container might help.

relet commented 9 months ago

The issue is resolved by enabling API version negotiation in the client.

    //client, err := docker.NewClient("unix:///run/docker.sock", "v1.13.1", nil, nil)
    client, err := docker.NewClientWithOpts(client.WithAPIVersionNegotiation(), docker.FromEnv)
crkinard commented 9 months ago

I have a better chance of getting macvlan working then figuring out how to fix this heh,

tjandras commented 9 months ago

@relet Is it possible that I clone your branch and build the fixed version myself? If yes, can you explain how? Thanks!

relet commented 9 months ago

Yes, there are several branches that have the fix by now. In principle you can docker build locally to get the plugin, or push the result to a registry (eg github) and pull from there.

NonaSuomy commented 8 months ago

Can you verbosely explain how to do this on the CLI command by command? "In principle, you can docker build locally to get the plugin" For people like me that have never built anything for docker...

NonaSuomy commented 8 months ago
git clone https://github.com/devplayer0/docker-net-dhcp.git
cd docker-net-dhcp
git fetch origin pull/43/head:celerway
git checkout celerway
Switched to branch 'celerway'

git branch -a
* celerway
  master
  remotes/origin/HEAD -> origin/master
  remotes/origin/dependabot/go_modules/github.com/containerd/containerd-1.5.18
  remotes/origin/dependabot/go_modules/github.com/docker/docker-20.10.24incompatible
  remotes/origin/dependabot/go_modules/golang.org/x/net-0.7.0
  remotes/origin/dependabot/go_modules/golang.org/x/sys-0.1.0
  remotes/origin/master

make create

docker plugin ls
ID             NAME                                        DESCRIPTION                          ENABLED
############   ghcr.io/devplayer0/docker-net-dhcp:golang   Docker host bridge DHCP networking   false

sudo docker plugin enable ghcr.io/devplayer0/docker-net-dhcp:golang
docker plugin ls
ID             NAME                                        DESCRIPTION                          ENABLED
############   ghcr.io/devplayer0/docker-net-dhcp:golang   Docker host bridge DHCP networking   true

sudo docker network ls
NETWORK ID     NAME               DRIVER                                                   SCOPE
############   bridge             bridge                                                   local
############   config_default     bridge                                                   local
############   dbrv100            ghcr.io/devplayer0/docker-net-dhcp:release-linux-amd64   local
############   dbrv200            ghcr.io/devplayer0/docker-net-dhcp:release-linux-amd64   local
############   dbrv300            ghcr.io/devplayer0/docker-net-dhcp:release-linux-amd64   local
############   dbrv350            ghcr.io/devplayer0/docker-net-dhcp:release-linux-amd64   local
############   dbrv400            ghcr.io/devplayer0/docker-net-dhcp:release-linux-amd64   local

Shows all your old docker-net-dhcp additions, we need to remove them :(

I first tried:
sudo docker network rm dbrv100
Error response from daemon: error while removing network: failed deleting Network: plugin "ghcr.io/devplayer0/docker-net-dhcp:release-linux-amd64" not found

So then I nuked them with
sudo docker network prune
WARNING! This will remove all custom networks not used by at least one container.
Are you sure you want to continue? [y/N] y
sudo docker network ls
NETWORK ID     NAME      DRIVER    SCOPE
############   bridge    bridge    local
############   host      host      local
############   none      null      local

Then added them all back with the new compiled driver

sudo docker network create -d ghcr.io/devplayer0/docker-net-dhcp:golang --ipam-driver null -o bridge=brv100 dbrv100
sudo docker network create -d ghcr.io/devplayer0/docker-net-dhcp:golang --ipam-driver null -o bridge=brv200 dbrv200
sudo docker network create -d ghcr.io/devplayer0/docker-net-dhcp:golang --ipam-driver null -o bridge=brv300 dbrv300
sudo docker network create -d ghcr.io/devplayer0/docker-net-dhcp:golang --ipam-driver null -o bridge=brv350 dbrv350
sudo docker network create -d ghcr.io/devplayer0/docker-net-dhcp:golang --ipam-driver null -o bridge=brv400 dbrv400

sudo docker network ls
NETWORK ID     NAME      DRIVER                                      SCOPE
############   bridge    bridge                                      local
############   dbrv100   ghcr.io/devplayer0/docker-net-dhcp:golang   local
############   dbrv200   ghcr.io/devplayer0/docker-net-dhcp:golang   local
############   dbrv300   ghcr.io/devplayer0/docker-net-dhcp:golang   local
############   dbrv350   ghcr.io/devplayer0/docker-net-dhcp:golang   local
############   dbrv400   ghcr.io/devplayer0/docker-net-dhcp:golang   local
############   host      host                                        local
############   none      null                                        local

Now they are all back in action but all the containers still point to the old bridges 😭 

docker container inspect genericcontainer001

you will see all the old ID's for the old networks...
I tried doing 
sudo docker network disconnect dbrv100 genericcontainer001
sudo docker network connect dbrv100 genericcontainer001

This changed the network so I thought win!

Yet NetworkMode was still stuck with the old network and would fail on startup.
sudo docker container start genericcontainer001
Error response from daemon: could not find a network matching network mode ####...: network ####... not found
Error: failed to start containers: genericcontainer001
So then I ran compose

docker-compose.yml
version: '3.9'

services:
  genericcontainer001:
    container_name: genericcontainer001
    hostname: genericcontainer001
    mac_address: de:ad:be:ef:00:01
    networks:
      - dhcp
networks:
  dhcp:
    #mac_address: de:ad:be:ef:00:01 #(for docker engine verison 25)
    name: dbrv100
    external: true

docker compose up -d

It came back up with the right network without an issue yay!

Thanks to encbladexp in docker discord for helping me figure out the compile technique! Thanks to manjax in docker discord for telling me to use compose to bring up the system to fix the straggling networkmode issue.