amazon.rst 5.8 KB

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