OK…
I have everything working nicely from the terminal.
I have created a volume container called S_ENABLED
I have created a standard container called nginxserver
I am starting nginxserver with a --volumes-from to S_ENABLED. This works perfectly.
However I want to start nginxserver from the remote API binding it to S_ENABLED.
Below I have put my commands for creating the containers on the command line, which work, and I have included my URL hits (using curl) to try and create them using the remote API, however it inside the nginxserver the S_ENABLED volume doesnt seem to be mounted. Any help would be appreciated.
Create:
Creating S_ENABLED from the command line
docker run -v /home/vagrant/docker/examples/sites-enabled/:/etc/nginx/sites-enabled --name S_ENABLED centos:7 true
Creating S_ENABLED from API:
curl -X POST -H "Content-Type: application/json" -d '{ "Cmd": "true", "Volumes": {"/etc/nginx/sites-enabled": {}}, "Image":"centos:7"}' http://127.0.0.1:4243/containers/create?name=S_ENABLED
as I understand it the
"Volumes": {"/etc/nginx/sites-enabled": {}}
is the path INSIDE the container that is going to be bound to the S_ENABLED volume container.
Start:
curl -X POST -H "Content-Type: application/json" -d '{ "Binds": ["/home/vagrant/docker/examples/sites-enabled/:/etc/nginx/sites-enabled:rw"] }' http://127.0.0.1:4243/containers/[id]/start
My understanding of the above is the Binds is the from:to:rw i.e from on the host, to in the container:[read/write permissions]
create
Creating nginxserver from the command line:
docker run -d -p 80:80 --volumes-from S_ENABLED --name nginxserver nginx:latest
create nginx container, to do a Volumes-from I do:
curl -X POST -H "Content-Type: application/json" -d '{"Image":"nginx:latest","VolumesFrom": ["S_ENABLED"] }' http://127.0.0.1:4243/containers/create?name=nginxserver
and to start it I do:
curl -X POST -H "Content-Type: application/json" -d '{"PortBindings":{ "80/tcp": [{ "HostPort": "80" }] }}' http://127.0.0.1:4243/containers/ed12e72a8c57/start
I get no errors, however when I do:
docker exec -it nginxserver bash
and navigate to /etc/nginx/sites-enabled
the contents of the host location directory (/home/vagrant/docker/examples/sites-enabled/) is not shown, so either I am setting up the volume container incorrectly, or I am connecting to the volume container from nginxserver incorrectly. The documentation on this feels a bit sparse, could anyone advise me where i am going wrong?
Thanks