Skip to content

[BUG] docker_network.present recreates the network every time it is run #66408

Closed as not planned

Description

@mitar

Description

I have docker_network.present state which recreates the Docker network every time it is run, despite nothing really changing.

Setup

Please be as specific as possible and give set-up details.

  • on-prem machine
  • VM (Virtualbox, KVM, etc. please specify)
  • VM running on a cloud service, please be explicit and add details
  • container (Kubernetes, Docker, containerd, etc. please specify)
  • or a combination, please be explicit
  • jails if it is FreeBSD
  • classic packaging
  • onedir packaging
  • used bootstrap to install

Steps to Reproduce the behavior

I have Docker installed on target server:

dpkg -l | grep docker on target server:

docker.io                              24.0.5-0ubuntu1~22.04.1
python3-docker                         5.0.3-1

lsb_release -a on target server:

Description:	Ubuntu 22.04.4 LTS
Release:	22.04
Codename:	jammy

I have IPv6 enabled for Docker, /etc/docker/daemon.json:

{
  "experimental": true,
  "userland-proxy": false,
  "ip6tables": true,
  "ipv6": true,
  "default-address-pools": [
    { "base": "172.17.0.0/16", "size": 16 },
    { "base": "172.18.0.0/16", "size": 16 },
    { "base": "172.19.0.0/16", "size": 16 },
    { "base": "172.20.0.0/14", "size": 16 },
    { "base": "172.24.0.0/14", "size": 16 },
    { "base": "172.28.0.0/14", "size": 16 },
    { "base": "fd00:2::/104", "size": 112 }
  ],
  "fixed-cidr-v6": "fd00:1::/64"
}

I use the following state:

mynet_network:
  docker_network.present:
    - name: mynet
    - ipv6: True

pip freeze | grep salt:

salt==3007.0

I use salt-ssh to deploy to the server. After each run, it always reports something like:

          ID: mynet_network
    Function: docker_network.present
        Name: mynet
      Result: True
     Comment: Network 'mynet' was replaced with updated config
     Started: 03:01:56.091744
    Duration: 1638.737 ms
     Changes:   
              ----------
              mynet:
                  ----------
                  IPAM:
                      ----------
                      Config:
                          ----------
                          new:
                          old:
                              |_
                                ----------
                                Gateway:
                                    172.18.0.1
                                Subnet:
                                    172.18.0.0/16
                              |_
                                ----------
                                Gateway:
                                    fd00:2::1/112
                                Subnet:
                                    fd00:2::/112
              reconnected:
                  - mycontainer
              recreated:
                  True

A good thing is that:

  • It uses same IPs when recreating.
  • The containers which depend on this network are not recreated (e.g., mycontainer).

Expected behavior

The network it not recreated.

Versions Report

salt --versions-report
Salt Version:
          Salt: 3007.0
 
Python Version:
        Python: 3.8.10 (default, Nov 22 2023, 10:22:35)
 
Dependency Versions:
          cffi: 1.16.0
      cherrypy: unknown
      dateutil: 2.9.0.post0
     docker-py: Not Installed
         gitdb: Not Installed
     gitpython: Not Installed
        Jinja2: 3.1.3
       libgit2: Not Installed
  looseversion: 1.3.0
      M2Crypto: Not Installed
          Mako: Not Installed
       msgpack: 1.0.8
  msgpack-pure: Not Installed
  mysql-python: Not Installed
     packaging: 24.0
     pycparser: 2.22
      pycrypto: Not Installed
  pycryptodome: 3.20.0
        pygit2: Not Installed
  python-gnupg: 0.5.2
        PyYAML: 6.0.1
         PyZMQ: 26.0.0
        relenv: Not Installed
         smmap: Not Installed
       timelib: 0.3.0
       Tornado: 6.4
           ZMQ: 4.3.5
 
Salt Package Information:
  Package Type: Not Installed
 
System Versions:
          dist: ubuntu 20.04.6 focal
        locale: utf-8
       machine: x86_64
       release: 5.15.0-101-generic
        system: Linux
       version: Ubuntu 20.04.6 focal

Activity

  1. added
    bug
    on Apr 21, 2024
  2. mitar commented on Apr 17, 2026

    @mitar
    ContributorAuthor

    It looks like the issue here is that the shortcut that clears network["IPAM"]["Config"] when the user didn't explicitly configure IPAM pools only triggered when the existing network had exactly one default pool. With ipv6: True (and no explicit pools), Docker auto-assigns two default pools (IPv4 + IPv6), so the shortcut didn't apply, compare_networks saw existing=[v4_default, v6_default] vs desired=[], and the network got recreated every run.

  3. mitar commented on Apr 23, 2026

    @mitar
    ContributorAuthor

    I have a fix for this in my fork, but I am waiting for Docker code to be moved to its own repository to make a PR:

  4. added
    severity-low
    on Oct 21, 2026
  5. dwoz commented on Oct 27, 2026

    @dwoz
    Contributor

    Closing — this bug targets a module that was moved out of Salt core in the 3007.x → 3008.x migration and now lives in salt-extensions/saltext-dockermod. Salt 3006.x and 3007.x are now in security-fix-only support, so a core-side fix for this is no longer in scope. Please re-file against https://github.com/salt-extensions/saltext-dockermod/issues (with reproduction and salt --versions-report) if it still reproduces there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugneeds-triageseverity-low

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions