amazon.rst 5.6 KB

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