Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Docker Remote API & Binds

Tags:

node.js

docker

I'm trying to use Docker's Remote API via nodejs docker.io library but I just can't find the right syntax how to bind directories.

I'm currently using this code:

docker.containers.start(cId, { Binds: ['/tmp:/tmp'] }, function(err, container)...

It starts container but when I inspect it doesn't show anything in Volumes.

Docker's Remote API documentation is lacking when it comes to syntax so I'm hoping somebody here knows the correct syntax.

like image 486
jimmy Avatar asked Dec 03 '22 22:12

jimmy


1 Answers

I finally got it working. It seems you also need to create Volumes when you create the container. Here's the proper syntax:

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" ]
}

source: https://groups.google.com/d/msg/docker-club/GrFQ3F1rqU4/3ZC5QoNkSAAJ

like image 84
jimmy Avatar answered Dec 27 '22 05:12

jimmy