moby: write unix /var/run/docker.sock->@: write: broken pipe

I’m sending commands to different containers; this was working correctly until a few days ago. Since then, the only thing that changed is; a new Docker version was released and I switched from a TCP connection to a socket connection. Rest of the commands execute fine.

Information:

This environment runs inside of a virtual machine with Debian Jessie.

$ docker version
Client:
 Version:      1.11.0
 API version:  1.23
 Go version:   go1.5.4
 Git commit:   4dc5990
 Built:        Wed Apr 13 18:17:17 2016
 OS/Arch:      linux/amd64

Server:
 Version:      1.11.0
 API version:  1.23
 Go version:   go1.5.4
 Git commit:   4dc5990
 Built:        Wed Apr 13 18:17:17 2016
 OS/Arch:      linux/amd64

$ docker info
Containers: 9
 Running: 6
 Paused: 0
 Stopped: 3
Images: 12
Server Version: 1.11.0
Storage Driver: aufs
 Root Dir: /var/lib/docker/aufs
 Backing Filesystem: extfs
 Dirs: 89
 Dirperm1 Supported: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins: 
 Volume: local
 Network: bridge null host
Kernel Version: 3.16.0-4-amd64
Operating System: Debian GNU/Linux 8 (jessie)
OSType: linux
Architecture: x86_64
CPUs: 2
Total Memory: 1.963 GiB
Name: docker-host
ID: 4NGE:LLRW:4LEL:CE6Q:S7BN:UZ6Q:LA6K:4WHG:PNRI:LHAD:TWFW:WDBJ
Docker Root Dir: /var/lib/docker
Debug mode (client): false
Debug mode (server): false
Registry: https://index.docker.io/v1/
WARNING: No memory limit support
WARNING: No swap limit support
WARNING: No kernel memory limit support
WARNING: No oom kill disable support
WARNING: No cpu cfs quota support
WARNING: No cpu cfs period support

$ uname -a
Linux docker-host 3.16.0-4-amd64 #1 SMP Debian 3.16.7-ckt25-1 (2016-03-06) x86_64 GNU/Linux

$ cat /etc/issue
Debian GNU/Linux 8 \n \l
Apr 21 07:35:46 docker-host docker[11709]: time="2016-04-21T07:35:46.790486036Z" level=error msg="attach: stdout: write unix /var/run/docker.sock->@: write: broken pipe"
Apr 21 07:35:46 docker-host docker[11709]: time="2016-04-21T07:35:46.931491694Z" level=error msg="Error running exec in container: attach failed with error: write unix /var/run/docker.sock->@: write: broken pipe\n"
Apr 21 07:35:46 docker-host docker[11709]: time="2016-04-21T07:35:46.931563085Z" level=error msg="Handler for POST /exec/fc6c278bc319d31ae125e6bfe62aab3bed6ae54d64223597e2c7a367fd540153/start returned error: attach failed with error: write unix /var/run/docker.sock->@: write: broken pipe"
Apr 21 07:35:46 docker-host docker[11709]: 2016/04/21 07:35:46 http: response.WriteHeader on hijacked connection
Apr 21 07:35:46 docker-host docker[11709]: 2016/04/21 07:35:46 http: response.Write on hijacked connection

Update: The problem occurs also when using a TCP connection: Update: When using a TCP connection there are less of these errors then when using a socket connection.

Apr 21 08:33:24 docker-host docker[25468]: time="2016-04-21T08:33:24.772961231Z" level=error msg="attach: stderr: write tcp 10.99.0.99:2375->172.17.0.2:40968: write: broken pipe"
Apr 21 08:33:25 docker-host docker[25468]: time="2016-04-21T08:33:25.890528192Z" level=error msg="Error running exec in container: attach failed with error: write tcp 10.99.0.99:2375->172.17.0.2:40968: write: broken pipe\n"
Apr 21 08:33:25 docker-host docker[25468]: time="2016-04-21T08:33:25.890563806Z" level=error msg="Handler for POST /exec/aca8b3206f70586afa35766edf858827b57dd1e7a5643878df1996c8c818f061/start returned error: attach failed with error: write tcp 10.99.0.99:2375->172.17.0.2:40968: write: broken pipe"
Apr 21 08:33:25 docker-host docker[25468]: 2016/04/21 08:33:25 http: response.WriteHeader on hijacked connection
Apr 21 08:33:25 docker-host docker[25468]: 2016/04/21 08:33:25 http: response.Write on hijacked connection

docker-php issue: https://github.com/docker-php/docker-php/issues/195

About this issue

  • Original URL
  • State: open
  • Created 8 years ago
  • Reactions: 15
  • Comments: 35 (8 by maintainers)

Most upvoted comments

I hit the same issue on my Kubernetes worker node, I have no idea on this. And I’m not sure this issue breaks the status of the nodes.

Client: Docker Engine - Community
 Version:           19.03.1
 API version:       1.39 (downgraded from 1.40)
 Go version:        go1.12.5
 Git commit:        74b1e89
 Built:             Thu Jul 25 21:21:07 2019
 OS/Arch:           linux/amd64
 Experimental:      false

Server: Docker Engine - Community
 Engine:
  Version:          18.09.8
  API version:      1.39 (minimum version 1.12)
  Go version:       go1.10.8
  Git commit:       0dd43dd
  Built:            Wed Jul 17 17:10:42 2019
  OS/Arch:          linux/amd64
  Experimental:     false
Sep  6 14:06:06 QTBJZGCS05 dockerd: http: multiple response.WriteHeader calls
Sep  6 14:06:06 QTBJZGCS05 dockerd: time="2019-09-06T14:06:06.191603031+08:00" level=error msg="Handler for GET /v1.38/containers/9a6dcfc92ead424dcbbf2988211610bef80d0c9b608728ccf9a75e7f0904680c/json returned error: write unix /var/run/docker.sock->@: write: broken pipe"
Sep  6 14:06:06 QTBJZGCS05 dockerd: time="2019-09-06T14:06:06.191867403+08:00" level=error msg="Handler for GET /v1.38/containers/9a6dcfc92ead424dcbbf2988211610bef80d0c9b608728ccf9a75e7f0904680c/json returned error: write unix /var/run/docker.sock->@: write: broken pipe"
Sep  6 14:06:06 QTBJZGCS05 dockerd: time="2019-09-06T14:06:06.192076133+08:00" level=error msg="Handler for GET /v1.38/containers/9a6dcfc92ead424dcbbf2988211610bef80d0c9b608728ccf9a75e7f0904680c/json returned error: write unix /var/run/docker.sock->@: write: broken pipe"
Sep  6 14:06:06 QTBJZGCS05 dockerd: http: multiple response.WriteHeader calls
Sep  6 14:06:06 QTBJZGCS05 dockerd: time="2019-09-06T14:06:06.192256467+08:00" level=error msg="Handler for GET /v1.38/containers/9a6dcfc92ead424dcbbf2988211610bef80d0c9b608728ccf9a75e7f0904680c/json returned error: write unix /var/run/docker.sock->@: write: broken pipe"
Sep  6 14:06:06 QTBJZGCS05 dockerd: time="2019-09-06T14:06:06.192437080+08:00" level=error msg="Handler for GET /v1.38/containers/9a6dcfc92ead424dcbbf2988211610bef80d0c9b608728ccf9a75e7f0904680c/json returned error: write unix /var/run/docker.sock->@: write: broken pipe"
Sep  6 14:06:06 QTBJZGCS05 dockerd: time="2019-09-06T14:06:06.192611055+08:00" level=error msg="Handler for GET /v1.38/containers/9a6dcfc92ead424dcbbf2988211610bef80d0c9b608728ccf9a75e7f0904680c/json returned error: write unix /var/run/docker.sock->@: write: broken pipe"
Sep  6 14:06:06 QTBJZGCS05 dockerd: http: multiple response.WriteHeader calls
Sep  6 14:06:06 QTBJZGCS05 dockerd: time="2019-09-06T14:06:06.192781402+08:00" level=error msg="Handler for GET /v1.38/containers/9a6dcfc92ead424dcbbf2988211610bef80d0c9b608728ccf9a75e7f0904680c/json returned error: write unix /var/run/docker.sock->@: write: broken pipe"
Sep  6 14:06:06 QTBJZGCS05 dockerd: time="2019-09-06T14:06:06.192952679+08:00" level=error msg="Handler for GET /v1.38/containers/9a6dcfc92ead424dcbbf2988211610bef80d0c9b608728ccf9a75e7f0904680c/json returned error: write unix /var/run/docker.sock->@: write: broken pipe"
Sep  6 14:06:06 QTBJZGCS05 dockerd: time="2019-09-06T14:06:06.193150911+08:00" level=error msg="Handler for GET /v1.38/containers/9a6dcfc92ead424dcbbf2988211610bef80d0c9b608728ccf9a75e7f0904680c/json returned error: write unix /var/run/docker.sock->@: write: broken pipe"
Sep  6 14:06:06 QTBJZGCS05 dockerd: http: multiple response.WriteHeader calls
Sep  6 14:06:06 QTBJZGCS05 dockerd: time="2019-09-06T14:06:06.193328210+08:00" level=error msg="Handler for GET /v1.38/containers/9a6dcfc92ead424dcbbf2988211610bef80d0c9b608728ccf9a75e7f0904680c/json returned error: write unix /var/run/docker.sock->@: write: broken pipe"
Sep  6 14:06:06 QTBJZGCS05 dockerd: time="2019-09-06T14:06:06.193526847+08:00" level=error msg="Handler for GET /v1.38/containers/9a6dcfc92ead424dcbbf2988211610bef80d0c9b608728ccf9a75e7f0904680c/json returned error: write unix /var/run/docker.sock->@: write: broken pipe"
Sep  6 14:06:06 QTBJZGCS05 dockerd: http: multiple response.WriteHeader calls
Sep  6 14:06:06 QTBJZGCS05 dockerd: time="2019-09-06T14:06:06.193790537+08:00" level=error msg="Handler for GET /v1.38/containers/9a6dcfc92ead424dcbbf2988211610bef80d0c9b608728ccf9a75e7f0904680c/json returned error: write unix /var/run/docker.sock->@: write: broken pipe"
Sep  6 14:06:06 QTBJZGCS05 dockerd: http: multiple response.WriteHeader calls
Sep  6 14:06:06 QTBJZGCS05 dockerd: time="2019-09-06T14:06:06.194136770+08:00" level=error msg="Handler for GET /v1.38/containers/9a6dcfc92ead424dcbbf2988211610bef80d0c9b608728ccf9a75e7f0904680c/json returned error: write unix /var/run/docker.sock->@: write: broken pipe"
Sep  6 14:06:06 QTBJZGCS05 dockerd: http: multiple response.WriteHeader calls
Sep  6 14:06:06 QTBJZGCS05 dockerd: time="2019-09-06T14:06:06.194439164+08:00" level=error msg="Handler for GET /v1.38/containers/9a6dcfc92ead424dcbbf2988211610bef80d0c9b608728ccf9a75e7f0904680c/json returned error: write unix /var/run/docker.sock->@: write: broken pipe"
Sep  6 14:06:06 QTBJZGCS05 dockerd: http: multiple response.WriteHeader calls
Sep  6 14:06:06 QTBJZGCS05 dockerd: time="2019-09-06T14:06:06.194740839+08:00" level=error msg="Handler for GET /v1.38/containers/9a6dcfc92ead424dcbbf2988211610bef80d0c9b608728ccf9a75e7f0904680c/json returned error: write unix /var/run/docker.sock->@: write: broken pipe"
Sep  6 14:06:06 QTBJZGCS05 dockerd: http: multiple response.WriteHeader calls
Sep  6 14:06:06 QTBJZGCS05 dockerd: http: multiple response.WriteHeader calls
Sep  6 14:06:06 QTBJZGCS05 dockerd: time="2019-09-06T14:06:06.195041328+08:00" level=error msg="Handler for GET /v1.38/containers/9a6dcfc92ead424dcbbf2988211610bef80d0c9b608728ccf9a75e7f0904680c/json returned error: write unix /var/run/docker.sock->@: write: broken pipe"
Sep  6 14:06:06 QTBJZGCS05 dockerd: http: multiple response.WriteHeader calls
Sep  6 14:06:06 QTBJZGCS05 dockerd: time="2019-09-06T14:06:06.195334850+08:00" level=error msg="Handler for GET /v1.38/containers/9a6dcfc92ead424dcbbf2988211610bef80d0c9b608728ccf9a75e7f0904680c/json returned error: write unix /var/run/docker.sock->@: write: broken pipe"
Sep  6 14:06:06 QTBJZGCS05 dockerd: http: multiple response.WriteHeader calls
Sep  6 14:06:06 QTBJZGCS05 dockerd: time="2019-09-06T14:06:06.195618613+08:00" level=error msg="Handler for GET /v1.38/containers/9a6dcfc92ead424dcbbf2988211610bef80d0c9b608728ccf9a75e7f0904680c/json returned error: write unix /var/run/docker.sock->@: write: broken pipe"
Sep  6 14:06:06 QTBJZGCS05 dockerd: http: multiple response.WriteHeader calls
Sep  6 14:06:06 QTBJZGCS05 dockerd: time="2019-09-06T14:06:06.195918516+08:00" level=error msg="Handler for GET /v1.38/containers/9a6dcfc92ead424dcbbf2988211610bef80d0c9b608728ccf9a75e7f0904680c/json returned error: write unix /var/run/docker.sock->@: write: broken pipe"
Sep  6 14:06:06 QTBJZGCS05 dockerd: http: multiple response.WriteHeader calls
Sep  6 14:06:06 QTBJZGCS05 dockerd: http: multiple response.WriteHeader calls
Sep  6 14:06:06 QTBJZGCS05 dockerd: time="2019-09-06T14:06:06.196228925+08:00" level=error msg="Handler for GET /v1.38/containers/9a6dcfc92ead424dcbbf2988211610bef80d0c9b608728ccf9a75e7f0904680c/json returned error: write unix /var/run/docker.sock->@: write: broken pipe"
Sep  6 14:06:06 QTBJZGCS05 dockerd: http: multiple response.WriteHeader calls
Sep  6 14:06:06 QTBJZGCS05 dockerd: time="2019-09-06T14:06:06.196519655+08:00" level=error msg="Handler for GET /v1.38/containers/9a6dcfc92ead424dcbbf2988211610bef80d0c9b608728ccf9a75e7f0904680c/json returned error: write unix /var/run/docker.sock->@: write: broken pipe"
Sep  6 14:06:06 QTBJZGCS05 dockerd: http: multiple response.WriteHeader calls
Sep  6 14:06:06 QTBJZGCS05 dockerd: http: multiple response.WriteHeader calls
Sep  6 14:06:06 QTBJZGCS05 dockerd: http: multiple response.WriteHeader calls
Sep  6 14:06:06 QTBJZGCS05 dockerd: http: multiple response.WriteHeader calls
Sep  6 14:06:06 QTBJZGCS05 dockerd: http: multiple response.WriteHeader calls

I am getting this issue under heavy stdout loads

This is because docker is trying to write a response to a client connection and the client has closed the connection.

2016/08/02 17:04:43 http: multiple response.WriteHeader calls time="2016-08-02T17:04:43.813279646Z" level=error msg="Handler for GET /containers/json returned error: write unix /var/run/docker.sock->@: write: broken pipe"

$ docker -v Docker version 1.11.2, build b9f10c9/1.11.2

AWS/ECS AMI

Investigating…

We encountered:

dockerd time="2021-11-12T16:49:49.652154050Z" level=error msg="Handler for GET /v1.40/containers/json returned error: write unix /var/run/docker.sock->@: write: broken pipe"
dockerd http: superfluous response.WriteHeader call from github.com/docker/docker/api/server/httputils.WriteJSON (httputils_write_json.go:11)

on Docker Engine version 19.03.15 on a AWS instance with an attached gp3 ebs with the default values of 3000 IOPS and 125 MiB/s throughput, and considered increasing the IOPS value after reading this comment:

We were able to mitigate this issue on our GKE cluster. While debugging, we saw that the Docker API was taking really long to respond. We got in contact with Google Cloud support and they suggested that we changed our nodes’ persistent disks with SSDs or something with better IOPS.

However that gave us an idea that maybe the daemon was having issue starting with some of the unused/dangling images in the server, as the daemon was using 50% CPU and almost exhausting the available memory even without running containers (with the exception of a single Datadog container), after running:

