Skip to content

Instantly share code, notes, and snippets.

@joshuacalloway
Created August 8, 2014 21:06
Show Gist options
  • Save joshuacalloway/5c02daaeac092d7d1a0d to your computer and use it in GitHub Desktop.
Save joshuacalloway/5c02daaeac092d7d1a0d to your computer and use it in GitHub Desktop.
Using --volumes-from does not work when using the -H flag. Trying to spin off docker containers on host from within a docker container.
from ubuntu:14.04
run apt-get update
run apt-get install -y docker.io
run ln -sf /usr/bin/docker.io /usr/local/bin/docker
add run.sh /usr/local/bin/run
entrypoint ["/usr/local/bin/run"]
from busybox
VOLUME /data
ADD hello.txt /data/hello.txt
CMD true
#!/bin/bash
echo "in run.sh entry"
ACTION=${1:-}
TAG=${TAG:-latest}
env=test
if [ ! -e "/docker.sock" ] ; then
echo "You must map your Docker socket to /docker.sock (i.e. -v /var/run/docker.sock:/docker.sock)"
exit 2
fi
@joshuacalloway
Copy link
Author

If you run these commands on host. it works fine.

docker run --name data joshuacalloway/data
docker run --volumes-from data ubuntu cat /data/hello.txt

However if you do this in a container. It is broken.

docker run -it --entrypoint=/bin/bash -v /var/run/docker.sock:/var/run/docker.sock joshuacalloway/deploy -s
xab> docker ps -----> this shows docker processes on the host
xab> docker rm data ---> this removes docker container data that was created above
xab> docker run --name data joshuacalloway/data
xab> docker run --volumes-from data ubuntu cat /data/hello.txt

Here is the gist for the simple example I created.

@joshuacalloway
Copy link
Author

Intro:
So I took a look at shipyard docker. And one thing caught my eye. You can spin off docker containers on the host machine within a docker container.
This is done by using the -H flag.
This all works fine. And this is how shipyard can spin off 5 containers on your machine ( redis, router, database, load balancer, shipyard )

So I decided to try this to deploy our apps as this would make deployment tons easier ( versus knowing systemd, init.d, or the various start scripts of various linux boxes ).
I was able to get about 70% there, but the thing that broke was --volumes-from tag.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment