Error response from daemon invalid subnet invalid cidr address

Hi All, I'm trying to set up an overlay network in docker-compose using consul as external key etc. I WAS getting the error "ERROR: error getting pools config from store: could not get poo...

Comments

@inscrutabledude

Hi All,

I’m trying to set up an overlay network in docker-compose using consul as external key etc. I WAS getting the error «ERROR: error getting pools config from store: could not get pools config from store:» which mentioned ipam, so I added an ipam section in my network declaration and now I get this: «ERROR: Invalid subnet : invalid CIDR address:»

My config follows:

networks:
       workernet:
         driver: overlay
         ipam:
           driver: default
           config:
             - subnet: "192.168.0.0/24"
             - gateway: "192.168.0.1"
       default:
         driver: bridge

Could someone tell me where I’ve gone wrong and show me how this is supposed to work? I should mention that I’ve been working with and googling this for 3 days with no success.

Thanks in advance!

@shin-

Your config section is not formatted correctly. It should look like this (note the absence of a dash on the second line):

           config:
             - subnet: "192.168.0.0/24"
               gateway: "192.168.0.1"

HTH

nykykof, reddypdl, LacrimaMosa, mkurt, bmikaeli, gorilla001, rao-abdul-mannan, RobinHoody, doododo, null93, and 47 more reacted with thumbs up emoji
ivorobioff, pasqLisena, sylvainbx, glafir, z43460018724, and SamirOuahhabi reacted with confused emoji
fredericgermain, rochadt, alisha17, TheYoungSensei, sgtcortez, and SamirOuahhabi reacted with heart emoji
Markussss, dimkonko, and SamirOuahhabi reacted with rocket emoji

@jetndra

Hi @shin- i m getting the same error with the below configuration

apiVersion: «k8s.cni.cncf.io/v1»
kind: NetworkAttachmentDefinition
metadata:
name: cms-oam-eth1
namespace: cms
spec:
config: ‘{
«cniVersion»: «0.3.0»,
«type»: «macvlan»,
«master»: «eth0»,
«mode»: «bridge»,
«ipam»: {
«type»: «host-local»,
«datastore»: «kubernetes»,
«kubernetes»: { «kubeconfig»: «/etc/cni/net.d/whereabouts.d/whereabouts.kubeconfig» },
«subnet»: «192.169.1.0/24»,
«rangeStart»: «192.169.1.2»,
«rangeEnd»: «192.169.1.240»,
«gateway»: «192.169.1.1»,
«log_file» : «/tmp/whereabouts.log»,
«log_level» : «debug»
}
}

Normal Scheduled 19s default-scheduler Successfully assigned cms/cms1-0 to k8s-worker-1
Warning FailedCreatePodSandBox 13s kubelet, k8s-worker-1 Failed to create pod sandbox: rpc error: code = Unknown desc = failed to setup network for sandbox «bdc93dc123701afa226cd844fde27d3c9d20882a0f8c0bd117c4f1381d094df3»: Multus: error adding pod to network «cms-oam-eth1»: delegateAdd: error invoking DelegateAdd — «macvlan»: invalid CIDR : invalid CIDR address:
Warning FailedCreatePodSandBox 6s kubelet, k8s-worker-1 Failed to create pod sandbox: rpc error: code = Unknown desc = failed to setup network for sandbox «4af83c0247d2fcda83cdf7a53990d84053a89f891839adc7f95a71c7490acec5»: Multus: error adding pod to network «cms-oam-eth1»: delegateAdd: error invoking DelegateAdd — «macvlan»: invalid CIDR : invalid CIDR address:
Can u plz help how to resolve this issue

@arunvelayutham

Hi @shin- i m getting the same error with the below configuration

apiVersion: «k8s.cni.cncf.io/v1»
kind: NetworkAttachmentDefinition
metadata:
name: cms-oam-eth1
namespace: cms
spec:
config: ‘{
«cniVersion»: «0.3.0»,
«type»: «macvlan»,
«master»: «eth0»,
«mode»: «bridge»,
«ipam»: {
«type»: «host-local»,
«datastore»: «kubernetes»,
«kubernetes»: { «kubeconfig»: «/etc/cni/net.d/whereabouts.d/whereabouts.kubeconfig» },
«subnet»: «192.169.1.0/24»,
«rangeStart»: «192.169.1.2»,
«rangeEnd»: «192.169.1.240»,
«gateway»: «192.169.1.1»,
«log_file» : «/tmp/whereabouts.log»,
«log_level» : «debug»
}
}

Normal Scheduled 19s default-scheduler Successfully assigned cms/cms1-0 to k8s-worker-1
Warning FailedCreatePodSandBox 13s kubelet, k8s-worker-1 Failed to create pod sandbox: rpc error: code = Unknown desc = failed to setup network for sandbox «bdc93dc123701afa226cd844fde27d3c9d20882a0f8c0bd117c4f1381d094df3»: Multus: error adding pod to network «cms-oam-eth1»: delegateAdd: error invoking DelegateAdd — «macvlan»: invalid CIDR : invalid CIDR address:
Warning FailedCreatePodSandBox 6s kubelet, k8s-worker-1 Failed to create pod sandbox: rpc error: code = Unknown desc = failed to setup network for sandbox «4af83c0247d2fcda83cdf7a53990d84053a89f891839adc7f95a71c7490acec5»: Multus: error adding pod to network «cms-oam-eth1»: delegateAdd: error invoking DelegateAdd — «macvlan»: invalid CIDR : invalid CIDR address:
Can u plz help how to resolve this issue

was this issue resolved?. could you please some insights on what was the reason for invalid CIDR?. (I assumed you gave the right CIDR params at whereabouts).

Problem

I am trying to setup a local DNS server (pihole) inside a docker container on my debian 11 server in my home network with a static IPv6, such that I can point all lookups from my router to it.

What I have so far

  • As this is a home network, my router reconnects in certain intervals, which does not allow me to use theglobal IPv6 prefix.

  • docker service is running on my server

  • I’m using docker-compose, the compose file looks like this currently:

     version: "3"
    
     # More info at https://github.com/pi-hole/docker-pi-hole/ and https://docs.pi-hole.net/
     services:
       pihole:
         container_name: pihole
         image: pihole/pihole:latest
         ports:
           - "53:53/tcp"
           - "53:53/udp"
           - "67:67/udp"
           - "80:80/tcp"
         environment:
           TZ: 'Europe/Berlin'
           # WEBPASSWORD: 'set a secure password here or it will be random'
           WEBPASSWORD: 'XXXXXXXXX'
         # Volumes store your data between container upgrades
         volumes:
           - type: bind
             source: ./etc-pihole/
             target: /etc/pihole/
           - type: bind
             source: ./etc-dnsmasq.d
             target: /etc/dnsmasq.d/
         # Recommended but not required (DHCP needs NET_ADMIN)
         #   https://github.com/pi-hole/docker-pi-hole#note-on-capabilities
         cap_add:
           - NET_ADMIN
       #option not needed wen used in combinationwith systemd
       #restart: unless-stopped
         networks:
           macvlan:
             ipv4_address: 10.10.1.51
             ipv6_address: fd00:0:0:1:50::51
    
    
     networks:
       macvlan:
         driver: macvlan
         enable_ipv6: true
         driver_opts:
           parent: enp7s0
         ipam:
           config:
             - subnet: 10.10.1.50/24
               gateway: 10.10.1.1
             - subnet: fd00:0:0:1:50::/80
               gateway: fd00:0:0:1:2e91:abff:fe91:baa0
    
  • The whole IPv4 setup is working, however I do not fully understand how to setup the macvlan, such that the dockered pihole can work as a DNS server in my home network.

  • The fd00:0:0:1:2e91:abff:fe91:baa0 is the local address of my router.

  • docker-compose up yields:

    failed to create network dc_pihole_macvlan: Error response from daemon: Invalid subnet fd00:0:0:1:50:/80 : invalid CIDR address: fd00:0:0:1:50:/80
    

Questions

  • Is what I am trying to do feasible at all?
  • Is this the correct setup for what I am trying to do?
  • How can I get the container to start?

Edits 1

  • After the suggested syntax fixes,the docker container starts. From a bash inside the container, I can ping my router at fd00:0:0:1:2e91:abff:fe91:baa0. I can also ping ipv6.google.com and it gets resolved to the correct IPv6, but strangely, only one of four packets is transmitted. Why? See attached output, where PROVIDER-PREFIX-RM is my (current) scope global prefix:

     root@c4ca40297eaa:/# ping ipv6.google.com -c 4
     PING ipv6.google.com(fra24s11-in-x0e.1e100.net (2a00:1450:4001:830::200e)) 56 data bytes
     From PROVIDER-PREFIX-RM:42:aff:fe0a:133 (PROVIDER-PREFIX-RM:42:aff:fe0a:133): icmp_seq=1 Destination unreachable: Address unreachable
     From PROVIDER-PREFIX-RM:42:aff:fe0a:133 (PROVIDER-PREFIX-RM:42:aff:fe0a:133): icmp_seq=2 Destination unreachable: Address unreachable
     From PROVIDER-PREFIX-RM:42:aff:fe0a:133 (PROVIDER-PREFIX-RM:42:aff:fe0a:133): icmp_seq=3 Destination unreachable: Address unreachable
     64 bytes from fra24s11-in-x0e.1e100.net (2a00:1450:4001:830::200e): icmp_seq=4 ttl=115 time=18.7 ms
    
     --- ipv6.google.com ping statistics ---
     4 packets transmitted, 1 received, +3 errors, 75% packet loss, time 95ms
     rtt min/avg/max/mdev = 18.738/18.738/18.738/0.000 ms, pipe 3
    
  • Addendum: Obviously I am new to this, so if you feel like suggesting a betternumbering scheme, by all means, do.

asked Jan 4, 2022 at 18:25

marc's user avatar

marcmarc

1213 bronze badges

19

В моем файле docker compose есть следующая конфигурация сети.

networks:
    default:
        ipam:
            driver: default
            config:
                - subnet: ${DOCKER_SUBNET}

Когда установлено DOCKER_SUBNET, подсеть, указанная в этой переменной, используется должным образом. Когда переменная не установлена, я получаю: ERROR: Invalid subnet : invalid CIDR address:, потому что переменная пуста (что вполне разумно).

Есть ли способ настроить драйвер ipam таким образом, чтобы, когда переменная DOCKER_SUBNET не была установлена, docker-compose выбирал доступную подсеть, как это было бы обычно, если бы конфигурация ipam не была указана?

2 ответа

Лучший ответ

Compose выберет доступную подсеть, только если вы не укажете конфигурацию ipam для сети. Compose не имеет расширенных функций для изменения конфигурации на лету.

Вы можете принять решение за пределами композиции, используя несколько файлов для создания файлов или система на основе шаблонов, в оболочке или другом языке, которая запускает команду docker-compose.

Отделите конфигурацию сети от конфигурации службы

docker-compose-net-auto.yml

version: "2.1"
networks:
  default:

docker-compose-net-subnet.yml

version: "2.1"
networks:
  default:
    ipam:
      driver: default
      config:
        - subnet: ${DOCKER_SUBNET}

Затем создайте сценарий launch.sh, который выбирает, какой сетевой файл включить.

#!/bin/sh
if [ -z "$DOCKER_SUBNET" ]; then
  docker-compose -f docker-compose.yml -f docker-compose-net-auto.yml up
else
  docker-compose -f docker-compose.yml -f docker-compose-net-subnet.yml up
fi


7

Matt
20 Окт 2017 в 13:06

networks:
  Mynetwork:
      driver: bridge
      ipam:
          driver: default
          config:
              - subnet: "192.168.0.0/24"
                gateway: "192.168.0.1"
  #- default:
      #driver: bridge


2

Vivek Raj
22 Окт 2020 в 10:07

Понравилась статья? Поделить с друзьями:
  • Error response from daemon error processing tar file exit status 1 unlinkat
  • Error request failed with status code 419 перевод
  • Error response from daemon dial unix docker raw sock connect no such file or directory
  • Error request failed with status code 413 перевод
  • Error response from daemon conflict unable to delete