Description
We have found a bug in the docker events command that captures Docker events. Specifically, when a network disconnect event occurs, it generates two events instead of one.
Reproduce
- Run the
docker events command to observe events:
docker events --filter "event=disconnect"
- Run the command to start a container connected to a network:
docker run -d --name test-container --network test-network nginx
- Disconnect the network from the container:
docker network disconnect test-network test-container
Expected behavior
The docker events command should generate a single event for each network disconnect. For example:
2024-10-30T19:05:20.743496360 network disconnect d331b8f1511379d6ddb431e249c478c3239e2ad54f14896a3c25f41bf8f70974 (container=6835ba7cb725b84add7e83f356b1fbae191b48a442e085d013fd29a153a58c45, name=test-network, type=bridge)
Actual Behavior
The docker events command generates two events for each network disconnect. For example:
2024-10-30T19:05:20.743496360 network disconnect d331b8f1511379d6ddb431e249c478c3239e2ad54f14896a3c25f41bf8f70974 (container=6835ba7cb725b84add7e83f356b1fbae191b48a442e085d013fd29a153a58c45, name=test-network, type=bridge)
2024-10-30T19:05:20.745043405 network disconnect d331b8f1511379d6ddb431e249c478c3239e2ad54f14896a3c25f41bf8f70974 (container=6835ba7cb725b84add7e83f356b1fbae191b48a442e085d013fd29a153a58c45, name=test-network, type=bridge)
docker version
Client: Docker Engine - Community
Version: 27.3.1
API version: 1.47
Go version: go1.22.7
Git commit: ce12230
Built: Fri Sep 20 11:41:00 2024
OS/Arch: linux/amd64
Context: default
Server: Docker Engine - Community
Engine:
Version: 27.3.1
API version: 1.47 (minimum version 1.24)
Go version: go1.22.7
Git commit: 41ca978
Built: Fri Sep 20 11:41:00 2024
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: 1.7.22
GitCommit: 7f7fdf5fed64eb6a7caf99b3e12efcf9d60e311c
runc:
Version: 1.1.14
GitCommit: v1.1.14-0-g2c9f560
docker-init:
Version: 0.19.0
GitCommit: de40ad0
docker info
Client: Docker Engine - Community
Version: 27.3.1
Context: default
Debug Mode: false
Plugins:
buildx: Docker Buildx (Docker Inc.)
Version: v0.17.1
Path: /usr/libexec/docker/cli-plugins/docker-buildx
compose: Docker Compose (Docker Inc.)
Version: v2.29.7
Path: /usr/libexec/docker/cli-plugins/docker-compose
Server:
Containers: 1
Running: 0
Paused: 0
Stopped: 1
Images: 21
Server Version: 27.3.1
Storage Driver: overlay2
Backing Filesystem: extfs
Supports d_type: true
Using metacopy: false
Native Overlay Diff: true
userxattr: false
Logging Driver: json-file
Cgroup Driver: systemd
Cgroup Version: 2
Plugins:
Volume: local
Network: bridge host ipvlan macvlan null overlay
Log: awslogs fluentd gcplogs gelf journald json-file local splunk syslog
Swarm: inactive
Runtimes: io.containerd.runc.v2 runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 7f7fdf5fed64eb6a7caf99b3e12efcf9d60e311c
runc version: v1.1.14-0-g2c9f560
init version: de40ad0
Security Options:
apparmor
seccomp
Profile: builtin
cgroupns
Kernel Version: 6.9.3-76060903-generic
Operating System: Pop!_OS 22.04 LTS
OSType: linux
Architecture: x86_64
CPUs: 16
Total Memory: 15.41GiB
Name: pop-os
ID: 1fa450f3-a97d-4219-9081-e02e277aa110
Docker Root Dir: /var/lib/docker
Debug Mode: false
Experimental: false
Insecure Registries:
127.0.0.0/8
Live Restore Enabled: false
Additional Info
This bug has been tested and confirmed to be valid for the following environments:
- Docker Version: 27.3.1
- Operating Systems:
- Pop!_OS 22.04 LTS
- Arch Linux 6.11.5-arch1-1
- Docker Version: 27.0.3
- Operating Systems:
- Ubuntu 22.04.4 LTS (Jammy Jellyfish)
We have checked the source code and identified the part of the code responsible for this behavior. We also have a fix ready and would be happy to contribute a pull request if needed.
Description
We have found a bug in the
docker eventscommand that captures Docker events. Specifically, when a network disconnect event occurs, it generates two events instead of one.Reproduce
docker eventscommand to observe events:Expected behavior
The
docker eventscommand should generate a single event for each network disconnect. For example:Actual Behavior
The
docker eventscommand generates two events for each network disconnect. For example:docker version
docker info
Additional Info
This bug has been tested and confirmed to be valid for the following environments:
We have checked the source code and identified the part of the code responsible for this behavior. We also have a fix ready and would be happy to contribute a pull request if needed.