Skip to content

Instantly share code, notes, and snippets.

@ehazlett
ehazlett / gist:88d1a3025ed92453c073
Created November 25, 2014 14:21
EC2 Docker Host Launch Data
#!/bin/bash
apt-get update
apt-get install -y curl
curl get.docker.io | sh -
# uncomment if you want remote api access
#echo 'DOCKER_OPTS="-H tcp://0.0.0.0:2375 -H unix:///var/run/docker.sock"' >> /etc/default/docker
service docker restart
dev@machine ~/d/g/s/g/d/machine> ./machine ls
NAME ACTIVE DRIVER STATE URL
docker-machine * amazonec2 Running tcp://54.172.130.76:2376
dev@machine ~/d/g/s/g/d/machine> ./machine url
NAME:
url - Get the URL of a machine
USAGE:
command url [arguments...]
ehazlett@ejh-mbp ~/Sync> ./machine-darwin create -d virtualbox machine-test
INFO[0000] Downloading boot2docker...
INFO[0005] Creating SSH key...
INFO[0005] Creating VirtualBox VM...
INFO[0010] Starting VirtualBox VM...
INFO[0011] Waiting for VM to start...
INFO[0046] "machine-test" has been created and is now the active machine. To point Docker at this machine, run: export DOCKER_HOST=$(machine url) DOCKER_AUTH=identity
ehazlett@ejh-mbp ~/Sync> ./machine-darwin ls
NAME ACTIVE DRIVER STATE URL
machine-test * virtualbox Running tcp://192.168.99.100:2376
[ehazlett@ejh-mbpr machine]$ ./machine ls
INFO[0000] Connecting to vCloud Air to fetch vApp Status...
NAME ACTIVE DRIVER STATE URL
test-vcloud * vmwarevcloudair Running tcp://23.92.243.104:2376
[ehazlett@ejh-mbpr machine]$ docker $(machine config test-vcloud) ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
[ehazlett@ejh-mbpr machine]$ docker $(machine config test-vcloud) run -ti busybox echo hello machine
Unable to find image 'busybox:latest' locally
ehazlett machine> ./script/build
Sending build context to Docker daemon 6.463 MB
Sending build context to Docker daemon
Step 0 : FROM golang:1.3-cross
---> d162748e3e05
Step 1 : RUN apt-get update && apt-get install -y --no-install-recommends openssh-client
---> Using cache
---> 50f1be697ea4
Step 2 : RUN go get github.com/mitchellh/gox
---> Using cache
ehazlett machine> ./script/build -os="linux"
Sending build context to Docker daemon 6.463 MB
Sending build context to Docker daemon
Step 0 : FROM golang:1.3-cross
---> d162748e3e05
Step 1 : RUN apt-get update && apt-get install -y --no-install-recommends openssh-client
---> Using cache
---> 50f1be697ea4
Step 2 : RUN go get github.com/mitchellh/gox
---> Using cache
ehazlett machine> ./script/build -os="linux" -arch="amd64"
Sending build context to Docker daemon 6.463 MB
Sending build context to Docker daemon
Step 0 : FROM golang:1.3-cross
---> d162748e3e05
Step 1 : RUN apt-get update && apt-get install -y --no-install-recommends openssh-client
---> Using cache
---> 50f1be697ea4
Step 2 : RUN go get github.com/mitchellh/gox
---> Using cache
@ehazlett
ehazlett / changelog.sh
Created January 29, 2015 17:46
Generate Changelog
#!/bin/bash
git log --no-merges --pretty="%cn|%s" $1..$2 | sort | awk -F '|' '$1==x{ printf "\n %s", $2; next }{ x=$1; printf "\n\n%s\n %s", $1, $2;} END { printf "\n"}' | tail -n +3
ehazlett .dotfiles> docker run --rm -v /var/run/docker.sock:/var/run/docker.sock shipyard/deploy start
Pulling image: shipyard/rethinkdb
Starting Rethinkdb Data
Starting Rethinkdb
Starting Shipyard
Pulling image: shipyard/shipyard:latest
Shipyard Stack started successfully
Username: admin Password: shipyard
ehazlett .dotfiles> docker ps | grep shipyard
1b41cdf642a1 shipyard/shipyard:2.0.8 "/app/controller" 8 seconds ago Up 8 seconds 0.0.0.0:8080->8080/tcp shipyard

To create a Swarm cluster using VirtualBox using Machine:

  • TOKEN=$(docker-machine create-swarm-token)
  • docker-machine create -d virtualbox --swarm --swarm-discovery token://$TOKEN --swarm-master swarm-master
  • docker-machine create -d virtualbox --swarm --swarm-discovery token://$TOKEN swarm-node-00

Then configure your Docker client:

  • $(docker-machine env --swarm swarm-master)
  • docker ps