docker-socket-proxy icon indicating copy to clipboard operation
docker-socket-proxy copied to clipboard

Difference in Docker Socket Behavior When Forwarding via TCP vs HTTP with HAProxy

Open codexvn opened this issue 5 months ago • 0 comments

I am looking for a service that forwards a Docker socket to TCP. So far, I have found this project and the socat project.

Here are the commands I am using:

docker run -d \
  --name docker-socket-proxy \
  -p 2377:2375 \
  -e AUTH=1 \
  -e SECRETS=1 \
  -e POST=1 \
  -e BUILD=1 \
  -e COMMIT=1 \
  -e CONFIGS=1 \
  -e CONTAINERS=1 \
  -e ALLOW_START=1 \
  -e ALLOW_STOP=1 \
  -e ALLOW_RESTARTS=1 \
  -e DISTRIBUTION=1 \
  -e EXEC=1 \
  -e GRPC=1 \
  -e IMAGES=1 \
  -e INFO=1 \
  -e NETWORKS=1 \
  -e NODES=1 \
  -e PLUGINS=1 \
  -e SERVICES=1 \
  -e SESSION=1 \
  -e SWARM=1 \
  -e SYSTEM=1 \
  -e TASKS=1 \
  -e VOLUMES=1 \
  -e DISABLE_IPV6=1 \
  -v /var/run/docker.sock:/var/run/docker.sock \
  ghcr.io/tecnativa/docker-socket-proxy:latest

docker run -d --name=dockersock2tcp -p 2375:2375 -v /var/run/docker.sock:/var/run/docker.sock alpine/socat TCP-LISTEN:2375,reuseaddr,keepalive,fork UNIX-CONNECT:/var/run/docker.sock

I noticed that using the same command can produce different results:

env DOCKER_HOST=tcp://localhost:2375 docker buildx ls

After investigating, I found that the difference is due to haproxy.cfg using mode http. When I switched it to mode tcp, it worked as expected.

Is this known behavior? Could you please explain why this option causes different Docker behavior?

codexvn avatar Aug 29 '25 07:08 codexvn