amazon.rst 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. :title: Installation on Amazon EC2
  2. :description: Docker installation on Amazon EC2
  3. :keywords: amazon ec2, virtualization, cloud, docker, documentation, installation
  4. Amazon EC2
  5. ==========
  6. .. include:: install_header.inc
  7. There are several ways to install Docker on AWS EC2:
  8. * :ref:`amazonquickstart` or
  9. * :ref:`amazonstandard` or
  10. * :ref:`amazonvagrant`
  11. **You'll need an** `AWS account <http://aws.amazon.com/>`_ **first, of course.**
  12. .. _amazonquickstart:
  13. Amazon QuickStart
  14. -----------------
  15. 1. **Choose an image:**
  16. * Launch the `Create Instance Wizard` <https://console.aws.amazon.com/ec2/v2/home?#LaunchInstanceWizard:> menu on your AWS Console
  17. * Select "Community AMIs" option and serch for ``amd64 precise`` (click enter to search)
  18. * If you choose a EBS enabled AMI you will be able to launch a `t1.micro` instance (more info on `pricing` <http://aws.amazon.com/en/ec2/pricing/> )
  19. * When you click select you'll be taken to the instance setup, and you're one click away from having your Ubuntu VM up and running.
  20. 2. **Tell CloudInit to install Docker:**
  21. * Enter ``#include https://get.docker.io`` into the instance *User
  22. Data*. `CloudInit <https://help.ubuntu.com/community/CloudInit>`_
  23. is part of the Ubuntu image you chose and it bootstraps from this
  24. *User Data*.
  25. 3. After a few more standard choices where defaults are probably ok, your
  26. AWS Ubuntu instance with Docker should be running!
  27. **If this is your first AWS instance, you may need to set up your
  28. Security Group to allow SSH.** By default all incoming ports to your
  29. new instance will be blocked by the AWS Security Group, so you might
  30. just get timeouts when you try to connect.
  31. Installing with ``get.docker.io`` (as above) will create a service named
  32. ``lxc-docker``. It will also set up a :ref:`docker group <dockergroup>` and you
  33. may want to add the *ubuntu* user to it so that you don't have to use ``sudo``
  34. for every Docker command.
  35. Once you've got Docker installed, you're ready to try it out -- head
  36. on over to the :doc:`../use/basics` or :doc:`../examples/index` section.
  37. .. _amazonstandard:
  38. Standard Ubuntu Installation
  39. ----------------------------
  40. If you want a more hands-on installation, then you can follow the
  41. :ref:`ubuntu_linux` instructions installing Docker on any EC2 instance
  42. running Ubuntu. Just follow Step 1 from :ref:`amazonquickstart` to
  43. pick an image (or use one of your own) and skip the step with the
  44. *User Data*. Then continue with the :ref:`ubuntu_linux` instructions.
  45. .. _amazonvagrant:
  46. Use Vagrant
  47. -----------
  48. .. include:: install_unofficial.inc
  49. And finally, if you prefer to work through Vagrant, you can install
  50. Docker that way too. Vagrant 1.1 or higher is required.
  51. 1. Install vagrant from http://www.vagrantup.com/ (or use your package manager)
  52. 2. Install the vagrant aws plugin
  53. ::
  54. vagrant plugin install vagrant-aws
  55. 3. Get the docker sources, this will give you the latest Vagrantfile.
  56. ::
  57. git clone https://github.com/dotcloud/docker.git
  58. 4. Check your AWS environment.
  59. Create a keypair specifically for EC2, give it a name and save it
  60. to your disk. *I usually store these in my ~/.ssh/ folder*.
  61. Check that your default security group has an inbound rule to
  62. accept SSH (port 22) connections.
  63. 5. Inform Vagrant of your settings
  64. Vagrant will read your access credentials from your environment, so
  65. we need to set them there first. Make sure you have everything on
  66. amazon aws setup so you can (manually) deploy a new image to EC2.
  67. Note that where possible these variables are the same as those honored by
  68. the ec2 api tools.
  69. ::
  70. export AWS_ACCESS_KEY=xxx
  71. export AWS_SECRET_KEY=xxx
  72. export AWS_KEYPAIR_NAME=xxx
  73. export SSH_PRIVKEY_PATH=xxx
  74. export BOX_NAME=xxx
  75. export AWS_REGION=xxx
  76. export AWS_AMI=xxx
  77. export AWS_INSTANCE_TYPE=xxx
  78. The required environment variables are:
  79. * ``AWS_ACCESS_KEY`` - The API key used to make requests to AWS
  80. * ``AWS_SECRET_KEY`` - The secret key to make AWS API requests
  81. * ``AWS_KEYPAIR_NAME`` - The name of the keypair used for this EC2 instance
  82. * ``SSH_PRIVKEY_PATH`` - The path to the private key for the named
  83. keypair, for example ``~/.ssh/docker.pem``
  84. There are a number of optional environment variables:
  85. * ``BOX_NAME`` - The name of the vagrant box to use. Defaults to
  86. ``ubuntu``.
  87. * ``AWS_REGION`` - The aws region to spawn the vm in. Defaults to
  88. ``us-east-1``.
  89. * ``AWS_AMI`` - The aws AMI to start with as a base. This must be
  90. be an ubuntu 12.04 precise image. You must change this value if
  91. ``AWS_REGION`` is set to a value other than ``us-east-1``.
  92. This is because AMIs are region specific. Defaults to ``ami-69f5a900``.
  93. * ``AWS_INSTANCE_TYPE`` - The aws instance type. Defaults to ``t1.micro``.
  94. You can check if they are set correctly by doing something like
  95. ::
  96. echo $AWS_ACCESS_KEY
  97. 6. Do the magic!
  98. ::
  99. vagrant up --provider=aws
  100. If it stalls indefinitely on ``[default] Waiting for SSH to become
  101. available...``, Double check your default security zone on AWS
  102. includes rights to SSH (port 22) to your container.
  103. If you have an advanced AWS setup, you might want to have a look at
  104. https://github.com/mitchellh/vagrant-aws
  105. 7. Connect to your machine
  106. .. code-block:: bash
  107. vagrant ssh
  108. 8. Your first command
  109. Now you are in the VM, run docker
  110. .. code-block:: bash
  111. sudo docker
  112. Continue with the :ref:`hello_world` example.