Skip to content

Instantly share code, notes, and snippets.

@lalyos
Last active February 28, 2023 03:38
Show Gist options
  • Star 7 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lalyos/09c0e6131b9de8240eb7 to your computer and use it in GitHub Desktop.
Save lalyos/09c0e6131b9de8240eb7 to your computer and use it in GitHub Desktop.
proxy docker /var/run/docker.sock to port 2375 with socat

The new Docker daemon uses port: 2376 with TLS enable by default. Sometimes I want to play with curl on the old plain http port 2375. The trick is: use socat in a container to proxy the unix socket to a real port.

docker run -d \
  --volume /var/run/docker.sock:/var/run/docker.sock \
  --name docker-http \
  deb socat -d -d TCP-L:2375,fork UNIX:/var/run/docker.sock
DOCKER_URL=$(docker inspect -f "{{.NetworkSettings.IPAddress}}" docker-http):2375
curl $DOCKER_URL/_ping

reference: https://gist.github.com/nuxlli/7553996

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment