docker / cli

The Docker CLI
Apache License 2.0
4.75k stars 1.88k forks source link

CLI hangs on interactive run when container fails to attach to network #5235

Open laurazard opened 5 days ago

laurazard commented 5 days ago

Description

-

Reproduce

$ docker swarm init
$ docker network create \
  --driver overlay \
  --ipv6 \
  --opt encrypted \
  --subnet "10.0.100.0/24" \
  --subnet "fd14:8656:a32e:100::/64" \
  --attachable \
  test
$ docker run --rm -it --network test alpine

Expected behavior

The CLI should handle SIGINTs and not hang.

docker version

Happens on recent builds:

Client:
 Version:           27.0.1-45-g4029dbc129
 API version:       1.46
 Go version:        go1.22.1
 Git commit:        4029dbc129
 Built:             Fri Jul  5 10:31:39 2024
 OS/Arch:           darwin/arm64
 Context:           desktop-linux

But also already happens as far back 25.0 (maybe more).

Additional Info

From Slack (@akerouanton):

[...] adding this subnet makes the docker run command send a ContainerStart request to the daemon, then the daemon makes a gRPC call to swarmkit and things hangs there for 30s. Until the CLI's stdin/out/err are attached to the container, maybe the right behavior should be to cancel the request? [...]