Dockerode: protocol, host and port is ignored unless I set socketPath explicitly to null

Created on 31 Oct 2019  路  6Comments  路  Source: apocas/dockerode

I followed the examples in the readme and did:

````
let Docker = require('dockerode');

let options = {
protocol:'http',
host: '127.0.0.1',
port: 2375
}
let docker = new Docker(options);
````

But it would still connect to the default unix socket. Finally I figured out that explicitly setting socketPath to null I could get it to respect the options. I.e. this works:

````
let Docker = require('dockerode');

let options = {
protocol:'http',
host: '127.0.0.1',
port: 2375,
socketPath: null
}
let docker = new Docker(options);
````

Using dockerode 3.0.2

The issue seems to be on line 72 in modem.js
var opts = Object.assign({}, defaultOpts(), options);

The defaultOpts contain a socketPath and it is not overridden by the options from dockerode and then takes precedence over the protocol, host and port

bug needs inspection

Most helpful comment

Just pushed a fix and added a test exactly for this scenario.
It's going to published in the next docker-modem version tomorrow.

All 6 comments

it is about docker-modem package. It always uses socketPath as default source.

Same here, in that case the dockerode documentation should be updated

It took me 3 hours to identify this problem, please, for the love of god, fix it please!

this problem take my 24 hours (totally). so please fix the readme.md or let me to fix that.
thank you dockerode

Just pushed a fix and added a test exactly for this scenario.
It's going to published in the next docker-modem version tomorrow.

Published in docker-modem v2.1.3

Was this page helpful?
0 / 5 - 0 ratings

Related issues

stanleygu picture stanleygu  路  4Comments

hackhat picture hackhat  路  4Comments

zigmund picture zigmund  路  3Comments

AlexanderCollins picture AlexanderCollins  路  5Comments

yamii picture yamii  路  5Comments