umputun / reproxy

Simple edge server / reverse proxy
http://reproxy.io
MIT License
1.23k stars 92 forks source link

Docker provider failed on docker version 25 #171

Closed rashpile closed 8 months ago

rashpile commented 8 months ago

System info:

docker version 
Client: Docker Engine - Community
 Version:           25.0.1
 API version:       1.44
 Go version:        go1.21.6
 Git commit:        29cf629
 Built:             Tue Jan 23 23:09:23 2024
 OS/Arch:           linux/amd64
 Context:           default

Steps to reproduce:

docker run --rm -e DOCKER_ENABLED=true \
  -v /var/run/docker.sock:/var/run/docker.sock:ro \
  umputun/reproxy:master

Error:

reproxy master-fe24cf9-20240125T09:30:03
[INFO]  activate http proxy server on 0.0.0.0:8080
[ERROR] failed to fetch running containers: can't list containers: 
  failed to parse error from docker daemon: 
  invalid character 'c' looking for beginning of value

Reason:


 curl --unix-socket /var/run/docker.sock http:/localhost/v1.22/containers/json     
client version 1.22 is too old. Minimum supported API version is 1.24, 
   please upgrade your client to a newer version

Solution:

https://github.com/umputun/reproxy/blob/fe24cf99efadb79a955f0240dbe1d4bb9f73c851/app/discovery/provider/docker.go#L376

Update to const APIVersion = "v1.24"

Fix:

$curl -s --unix-socket /var/run/docker.sock http:/localhost/v1.24/containers/json | jq '.[0].Image'
"umputun/reproxy:master"