Docker Continuously Making Unnecessary SSH Connections to Remote Servers

I’m using Docker Desktop for Mac and utilizing docker context to connect to remote servers via SSH. I then build and deploy services using Docker Compose. Everything seems to work normally, however, recently when I checked the server logs, I noticed that my machine was persistently making SSH connections to the remote server, connecting every few seconds.

root@aaaaaaaaa:~# tail -f /var/log/auth.log | grep Accepted
May 21 06:56:09 aaaaaaaa sshd[168869]: Accepted publickey for root from 111.111.111.111 port 57088 ssh2: ED25519 SHA256:xxxxxxxxxxxxxxxx

When I checked my local machine with pstree, I found that com.docker.build was constantly making SSH connections to the remote servers and executing the docker system dial-stdio command.

pstree -u $USER 06567
-+- 06567 tao com.docker.build
|--= 06609 tao ssh -- law-us docker system dial-stdio
|--= 06632 tao ssh -- shui-us docker system dial-stdio
|--= 06633 tao ssh -- law-us docker system dial-stdio
|--= 07561 tao ssh -- shui-us docker system dial-stdio
...

Interestingly, at this time, I am not even using the context of these servers. My current context is the local system. I’m wondering what could be causing this? How can I prevent these seemingly meaningless connection attempts?

The version of my current setup is:

  • Docker Desktop: 4.19.0 (106363)
  • Docker version:
Client: Docker Engine - Community
 Version:           23.0.2
 API version:       1.42
 Go version:        go1.20.2
 Git commit:        569dd73db1
 Built:             Mon Mar 27 15:44:26 2023
 OS/Arch:           darwin/arm64
 Context:           desktop-linux

Server: Docker Desktop 4.19.0 (106363)
 Engine:
  Version:          23.0.5
  API version:      1.42 (minimum version 1.12)
  Go version:       go1.19.8
  Git commit:       94d3ad6
  Built:            Wed Apr 26 16:17:14 2023
  OS/Arch:          linux/arm64
  Experimental:     false
 containerd:
  Version:          1.6.20
  GitCommit:        2806fc1057397dbaeefbea0e4e17bddfbd388f38
 runc:
  Version:          1.1.5
  GitCommit:        v1.1.5-0-gf19387a
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

This is the time when I have to say thank you just for asking a question :slight_smile: It is starting to make sense. There is an old issue:

The last comment that I linked explains an error which is related to too many connections. dial-stdio is a non-documented argument which shouldn’t be called manually and it is proxying the standard io (stdin, stdout, stderr). It is probably required when you run a container and want to execcute a command in it remotely, but I agree, it shouldn’t be there when you don’t even use the context. If there is a good reason why it is running constantly, I don’t know that. My first thought was that it could be some kind of “keep-alived” mechanism, but there is nothing to keep alive in your case unles there is a process that is running and connecting to a remote containr even if you switched to another context in your current terminal session. Is it possible that you have a running process in the background and keeps the SSH connection to the remote context alive? Did you restart your machine or Docker Desktop recently?

I’ve just started to see those processes recently and my situation is almost the same as you. I have a few servers on my local network to which I have contexts created to connect to, but I’m not currently using any.

My environment is Win11 with Docker Desktop 4.19.0(106363), engine v23.0.5, compose v2.17.3 and I usually work through WSL2 and those servers are Ubuntu 20.04