Docker container loses network connectivity intermittently

Hi there,

This issue has been driving my crazy for quite some time now, and I’ve been pulling my hair out trying to get to the bottom of it, so any help would be greatly appreciated. :sweat_smile:

Setup:

  • Docker for mac (4.4.2, but have seen the issue across many versions)
  • Using docker-compose to run the containers locally (no additional networking or DNS settings in the compose file))
  • Using Mac with intel chip

The issue:
When a container is newly created, all networking will work as expected; it can ping out to the internet, and connect to our external services (AWS, a remote-hosted database & cache).

However, after a few minutes all outgoing connections on the container will fail, and never recover for the life of the container (occasionally it will recover for a few seconds, but ultimately no new connections can be made).

For example, trying to ping an outside address from the container:

root@92cddcdcd645:/app# ping google.com
PING google.com (142.250.176.206) 56(84) bytes of data.
From 172.25.0.1 (172.25.0.1) icmp_seq=35 Destination Host Unreachable
From 172.25.0.1 (172.25.0.1) icmp_seq=36 Destination Host Unreachable
From 172.25.0.1 (172.25.0.1) icmp_seq=44 Destination Host Unreachable

Running the docker diagnostics also points to an issue connecting to the internet:


$ /Applications/Docker.app/Contents/MacOS/com.docker.diagnose check
...
[FAIL] DD0012: is the VM networking working? network checks failed: failed to ping host: exit status 1

Things I’ve tried:

  • Disabling VPN
  • Removing anti-virus software (Sophos)

This issue has been going on for almost 2 months now (don’t know what really started it), but have read countless articles about issues related to docker-networking, and nothing has really pointed to a solutions.

I feel like I’ve sort of exhausted all my options at this point for figuring out what is happening here. I also don’t have too much experience with low-level networking, so open to any suggestions for ways to debug what might be going on (any logs or things to look at that might give more details?)

Also happy to provide any more details that might be useful.

Thanks!

1 Like

same deal has been happening to me for months across various versions, most recently Docker Desktop 4.7.1.

$ /Applications/Docker.app/Contents/MacOS/com.docker.diagnose check
Starting diagnostics
...
[FAIL] DD0012: is the VM networking working? network checks failed: failed to ping host: exit status 1

things work fine for a time, then all containers lose networking. restarting docker fixes it.

increasing the number of max-connections seems to be helping me, Override --max-connections configuration · Issue #2610 · docker/for-mac · GitHub

1 Like

also seeing DD0012 (“network checks failed: failed to ping host”) and so far unable to fix, including after uninstall and fresh install of Docker and a few reboots.
my setup:

  • macOS 12.4 (21F79)
  • MacBookPro15,1
  • Docker 4.9.0 (downloaded yesterday)

same here, after around 20h work without problems, no connection to the outside can be made.
Container restart helps.

Docker Mac 4.8.2
MacOS 12.4
Mac mini (M1, 2020)

Same issue here. Has anyone here made any progress?

Looks like a similar problem is described here Docker daemon stops accepting connections when vpnkit is under load · Issue #2841 · docker/for-mac · GitHub and it still happens.

Increasing --max-connections in ~/Library/Group\ Containers/group.com.docker/settings.json is not helping for me

DockerMac: 4.13.1
macOS: 12.6
MacBookPro Intel 2020

The only way I managed to work around this was to downgrade to Docker Mac 3.6.0 which has been consistently stable since April 2022, but I’m now way out of date. If I’m on any 4.x release, it breaks pretty quickly in the described way.

1 Like

This is happening to me as well, even after the latest update. Only thing that fixes it is a Docker restart.

DockerMac: 4.14.1 (91661)
macOS: 13.0.1
MacbookPro (M1 Pro - 16 in - 2021)

Ridiculous this hasn’t been fixed as it makes using docker for local development a pain.

Thanks for this suggestion, this problem has been driving me crazy for weeks. A restart would fix it but only for a short while. Docker 3.6.0 has completely solved the problem!

1 Like

I’ve submitted a bug on Docker’s git and they’re looking into it next week. Here’s a link so you can follow along.

Hi everyone. The problem we have right now, is that once in a while, containers with high volume of data, lose connection for 5 minutes and reconnect after 5 minutes. docker swarm is set on AWS with 80 containers. what can be the reason? lack of IP or lack of memory? please someone help me.