denibertovic / docker-hs

A Haskell library for the Docker Engine API
BSD 3-Clause "New" or "Revised" License
77 stars 48 forks source link

inspectContainer fails decoding #86

Open paolino opened 2 years ago

paolino commented 2 years ago

hello I get 2 errors inspecting containers

[a.pv@ansible 18:07:21 ~] docker version
Client: Docker Engine - Community
 Version:           20.10.11
 API version:       1.41
 Go version:        go1.16.9
 Git commit:        dea9396
 Built:             Thu Nov 18 00:38:53 2021
 OS/Arch:           linux/amd64
 Context:           default
 Experimental:      true

Server: Docker Engine - Community
 Engine:
  Version:          20.10.11
  API version:      1.41 (minimum version 1.12)
  Go version:       go1.16.9
  Git commit:       847da18
  Built:            Thu Nov 18 00:37:17 2021
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.4.12
  GitCommit:        7b11cfaabd73bb80907dd23182b9347b4245eb5d
 runc:
  Version:          1.0.2
  GitCommit:        v1.0.2-0-g52b36a2
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

where should I look to fix them? any hint very appreciated

jprider63 commented 2 years ago

Hi @paolino. If you want to fix this, you probably need to modify the FromJSON instance for ContainerConfig to parse a null "Cmd" as []. For "StopSignal", I'm not sure what should be returned if the key isn't provided. Maybe SIGTERM since the API says that's the default.

Can you create a test case for the JSON response you're seeing?

paolino commented 2 years ago

Hi, I changed almost all [x] to a newtype to support 'null' encoding. It's quite an invasive change because it was detecting this all over the ContainerConfig encoding. I have 100 containers in production which slowly made me fix the [x] . But I haven't checked the API docs. Sadly I messed up the indentation and hlint things so a PR is not ready. Btw you can have a look here and if you think it's something useful I can try o port it back to the original style. In that case, I need to know which indenter should I use :-)