2013-08-03 17:31:20 +07:00
|
|
|
:title: Installation on Amazon EC2
|
2013-09-10 18:54:13 -07:00
|
|
|
:description: Docker installation on Amazon EC2
|
2013-05-21 11:47:16 -06:00
|
|
|
:keywords: amazon ec2, virtualization, cloud, docker, documentation, installation
|
|
|
|
|
2013-09-10 18:54:13 -07:00
|
|
|
Amazon EC2
|
|
|
|
==========
|
2013-03-25 19:52:52 -07:00
|
|
|
|
2013-09-10 18:54:13 -07:00
|
|
|
.. include:: install_header.inc
|
2013-08-02 15:10:57 -07:00
|
|
|
|
2013-09-10 18:54:13 -07:00
|
|
|
There are several ways to install Docker on AWS EC2:
|
2013-03-25 19:52:52 -07:00
|
|
|
|
2013-09-10 18:54:13 -07:00
|
|
|
* :ref:`amazonquickstart` or
|
|
|
|
* :ref:`amazonstandard` or
|
|
|
|
* :ref:`amazonvagrant`
|
|
|
|
|
|
|
|
**You'll need an** `AWS account <http://aws.amazon.com/>`_ **first, of course.**
|
|
|
|
|
|
|
|
.. _amazonquickstart:
|
|
|
|
|
|
|
|
Amazon QuickStart
|
|
|
|
-----------------
|
|
|
|
|
|
|
|
1. **Choose an image:**
|
|
|
|
|
2013-11-23 15:36:09 -05:00
|
|
|
* Launch the `Create Instance Wizard
|
|
|
|
<https://console.aws.amazon.com/ec2/v2/home?#LaunchInstanceWizard:>`_ menu
|
|
|
|
on your AWS Console.
|
2013-11-23 15:30:29 -05:00
|
|
|
|
2014-01-06 09:53:58 -08:00
|
|
|
* Click the ``Select`` button for a 64Bit Ubuntu image. For example: Ubuntu Server 12.04.3 LTS
|
2013-11-23 15:30:29 -05:00
|
|
|
|
2014-01-06 09:53:58 -08:00
|
|
|
* For testing you can use the default (possibly free)
|
2013-11-23 15:36:09 -05:00
|
|
|
``t1.micro`` instance (more info on `pricing
|
2014-01-06 09:53:58 -08:00
|
|
|
<http://aws.amazon.com/en/ec2/pricing/>`_).
|
2013-11-23 15:30:29 -05:00
|
|
|
|
2014-01-06 09:53:58 -08:00
|
|
|
* Click the ``Next: Configure Instance Details`` button at the bottom right.
|
2013-09-10 18:54:13 -07:00
|
|
|
|
|
|
|
2. **Tell CloudInit to install Docker:**
|
|
|
|
|
2013-11-23 15:36:09 -05:00
|
|
|
* When you're on the "Configure Instance Details" step, expand the "Advanced
|
|
|
|
Details" section.
|
|
|
|
|
|
|
|
* Under "User data", select "As text".
|
|
|
|
|
2013-11-23 15:30:29 -05:00
|
|
|
* Enter ``#include https://get.docker.io`` into the instance *User Data*.
|
|
|
|
`CloudInit <https://help.ubuntu.com/community/CloudInit>`_ is part of the
|
2013-11-23 15:36:09 -05:00
|
|
|
Ubuntu image you chose; it will bootstrap Docker by running the shell
|
|
|
|
script located at this URL.
|
2013-09-10 18:54:13 -07:00
|
|
|
|
2013-11-23 15:30:29 -05:00
|
|
|
3. After a few more standard choices where defaults are probably ok, your AWS
|
|
|
|
Ubuntu instance with Docker should be running!
|
2013-09-10 18:54:13 -07:00
|
|
|
|
|
|
|
**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.
|
|
|
|
|
2013-09-27 22:50:24 -06:00
|
|
|
Installing with ``get.docker.io`` (as above) will create a service named
|
|
|
|
``lxc-docker``. It will also set up a :ref:`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.
|
2013-09-10 18:54:13 -07:00
|
|
|
|
|
|
|
Once you've got Docker installed, you're ready to try it out -- head
|
|
|
|
on over to the :doc:`../use/basics` or :doc:`../examples/index` section.
|
|
|
|
|
|
|
|
.. _amazonstandard:
|
|
|
|
|
|
|
|
Standard Ubuntu Installation
|
|
|
|
----------------------------
|
|
|
|
|
|
|
|
If you want a more hands-on installation, then you can follow the
|
|
|
|
:ref:`ubuntu_linux` instructions installing Docker on any EC2 instance
|
|
|
|
running Ubuntu. Just follow Step 1 from :ref:`amazonquickstart` to
|
|
|
|
pick an image (or use one of your own) and skip the step with the
|
|
|
|
*User Data*. Then continue with the :ref:`ubuntu_linux` instructions.
|
|
|
|
|
|
|
|
.. _amazonvagrant:
|
|
|
|
|
|
|
|
Use Vagrant
|
|
|
|
-----------
|
2013-08-28 17:26:10 -07:00
|
|
|
|
|
|
|
.. include:: install_unofficial.inc
|
|
|
|
|
2013-09-10 18:54:13 -07:00
|
|
|
And finally, if you prefer to work through Vagrant, you can install
|
|
|
|
Docker that way too. Vagrant 1.1 or higher is required.
|
2013-03-26 16:29:21 -07:00
|
|
|
|
|
|
|
1. Install vagrant from http://www.vagrantup.com/ (or use your package manager)
|
|
|
|
2. Install the vagrant aws plugin
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
|
|
vagrant plugin install vagrant-aws
|
|
|
|
|
|
|
|
|
2013-04-22 18:38:42 -07:00
|
|
|
3. Get the docker sources, this will give you the latest Vagrantfile.
|
2013-03-26 16:29:21 -07:00
|
|
|
|
|
|
|
::
|
|
|
|
|
|
|
|
git clone https://github.com/dotcloud/docker.git
|
|
|
|
|
|
|
|
|
|
|
|
4. Check your AWS environment.
|
|
|
|
|
2013-09-10 18:54:13 -07:00
|
|
|
Create a keypair specifically for EC2, give it a name and save it
|
|
|
|
to your disk. *I usually store these in my ~/.ssh/ folder*.
|
2013-03-26 16:29:21 -07:00
|
|
|
|
2013-09-10 18:54:13 -07:00
|
|
|
Check that your default security group has an inbound rule to
|
|
|
|
accept SSH (port 22) connections.
|
2013-03-26 16:29:21 -07:00
|
|
|
|
|
|
|
5. Inform Vagrant of your settings
|
|
|
|
|
2013-09-10 18:54:13 -07:00
|
|
|
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.
|
2013-03-26 16:29:21 -07:00
|
|
|
|
2013-11-06 19:16:56 -08:00
|
|
|
Note that where possible these variables are the same as those honored by
|
|
|
|
the ec2 api tools.
|
2013-03-26 16:29:21 -07:00
|
|
|
::
|
2013-03-25 19:52:52 -07:00
|
|
|
|
2013-11-06 19:16:56 -08:00
|
|
|
export AWS_ACCESS_KEY=xxx
|
|
|
|
export AWS_SECRET_KEY=xxx
|
2013-03-26 16:29:21 -07:00
|
|
|
export AWS_KEYPAIR_NAME=xxx
|
2013-11-06 19:16:56 -08:00
|
|
|
export SSH_PRIVKEY_PATH=xxx
|
2013-03-25 19:52:52 -07:00
|
|
|
|
2013-11-06 19:16:56 -08:00
|
|
|
export BOX_NAME=xxx
|
|
|
|
export AWS_REGION=xxx
|
|
|
|
export AWS_AMI=xxx
|
|
|
|
export AWS_INSTANCE_TYPE=xxx
|
2013-03-25 19:52:52 -07:00
|
|
|
|
2013-11-06 19:16:56 -08:00
|
|
|
The required environment variables are:
|
|
|
|
|
|
|
|
* ``AWS_ACCESS_KEY`` - The API key used to make requests to AWS
|
|
|
|
* ``AWS_SECRET_KEY`` - The secret key to make AWS API requests
|
2013-03-26 16:29:21 -07:00
|
|
|
* ``AWS_KEYPAIR_NAME`` - The name of the keypair used for this EC2 instance
|
2013-11-06 19:16:56 -08:00
|
|
|
* ``SSH_PRIVKEY_PATH`` - The path to the private key for the named
|
2013-09-10 18:54:13 -07:00
|
|
|
keypair, for example ``~/.ssh/docker.pem``
|
2013-03-25 19:52:52 -07:00
|
|
|
|
2013-11-06 19:16:56 -08:00
|
|
|
There are a number of optional environment variables:
|
|
|
|
|
|
|
|
* ``BOX_NAME`` - The name of the vagrant box to use. Defaults to
|
|
|
|
``ubuntu``.
|
|
|
|
* ``AWS_REGION`` - The aws region to spawn the vm in. Defaults to
|
|
|
|
``us-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 if
|
|
|
|
``AWS_REGION`` is set to a value other than ``us-east-1``.
|
|
|
|
This is because AMIs are region specific. Defaults to ``ami-69f5a900``.
|
|
|
|
* ``AWS_INSTANCE_TYPE`` - The aws instance type. Defaults to ``t1.micro``.
|
|
|
|
|
2013-03-26 16:29:21 -07:00
|
|
|
You can check if they are set correctly by doing something like
|
2013-03-25 19:52:52 -07:00
|
|
|
|
2013-03-26 16:29:21 -07:00
|
|
|
::
|
2013-03-25 19:52:52 -07:00
|
|
|
|
2013-11-06 19:16:56 -08:00
|
|
|
echo $AWS_ACCESS_KEY
|
2013-03-25 19:52:52 -07:00
|
|
|
|
2013-03-26 16:29:21 -07:00
|
|
|
6. Do the magic!
|
2013-03-25 19:52:52 -07:00
|
|
|
|
2013-03-26 16:29:21 -07:00
|
|
|
::
|
2013-03-25 19:52:52 -07:00
|
|
|
|
2013-03-26 16:29:21 -07:00
|
|
|
vagrant up --provider=aws
|
2013-03-25 19:52:52 -07:00
|
|
|
|
|
|
|
|
2013-09-10 18:54:13 -07:00
|
|
|
If 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.
|
2013-03-25 19:52:52 -07:00
|
|
|
|
2013-09-10 18:54:13 -07:00
|
|
|
If you have an advanced AWS setup, you might want to have a look at
|
2013-11-23 15:36:09 -05:00
|
|
|
`vagrant-aws <https://github.com/mitchellh/vagrant-aws>`_.
|
2013-03-25 19:52:52 -07:00
|
|
|
|
2013-03-26 16:29:21 -07:00
|
|
|
7. Connect to your machine
|
2013-03-25 19:52:52 -07:00
|
|
|
|
2013-03-26 16:29:21 -07:00
|
|
|
.. code-block:: bash
|
2013-03-25 19:52:52 -07:00
|
|
|
|
2013-03-26 16:29:21 -07:00
|
|
|
vagrant ssh
|
2013-03-25 19:52:52 -07:00
|
|
|
|
2013-03-26 16:29:21 -07:00
|
|
|
8. Your first command
|
2013-03-25 19:52:52 -07:00
|
|
|
|
2013-03-26 16:29:21 -07:00
|
|
|
Now you are in the VM, run docker
|
2013-03-25 19:52:52 -07:00
|
|
|
|
2013-03-26 16:29:21 -07:00
|
|
|
.. code-block:: bash
|
2013-03-25 19:52:52 -07:00
|
|
|
|
2013-08-13 18:05:35 -07:00
|
|
|
sudo docker
|
2013-03-25 19:52:52 -07:00
|
|
|
|
|
|
|
|
2013-08-02 15:10:57 -07:00
|
|
|
Continue with the :ref:`hello_world` example.
|