Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

containerAttach is sending parameter as POST JSON payload while it shouldn't #742

Open
benoitf opened this issue Sep 12, 2023 · 2 comments

Comments

@benoitf
Copy link

benoitf commented Sep 12, 2023

Hello,

When trying to use dockerode with podman engine, I noticed that I received echo of queries when using attach on a container.

Reading https://docs.docker.com/engine/api/v1.43/#tag/Container/operation/ContainerAttach we can see that parameters like stdin, stdout, stream, etc are all query parameters like /v1.43/containers/{id}/attach?stdin=...&stdout=... but dockerode also send the options as a JSON payload {"stream": true, "stdin":true, "stdout":true}

the API don't mention a payload so for attach API, dockerode shouldn't send any body on the REST API call.

@absorbb
Copy link

absorbb commented May 17, 2024

That can be a real problem when trying to work with images that expect some meaningful input in stdin.

We've implemented workaround using proxy object:

container.modem = new Proxy(container.modem, {
      get(target, prop) {
        const origMethod = target[prop];
        if (prop === "dial") {
            return function (...args) {
              if (args[0].path.endsWith("/attach?")) {
                // make request body empty
                args[0].file = new Buffer("")
              }
              return origMethod.apply(target, args)
            }
        } else {
          return origMethod
        }
      }
    })

@STRRL
Copy link

STRRL commented Dec 27, 2024

related issue:

#777

#769

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants