How to make a HTTP::Client connect to a unix socket?

I am trying to query the docker engine via /var/run/docker.sock

Not quite sure how to set up HTTP::Client with a unix socket.

I see a bunch of old shards using HTTP::Client.unix but that seems to be obsolete.

Can anyone point me in the right direction?

I naively tried:

require "uri"
require "http/client"

uri = URI.parse "unix:///var/run/docker.sock"
client = uri

puts client

But get a

Unhandled exception: Unsupported scheme: unix

Try creating a, then passing that IO to

Ref: Allow HTTP::Client to work with any IO by waj · Pull Request #9543 · crystal-lang/crystal · GitHub


It should work:

socket ="/var/run/docker.sock")
client =

This Docker client seems maintened: GitHub - marghidanu/docr: Crystal Docker client

1 Like