Dockerode: How to start a container ?

Created on 1 Aug 2017  路  2Comments  路  Source: apocas/dockerode

I am tyring to run this command in dockerode, I am bit confused on how to run it.
docker run -d -p 1527:80 ajaycs14/hello-world

my code

docker.run('ajaycs14/hello-world', [], process.stdout, {createOptions:{}}, {start_options:["-p 8888:80", "-d"]}, function (err, data, container) {
 // ....
});

Container is not started. I am pretty sure something wrong while invoking run , but I couldn't able to figure out.
thank you

question

Most helpful comment

Since it was already correctly tackled, I'm going to close this one. :)

All 2 comments

Try with

docker.run('ajaycs14/hello-world', [], process.stdout, {PortBindings: { "80/tcp": [{ "HostPort": "8888" }] } }, function (err, data, container) {
 // ....
});

The real options are in DockerApi

Edit: If you want to run a container in detach mode:

docker.createContainer({ Image: 'ajaycs14/hello-world', Tty: false, name: 'yourContainerName', PortBindings: { "80/tcp": [{ "HostPort": "8080" }] } }, function (err,container){
  container.start();
})

There is an example here

Since it was already correctly tackled, I'm going to close this one. :)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

gaetsd picture gaetsd  路  3Comments

florentvaldelievre picture florentvaldelievre  路  4Comments

zigmund picture zigmund  路  3Comments

lgomez picture lgomez  路  3Comments

lakindu95 picture lakindu95  路  3Comments