- Remove the overrides config.vm.box and config.vm.box_url and use the same values for all providers. - Use the same private key path for all providers. It is still possible to set a different private key path through the environment variable SSH_PRIVKEY_PATH if desired (your AWS key may be different from your Virtualbox key). - Allow the environment variable AWS_INSTANCE_TYPE to specify the instance type of instead of hard coding the AWS instance type as 't1.micro'. 't1.micro' is still the default if unspecified. - Use the same environment variables for keys as the Amazon provided EC2 API tools. This allows people who already have the EC2 tools set up correctly to use 'vagrant up' with less environment configuration than before. - Rewrite the provisioning code. The goal is to be idempotent and to correctly install docker for all providers instead of just virtualbox. It will conditionally install the virtualbox guest additions if virtualbox is the provider. - Update the AWS install documentation to reflect the changes. Upstream-commit: ccbb5d34927dc1905984bead3ebb576c0ea20960 Component: engine
5.2 KiB
- title
- Installation on Amazon EC2
- description
- Docker installation on Amazon EC2
- keywords
- amazon ec2, virtualization, cloud, docker, documentation, installation
Amazon EC2
There are several ways to install Docker on AWS EC2:
amazonquickstartoramazonstandardoramazonvagrant
You'll need an AWS account first, of course.
Amazon QuickStart
- Choose an image:
- Open http://cloud-images.ubuntu.com/locator/ec2/
- Enter
amd64 precisein the search field (it will search as you type) - Pick an image by clicking on the image name. An EBS-enabled image will let you use a t1.micro instance. Clicking on the image name will take you to your AWS Console.
- Tell CloudInit to install Docker:
- Enter
#include https://get.docker.iointo the instance User Data. CloudInit is part of the Ubuntu image you chose and it bootstraps from this User Data.
- Enter
- After a few more standard choices where defaults are probably ok, your AWS Ubuntu instance with Docker should be running!
If this is your first AWS instance, you may need to set up your Security Group to allow SSH. By default all incoming ports to your new instance will be blocked by the AWS Security Group, so you might just get timeouts when you try to connect.
Installing with get.docker.io (as above) will create a
service named lxc-docker. It will also set up a docker group <dockergroup> and you may want to
add the ubuntu user to it so that you don't have to use
sudo for every Docker command.
Once you've got Docker installed, you're ready to try it out -- head
on over to the ../use/basics or ../examples/index section.
Standard Ubuntu Installation
If you want a more hands-on installation, then you can follow the
ubuntu_linux
instructions installing Docker on any EC2 instance running Ubuntu. Just
follow Step 1 from amazonquickstart to pick an image (or use one of your
own) and skip the step with the User Data. Then continue with
the ubuntu_linux
instructions.
Use Vagrant
And finally, if you prefer to work through Vagrant, you can install Docker that way too. Vagrant 1.1 or higher is required.
Install vagrant from http://www.vagrantup.com/ (or use your package manager)
Install the vagrant aws plugin
vagrant plugin install vagrant-awsGet the docker sources, this will give you the latest Vagrantfile.
git clone https://github.com/dotcloud/docker.gitCheck your AWS environment.
Create a keypair specifically for EC2, give it a name and save it to your disk. I usually store these in my ~/.ssh/ folder.
Check that your default security group has an inbound rule to accept SSH (port 22) connections.
Inform Vagrant of your settings
Vagrant will read your access credentials from your environment, so we need to set them there first. Make sure you have everything on amazon aws setup so you can (manually) deploy a new image to EC2.
Note that where possible these variables are the same as those honored by the ec2 api tools. :
export AWS_ACCESS_KEY=xxx export AWS_SECRET_KEY=xxx export AWS_KEYPAIR_NAME=xxx export SSH_PRIVKEY_PATH=xxx export BOX_NAME=xxx export AWS_REGION=xxx export AWS_AMI=xxx export AWS_INSTANCE_TYPE=xxxThe required environment variables are:
AWS_ACCESS_KEY- The API key used to make requests to AWSAWS_SECRET_KEY- The secret key to make AWS API requestsAWS_KEYPAIR_NAME- The name of the keypair used for this EC2 instanceSSH_PRIVKEY_PATH- The path to the private key for the named keypair, for example~/.ssh/docker.pem
There are a number of optional environment variables:
BOX_NAME- The name of the vagrant box to use. Defaults toubuntu.AWS_REGION- The aws region to spawn the vm in. Defaults tous-east-1.AWS_AMI- The aws AMI to start with as a base. This must be be an ubuntu 12.04 precise image. You must change this value ifAWS_REGIONis set to a value other thanus-east-1. This is because AMIs are region specific. Defaults toami-69f5a900.AWS_INSTANCE_TYPE- The aws instance type. Defaults tot1.micro.
You can check if they are set correctly by doing something like
echo $AWS_ACCESS_KEYDo the magic!
vagrant up --provider=awsIf it stalls indefinitely on
[default] Waiting for SSH to become available..., Double check your default security zone on AWS includes rights to SSH (port 22) to your container.If you have an advanced AWS setup, you might want to have a look at https://github.com/mitchellh/vagrant-aws
Connect to your machine
vagrant sshYour first command
Now you are in the VM, run docker
sudo docker
Continue with the hello_world example.