有创build时立即启动容器的选项吗? 通过创build容器文档查看我看不到一个,但我怀疑这样的事情可能已经存在。
你可以从Create a Container的响应中获取容器id,然后将它传递给Start a Container ?
结束了@丹尼拉提到。 使用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) } ] .... )
添加为答案,因为示例代码可能是有用的。