Skip to content

Null port bindings from inspect, the first time. a second time good. why? #267

Description

@ekkis

I have the following function:

run: function(opts) {
    var self = this;
    return self.createContainer(opts).catch(function(e) {
        return self.pull(opts.Image).then(function(stream) {
            return self.followProgress(stream);
        }).then(function() {
            return self.createContainer(opts);
        });
    }).then(function(o) {
        Bluebird.promisify(o.start, {context: o})();
        return o;
    }).then(function(o) {;
        var inspect = Bluebird.promisify(
            o.inspect, {context: o}
        );
        return inspect();
    });
},

which I call like this:

bitcoind: function(opts) {
    return this.run({
        name: 'bitcoind',
        Image: 'seegno/bitcoind:latest',
        Env: ['BITCOIN_DATA=/data'],
        Binds: [process.cwd() + '/bitcoind:/data'],
        HostConfig: {
            PortBindings: {
                '8332/tcp': [{ HostPort: '8332' }]
            }
        },
        Cmd: [
            '-server',
            '-rpcuser=' + opts.user,
            '-rpcpassword=' + opts.pass,
            '-printtoconsole'
        ]
    });
},

and everything works perfectly, almost. if I start my bitcoind server like this:

docker.bitcoind(config.bitcoind).then(function(info) {
    var p = info.NetworkSettings.Ports;
    console.log(p);
}); 

the console shows "null". the ports didn't get set. the command line shows me proper values. running

$ docker inspect bitcoind

I see:

        "Ports": {
            "18332/tcp": null,
            "18333/tcp": null,
            "18444/tcp": null,
            "8332/tcp": [
                {
                    "HostIp": "0.0.0.0",
                    "HostPort": "8332"
                }
            ],
            "8333/tcp": null
        },

which is what I expected. so out of curiosity I then ran:

docker.inspect('693f32482b46').then(function(info) {
    console.log(info);
});

and that contains the port information! so I'm puzzled as to why the inspection I ran at the end of the run() would return everything but the port mappings. had I failed to wait correctly for the process to start, inspection would have returned an empty value.

thoughts as to what might be going on here or what I should do differently?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions