Skip to content

use of closed network connection #7552

Backlog

Description

@SpaskeISO

Description

After reading logs with docker logs -f <container_name> and pressing CTRL+C I get this:

^Cread unix @->/run/docker.sock: use of closed network connection

This happens on Debian13 docker versions 29.10.1/29.10.0

Reproduce

docker logs -f <container_name>
CTRL+C

Expected behavior

There should not be error about unix socket

docker version

Client: Docker Engine - Community
 Version:           29.10.1
 API version:       1.57
 Go version:        go1.27.4
 Git commit:        c48360f
 Built:             Tue Nov 24 19:44:19 2026
 OS/Arch:           linux/amd64
 Context:           default

Server: Docker Engine - Community
 Engine:
  Version:          29.10.1
  API version:      1.57 (minimum version 1.40)
  Go version:       go1.27.4
  Git commit:       54cd494
  Built:            Tue Nov 24 19:44:41 2026
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          v2.4.2
  GitCommit:        b7a25261e029d68978bbf290df0a62fc819b3c51
 runc:
  Version:          1.5.3
  GitCommit:        v1.5.3-0-g46365c62
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

docker info

Client: Docker Engine - Community
 Version:    29.10.1
 Context:    default
 Debug Mode: false
 Plugins:
  buildx: Docker Buildx (Docker Inc.)
    Version:  v0.39.1
    Path:     /usr/libexec/docker/cli-plugins/docker-buildx
  compose: Docker Compose (Docker Inc.)
    Version:  v5.8.0
    Path:     /usr/libexec/docker/cli-plugins/docker-compose
  model: Docker Model Runner (Docker Inc.)
    Version:  v1.2.10
    Path:     /usr/libexec/docker/cli-plugins/docker-model

Server:
 Containers: 1
  Running: 1
  Paused: 0
  Stopped: 0
 Images: 1
 Server Version: 29.10.1
 Storage Driver: overlayfs
  driver-type: io.containerd.snapshotter.v1
 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
 CDI spec directories:
  /etc/cdi
  /var/run/cdi
 Swarm: inactive
 Runtimes: io.containerd.runc.v2 runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: b7a25261e029d68978bbf290df0a62fc819b3c51
 runc version: v1.5.3-0-g46365c62
 init version: de40ad0
 Security Options:
  apparmor
   Profile: default
  seccomp
   Profile: builtin
  cgroupns
 Kernel Version: 6.12.118+deb13-amd64
 Operating System: Debian GNU/Linux 13 (trixie)
 OSType: linux
 Architecture: x86_64
 CPUs: 6
 Total Memory: 23.48GiB
 Name: hom-smspp2-node1
 ID: 79b4843a-2ce8-4b6e-9f0f-2351b5a0262b
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 Experimental: false
 Insecure Registries:
  127.0.0.0/8
  ::1/128
 Live Restore Enabled: false
 Firewall Backend: iptables
  EnableUserlandProxy: true
  UserlandProxyPath: /usr/bin/docker-proxy

Additional Info

No response

Activity

  1. thaJeztah commented on Nov 27, 2026

    @thaJeztah
    Member

    Thanks for reporting; at a quick glance, I think this may be a race between the CLI terminating and the network closing; so at least for this case it would be harmless. But possibly we can improve (ignore some sentinel errors) but there may still be a race, and we probably can't unconditionally ignore "network closing" errors, because in other situations they may be unexpected.

    I tried reproducing the issue, but so far didn't; perhaps you can provide more information;

    • Did this work correctly with Docker 29.9?
    • Does this happen consistently, or only occasionally?
    • Is the container continuously producing logs, or is docker logs -f idle when pressing Ctrl+C?
    • Was the container created with -t (TTY enabled)?
    • Is Docker invoked directly, through an alias or wrapper script, or over SSH?
    • Does this also happen when interrupting docker events?
  2. thaJeztah commented on Nov 27, 2026

    @thaJeztah
    Member

    If possible, perhaps you can provide a minimal reproducer with the exact commands (including a public image to use for reproducing if it depends on that)

  3. thaJeztah commented on Nov 27, 2026

    @thaJeztah
    Member

    FWIW (and note to self); currently the code doesn't explicitly handle context-cancellation errors, which is something we may want to add; but we should check if `` should also be handled explicitly;

    if err != nil {
    return err
    }
    defer func() { _ = resp.Close() }()
    if c.Container.Config.Tty {
    _, err = io.Copy(dockerCli.Out(), resp)
    } else {
    _, err = stdcopy.StdCopy(dockerCli.Out(), dockerCli.Err(), resp)
    }
    return err

    i.e., something like this (but possibly without the network error handling);

    if errors.Is(err, net.ErrClosed) && errors.Is(ctx.Err(), context.Canceled) {
        return ctx.Err()
    }
    return err
  4. SpaskeISO commented on Nov 30, 2026

    @SpaskeISO
    Author

    Hi, here are some answers for your questions:

    • Yes it did work with Docker 29.9.
    • This does not happen consistently but it is frequent.
    • Container is either.
    • No.
    • It was invoked using Ansible
    • I don't know.

    I'm sorry I can't provide a public facing image since this is docker image from a company where I work.
    Image is built from latest Alpine release and inside is a golang binary.

  5. thaJeztah commented on Nov 30, 2026

    @thaJeztah
    Member

    I was able to reproduce this in a client unit test without a daemon running, and narrowed it down to a change introduced in Go 1.27.2:

    The change fixes a deadlock when concurrently reading and closing an HTTP response body, but also changes how errors are propagated in that situation.

    Our client uses newCancelReadCloser to explicitly close the response body on context cancellation, which races with the HTTP transport's own cancellation handling. Starting with Go 1.27.2, this can result in net.ErrClosed being returned instead of context.Canceled.

    A reproducer using only net/http passes, but adding our newCancelReadCloser wrapper reproduces the issue. We should look into removing this redundant cancellation handling from the client, as the HTTP transport already handles request context cancellation.

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions