AgustinCB / docker-api

Docker Remote API driver for node.js. It uses the same modem than dockerode, but the interface is promisified and with a fancier syntax.
GNU General Public License v3.0
303 stars 51 forks source link

how to mount "-v //var/run/docker.sock://var/run/docker.sock" in docker-api #58

Closed chrisEAH closed 3 years ago

chrisEAH commented 5 years ago

hey, i need some help.

how to translate cli-command "docker run --name watchtower -v //var/run/docker.sock://var/run/docker.sock v2tec/watchtower" to the docker api.

i'm trying like this. but it is not working

dockerStart.container .create({ name: "watchtower", Image: "v2tec/watchtower", Volumes:{ "/var/run/docker.sock":{'/var/run/docker.sock'}} }) .then(container=>container.start()) .catch(error => console.log(error));

Thank you for your help :)

stevenguh commented 5 years ago

I think what you need is the Binds option in the HostConfig. See ContainerCreate API in the docker engine for details.

Maybe something like that is what you need

dockerStart.container.create({
    name: "watchtower",
    Image: "v2tec/watchtower",
    HostConfig: {
        Binds: ["/var/run/docker.sock:/var/run/docker.sock"]
    }
}).then(container=>container.start()).catch(error => console.log(error));
chrisEAH commented 5 years ago

thank you. that was the solution

:)