0

Is there's an option to start a container immediately on creation? Looking through the Create a Container docs I can't see one, but I suspect something like this may already exist.

1

Can you take the container id from the response of Create a Container, then pass it into Start a Container?

  • Adding detail from the links would really improve the answer. Links break and that means the answer is no longer useful. – Dave M Feb 19 '14 at 19:45
0

Ended up doing as @dannyla mentions. Using Dockerode:

async.waterfall([
  function createContainer(cb){
    log('Creating container')
    // http://docs.docker.io/en/latest/reference/api/docker_remote_api_v1.9/#create-a-container
    docker.createContainer({
      // Exposedports, Cmd, etc come from image
      Image: imageName,
      name: containerName
    }, cb);
  },

  function startContainer(container, cb){
    // http://docs.docker.io/en/latest/reference/api/docker_remote_api_v1.9/#start-a-container
    log('Starting new container')
    container.start(cb)
  }

] .... )

Added as as answer because sample code could be useful.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.