docker system prune --volumes

Which took an unusually long time (15 min) to delete just 2.8GB, the problem went away, and memory and CPU went back to normal idle levels.

As mentioned above, we do have a running Datadog container on every instance but only 1 out of many was having this issue, so it could also be a combination of a bad unused/dangling image and the Datadog container trying to collect data.

@thaJeztah sorry for bothering, but maybe you can provide some information about the state of this issue? I have the same trouble with 17.06.2-ce

@Aisuko yes, we started noticing fewer docker.sock broken pipe errors. In our case, we had a combination of some containers logging as hell, constantly crashing, being OOMKilled, restarting and too many containers in a single node. Maybe monitoring and tweaking this can help to reduce the load on the Docker API, as well as switching to SSD.

The problem went away for us when we stopped using a particular setting in the Datadog agent (collecting Docker image stats).

I’m seeing this problem when running the DataDog agent (v6) in Docker, which monitors docker.sock to upload stats. See https://github.com/aws/amazon-ecs-agent/issues/1489

It’s happening very consistently to me, but it would be fairly complicated for me to make a minimal repro, since our setup has most of the work going through Amazon’s ECS agent.

@allencloud I would say yes… but I’m sure you’ve got some situation that will cause me to eat my words… 😃

I’m getting this all over the place. Thought it was an issue for older versions, but this one was just updated after seeing it the first time and now I’m getting it again less than a day later.

time="2017-04-19T07:30:41.866377909-04:00" level=info msg="Container 3966aab6af368a47e375ef4a77fa9838b007dbe79b17d613626d0a2f59aa1a3d failed to exit within 10 seconds of signal 15 - using the force" 
time="2017-04-19T07:31:41.992926286-04:00" level=info msg="Container d63b8d713d771610f9df0df1e7032065c06b4bd4884e685d0fc0ec2d9776fb77 failed to exit within 10 seconds of signal 15 - using the force" 
time="2017-04-19T08:32:43.627664879-04:00" level=info msg="Container f919e3be04153d2f892bf67d24d9425c30d356cd50b9394721a18e53abf9d520 failed to exit within 10 seconds of signal 15 - using the force" 
time="2017-04-19T09:01:34.386621665-04:00" level=error msg="Handler for DELETE /containers/3cbfbeebc4c0340784a0a4bc1d8d7c211fa7b4f7db6002e8aaa6ffc622807b19 returned error: No such container: 3cbfbeebc4c0340784a0a4bc1d8d7c211fa7b4f7db6002e8aaa6ffc622807b19" 
time="2017-04-19T09:34:45.216217643-04:00" level=info msg="Container e4ce7748e8e7a05196f1ee5444e1f63397beeba5afce350f956aadced8703279 failed to exit within 10 seconds of signal 15 - using the force" 
time="2017-04-19T10:36:47.356670589-04:00" level=info msg="Container a95536fbba027a145f01f976df8aae38c317f76a1295fb5d12ea4a3a6ca80a39 failed to exit within 10 seconds of signal 15 - using the force" 
time="2017-04-19T10:38:47.366794457-04:00" level=info msg="Container 30ee59666618d967c5ee19bb63cc8d48fe4ee672c2f3c7237b6bec63d566f173 failed to exit within 10 seconds of signal 15 - using the force" 
time="2017-04-19T11:05:32.990480757-04:00" level=error msg="Handler for GET /events returned error: write unix /var/run/docker.sock->@: write: broken pipe" 
2017-04-19 11:05:32.990972 I | http: multiple response.WriteHeader calls
time="2017-04-19T11:05:33.003373208-04:00" level=error msg="Handler for GET /events returned error: write unix /var/run/docker.sock->@: write: broken pipe" 
2017-04-19 11:05:33.005297 I | http: multiple response.WriteHeader calls
time="2017-04-19T11:05:33.446175758-04:00" level=error msg="Handler for POST /v1.28/containers/b39e72f43276ad7b079c569827a9920a25458f02ca0e96192749eb187ca67139/start returned error: Container already started" 
# docker info
Containers: 7
 Running: 7
 Paused: 0
 Stopped: 0
Images: 205
Server Version: 17.04.0-ce
Storage Driver: aufs
 Root Dir: /var/lib/docker/aufs
 Backing Filesystem: extfs
 Dirs: 653
 Dirperm1 Supported: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins: 
 Volume: local
 Network: bridge host macvlan null overlay
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: 
containerd version: 422e31ce907fd9c3833a38d7b8fdd023e5a76e73
runc version: 9c2d8d184e5da67c95d601382adf14862e4f2228
init version: 949e6fa
Security Options:
 apparmor
Kernel Version: 4.2.0-36-generic
Operating System: Ubuntu 14.04.5 LTS
OSType: linux
Architecture: x86_64
CPUs: 2
Total Memory: 1.954GiB
Name: docker-nla-1
ID: QK5U:STCF:TVWG:HUKC:D5AF:FFDF:55AB:OEJD:OIS4:D66T:2LHB:NPS5
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): false
Registry: https://index.docker.io/v1/
Experimental: false
Insecure Registries:
 127.0.0.0/8
Live Restore Enabled: false

WARNING: No swap limit support