Skip to content

Instantly share code, notes, and snippets.

@dzlab
Last active December 1, 2015 11:26
Show Gist options
  • Save dzlab/5534469fddbd18742de9 to your computer and use it in GitHub Desktop.
Save dzlab/5534469fddbd18742de9 to your computer and use it in GitHub Desktop.
A collection of docker related commands
#Build a docker image
cd myproject
docker run --rm -v "$(pwd):/src" -v /var/run/docker.sock:/var/run/docker.sock centurylink/golang-builder
#Create Docker machine on AWS
docker-machine create --driver amazonec2 --amazonec2-access-key $AWS_ACCESS_KEY_ID --amazonec2-secret-key $AWS_SECRET_ACCESS_KEY --amazonec2-vpc-id vpc-be157ddb --amazonec2-region eu-west-1 --amazonec2-instance-type t2.medium aws01
eval $(docker-machine env aws01)
#Swarm + Compose on AWS
export CLUSTER_ID=$(docker run swarm create)
echo "Creating SWARM master"
docker-machine create --driver amazonec2 --amazonec2-access-key $AWS_ACCESS_KEY_ID --amazonec2-secret-key $AWS_SECRET_ACCESS_KEY --amazonec2-vpc-id $VPC_ID --amazonec2-region $REGION --amazonec2-instance-type t2.medium --swarm --swarm-master --swarm-discovery=token://$CLUSTER_ID swarm-master
echo "Creating SWARM nodes"
docker-machine create --driver amazonec2 --amazonec2-access-key $AWS_ACCESS_KEY_ID --amazonec2-secret-key $AWS_SECRET_ACCESS_KEY --amazonec2-vpc-id $VPC_ID --amazonec2-region $REGION --amazonec2-instance-type t2.medium --swarm --swarm-discovery=token://$CLUSTER_ID swarm-agent-00
docker-machine create --driver amazonec2 --amazonec2-access-key $AWS_ACCESS_KEY_ID --amazonec2-secret-key $AWS_SECRET_ACCESS_KEY --amazonec2-vpc-id $VPC_ID --amazonec2-region $REGION --amazonec2-instance-type t2.medium --swarm --swarm-discovery=token://$CLUSTER_ID swarm-agent-01
echo "Set the DOCKER_HOST env variable"
eval $(docker-machine env --swarm swarm-master)
cd myproject/
docker-compose up -d
docker-compose --x-networking --x-network-driver=overlay up
docker-compose ps
docker ps
echo "Scale one of the application containers"
docker-compose scale server=2
docker-compose logs
echo "SSH into a docker machine"
docker-machine -D ssh swarm-master
echo "Update kernel version to 3.16 - overlay network requirement"
$ sudo apt-get install linux-image-generic-lts-utopic
$ sudo reboot
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment