0

I am posting with Postman through Docker API 1.41 an Exec command to a container to get md5, sha1 and sha256 of some files on same line. Works OK but it returns garbage at the beginning of the response.

Can anyone spot the problem?

POST http://localhost:2375/v1.41/containers/{containerid}/exec

{
  "AttachStdin": false,
  "AttachStdout": true,
  "AttachStderr": true,
  "DetachKeys": "ctrl-p,ctrl-q",
  "Tty": false,
  "Cmd": [
    "sh", 
    "-c",
    "find /sbin/* -type f -print0 | xargs -0 sh -c 'paste -d \" \" <(md5sum \"$@\") <(sha1sum \"$@\") <(sha256sum \"$@\") <(du -lh \"$@\")' bash | tr -s ' ' | cut -d ' ' -f 1,3,5,6"
  ]
}

Result:

{
    "Id": "5243df9ea1d665d5eef78593c8d1031e4a3c61feb20267a974119a7f70d87d24"
}

Starting command:

POST http://localhost:2375/v1.41/exec/5243df9ea1d665d5eef78593c8d1031e4a3c61feb20267a974119a7f70d87d24/start

{
  "Detach": false,
  "Tty": false
}

Result:

锟絚bf83b97caceaeb98d449946cda46dba 3f5a14046fd530c8679dd7f67c15ec6570631d51 7995d69305583789568e85eeac0abf0c3c7166c4edb53afc5910e57ff0b37650 /sbin/apk 5830d01f7821b978df770b06db3790921 2a36b6f8f3992b112450e66ac128c2ea499a103e b4a2c06db38742e8c42c3c9838b285a7d8cdac6c091ff3df5ff9a15f1e41b9c7 /sbin/ldconfig 90292714bf3b5d86c997f10f64f92a50 f9ff078ddf9d9074b4dcee9965a230ee66fc9cb3 ab0f9ffe6fb1064ed2736c8191f841daaf54700f5e7b670e56fca7d7855dece8 /sbin/mkmntdirs
Elias
  • 452
  • 5
  • 11
  • What exactly did you do to allow unencrypted access on port 2375? That's potentially a major security issue – anyone who can reach that port can very easily root the entire system. (Correspondingly consider using a Docker SDK instead of raw HTTP requests for this kind of task.) – David Maze Nov 11 '22 at 12:18
  • The binary response data has a [framing protocol](https://docs.docker.com/engine/api/v1.41/#tag/Container/operation/ContainerAttach) so it starts with an 8-byte header identifying the stream and block length, but I'd be a little surprised to see it render as Chinese characters. Do you have a hex dump of the first 16 bytes or so of the response? – David Maze Nov 11 '22 at 12:23

0 Answers0