Skip to content

[Bug]: docker_container.running does not re-create a continer when watched file changes #68958

@mitar

Description

@mitar

What happened?

I have state like:

/srv/storage/example/config/auth:
  file.managed:
    - contents: |
        some config
    - user: 1000
    - group: root
    - mode: 600
    - makedirs: true
    - dir_mode: 755

example:
  docker_image.present:
    - name: myexampleimage
    - tag: latest
    - force: true
  docker_container.running:
    - hostname: example
    - image: myexampleimage:latest
    - restart_policy: unless-stopped
    - command:
      - --password=/config/auth
    - binds:
      - /srv/storage/config/config:/config
    - skip_translate: port_bindings
    - networks:
      - ipv4
    - require:
      - docker_image: config
      - docker_network: ipv4
    - watch:
      - file: /srv/storage/example/config/auth

The issue is that when I change auth contents this is correctly detected as a change:

          ID: /srv/storage/example/config/auth
    Function: file.managed
      Result: True
     Comment: File /srv/storage/example/config/auth updated
     Started: 08:34:42.215555
    Duration: 2.488 ms
     Changes:   
              ----------
              diff:
                  --- 
                  +++ 
                  @@ -1 +1 @@
                  -old config
                  +some config

But docker container is not recreated. There is unrelated change though, but there is no recreate:

          ID: example
    Function: docker_container.running
      Result: True
     Comment: Container 'example' is already configured as specified. Reconnected to network 'ipv4' with updated configuration.
     Started: 08:34:44.375705
    Duration: 549.806 ms
     Changes:   
              ----------
              container:
                  ----------
                  Networks:
                      ----------
                      ipv4:
                          ----------
                          Gateway:
                              ----------
                              new:
                                  172.18.0.1
                              old:
                                  None
                          IPAMConfig:
                              ----------
                              new:
                                  None
                              old:
                                  ----------
                                  IPv4Address:
                                      172.18.0.5
                                  IPv6Address:
                          IPAddress:
                              ----------
                              new:
                                  172.18.0.5
                              old:
                                  None

(It is a side question why it is detecting this networking change - it should not - but this issue is not about that. I think it is connected with #66408.)

Type of salt install

pip (pypi)

Major version

3007.x

What supported OS are you seeing the problem on? Can select multiple. (If bug appears on an unsupported OS, please open a GitHub Discussion instead)

ubuntu-24.04

salt --versions-report output

salt3new) mitar@gagea:~/Documents/Projects/plast8-servers$ salt --versions-report
Salt Version:
          Salt: 3007.9
 
Python Version:
        Python: 3.12.3 (main, Mar  3 2026, 12:15:18) [GCC 13.3.0]
 
Dependency Versions:
          cffi: 2.0.0
      cherrypy: 18.10.0
  cryptography: 46.0.3
      dateutil: 2.9.0.post0
     docker-py: Not Installed
         gitdb: Not Installed
     gitpython: Not Installed
        Jinja2: 3.1.6
       libgit2: Not Installed
  looseversion: 1.3.0
      M2Crypto: Not Installed
          Mako: Not Installed
       msgpack: 1.1.2
  msgpack-pure: Not Installed
  mysql-python: Not Installed
     packaging: 25.0
     pycparser: 2.23
      pycrypto: Not Installed
  pycryptodome: 3.23.0
        pygit2: Not Installed
  python-gnupg: 0.5.5
        PyYAML: 6.0.3
         PyZMQ: 27.1.0
        relenv: Not Installed
         smmap: Not Installed
       timelib: 0.3.0
       Tornado: 6.5.2
           ZMQ: 4.3.5
 
Salt Package Information:
  Package Type: Not Installed
 
System Versions:
          dist: ubuntu 24.04.4 noble
        locale: utf-8
       machine: x86_64
       release: 6.8.0-110-generic
        system: Linux
       version: Ubuntu 24.04.4 noble

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugbroken, incorrect, or confusing behaviorneeds-triage

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions