我正在尝试通过 nodejs docker.io 库使用 Docker 的远程 API,但我找不到正确的语法来绑定(bind)目录。
我目前正在使用此代码:
docker.containers.start(cId, { Binds: ['/tmp:/tmp'] }, function(err, container)...
它启动了容器,但当我检查它时,它在 Volumes 中没有显示任何内容。
Docker 的 Remote API 文档缺少语法,所以我希望这里有人知道正确的语法。
最佳答案
我终于让它工作了。看来您还需要在创建容器时创建卷。这是正确的语法:
the first API call to /container/create should include:
{
"Volumes": { "/container/path": {} }
}
Then when starting a container (POST /containers//start), use the "Binds" option:
{
"Binds": [ "/host/path:/container/path:rw" ]
}
来源:https://groups.google.com/d/msg/docker-club/GrFQ3F1rqU4/3ZC5QoNkSAAJ
关于node.js - Docker 远程 API 和绑定(bind),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18208297/