Skip to content

Instantly share code, notes, and snippets.

@tomsing1
Last active December 2, 2016 21:39
Show Gist options
  • Save tomsing1/ecc6044de60cf1e1d83cc304ffe40cd4 to your computer and use it in GitHub Desktop.
Save tomsing1/ecc6044de60cf1e1d83cc304ffe40cd4 to your computer and use it in GitHub Desktop.
Experimenting with docker machine on AWS

Docker machine

Documentation

prerequisites

  • docker
  • AWS credentials in ~/.aws/credentials

Documentation

installing docker machine on Linux / Mac OS X

curl -L https://github.com/docker/machine/releases/download/v0.8.2/docker-machine-`uname -s`-`uname -m` >/usr/local/bin/docker-machine && \
> chmod +x /usr/local/bin/docker-machine
docker-machine version

spin up an instance on AWS that runs docker

Using the usual credentials file already present on the system

INSTANCE="aws-sandbox"
docker-machine create --driver amazonec2 --amazonec2-region us-west-2 ${INSTANCE}

Lot's of arguments to explore here

list docker machines

docker-machine ls

run commands remotely on the docker instance (without logging in)

docker-machine ssh aws-sandbox whoami

get IP

docker-machine ip aws-sandbox

inspect

docker-machine inspect aws-sandbox

scp

Copying files between machines (eg scripts, output files, etc).

$ cat foo.txt
cat: foo.txt: No such file or directory
$ docker-machine ssh dev pwd
/home/docker
$ docker-machine ssh dev 'echo A file created remotely! >foo.txt'
$ docker-machine scp dev:/home/docker/foo.txt .
foo.txt                                                           100%   28     0.0KB/s   00:00
$ cat foo.txt
A file created remotely!

⚠️ In the case of transferring files from machine to machine, they go through the local host’s filesystem first (using scp’s -3 flag).

stop and remove

docker-machine stop aws-sandbox
docker-machine rm aws-sandbox

configuring the instance

documentation

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