apocas / dockerode

Docker + Node = Dockerode (Node.js module for Docker's Remote API)
Apache License 2.0
4.38k stars 465 forks source link

Custom http request options #698

Open hegerdes opened 2 years ago

hegerdes commented 2 years ago

Thanks for creating and maintaining this lib.

I have a feature request:

Imagine your DockerSocket is not directly accessible because it is behind a reverse proxy. With the current sate you could only access the Docker API via:

new Docker({host: 'https://my-domain.example', port: 9000 })

but not: new Docker({host: 'https://my-domain.example/internal/api', port: 9000 })

Also if the proxy has a extra layer of Authorization they can not be passed because the DockerOptions argument only allows for these parameters and not the additional ones specified in the NodeJS HTTP Request Docs. So it is not possible to set an extra Header containing a Authorization: Bearer like a JWT

    interface DockerOptions {
        socketPath?: string | undefined;
        host?: string | undefined;
        port?: number | string | undefined;
        username?: string | undefined;
        ca?: string | string[] | Buffer | Buffer[] | undefined;
        cert?: string | string[] | Buffer | Buffer[] | undefined;
        key?: string | string[] | Buffer | Buffer[] | KeyObject[] | undefined;
        protocol?: 'https' | 'http' | 'ssh' | undefined;
        timeout?: number | undefined;
        version?: string | undefined;
        sshAuthAgent?: string | undefined;
        Promise?: typeof Promise | undefined;
    }

It would be really awesome to allow additional http options for each request. This also would allow to use the lib via the PortainerAPI

Please let me know if this would be considered a valid new feature

stale[bot] commented 1 week ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Open a new issue if needed.