apocas / dockerode

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

Unable to start container #278

Closed oliversalzburg closed 8 years ago

oliversalzburg commented 8 years ago

When attempting to start the container, I get the error

starting container with HostConfig was deprecated since v1.10 and removed in v1.12

Which refers to https://docs.docker.com/engine/deprecated/#/hostconfig-at-api-container-start. dockerode seems to use this endpoint at https://github.com/apocas/dockerode/blob/master/lib/container.js#L190

oliversalzburg commented 8 years ago

I'm getting the feeling that the cause of the issue is actually in https://github.com/Strider-CD/strider-docker-runner :P

apocas commented 8 years ago

Indeed :) https://github.com/apocas/dockerode/issues/276

freefood89 commented 8 years ago

for those who are stuck.. you need both PortBindings and ExposedPorts

docker.createContainer({
    Image: 'test',
    Cmd: [],
    Tty: false,
    Env: [
        "foo=bar"
    ],
    ExposedPorts: {
        '5000/tcp': {}
    },
    HostConfig: {
        PortBindings: {
            '5000/tcp': [{HostPort: "5000"}]
        }
    }
}, (err, container) => {
    do stuff
});

It took a while to figure this out..

RobertLowe commented 6 years ago

@freefood89 you are my hero 👍