Pipe input to dockerized socat run on socket present on docker host

516 Views Asked by At

My goal is to query Haproxy Runtime API using dockerized socat.

Below command returns empty result (/var/run/haproxy.stat is haproxy socket located on the docker host)

 echo "-h" | docker run  -a stdin -a stderr alpine/socat stdio /var/run/haproxy.stat

I've tried to add haproxy socket via volume, but the result is still empty.

echo "-h" | docker run  -a stdin -a stderr  -v /var/run/haproxy.stat:/var/run/haproxy.stat alpine/socat stdio /var/run/haproxy.stat
1

There are 1 best solutions below

2
On BEST ANSWER

Command that worked is:

echo "-h" | docker run -i -a stdin -a stderr -a stdout -v /var/run/haproxy.stat:/var/run/haproxy.stat alpine/socat stdio /var/run/haproxy.stat

Needed to add -a stdout and -i to docker run

Following suggestion by BMitch" tried below command and it worked as well

echo "-h" | docker run -i -v /var/run/haproxy.stat:/var/run/haproxy.stat alpine/socat stdio /var/run/haproxy.stat