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!

3 Likes

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

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)