amazon.rst 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  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. * Open http://cloud-images.ubuntu.com/locator/ec2/
  17. * Enter ``amd64 precise`` in the search field (it will search as you
  18. type)
  19. * Pick an image by clicking on the image name. *An EBS-enabled
  20. image will let you use a t1.micro instance.* Clicking on the image
  21. name will take you to your AWS Console.
  22. 2. **Tell CloudInit to install Docker:**
  23. * Enter ``#include https://get.docker.io`` into the instance *User
  24. Data*. `CloudInit <https://help.ubuntu.com/community/CloudInit>`_
  25. is part of the Ubuntu image you chose and it bootstraps from this
  26. *User Data*.
  27. 3. After a few more standard choices where defaults are probably ok, your
  28. AWS Ubuntu instance with Docker should be running!
  29. **If this is your first AWS instance, you may need to set up your
  30. Security Group to allow SSH.** By default all incoming ports to your
  31. new instance will be blocked by the AWS Security Group, so you might
  32. just get timeouts when you try to connect.
  33. Installing with ``get.docker.io`` (as above) will create a service
  34. named ``dockerd``. You may want to set up a :ref:`docker group
  35. <dockergroup>` and add the *ubuntu* user to it so that you don't have
  36. to use ``sudo`` for every Docker command.
  37. Once you've got Docker installed, you're ready to try it out -- head
  38. on over to the :doc:`../use/basics` or :doc:`../examples/index` section.
  39. .. _amazonstandard:
  40. Standard Ubuntu Installation
  41. ----------------------------
  42. If you want a more hands-on installation, then you can follow the
  43. :ref:`ubuntu_linux` instructions installing Docker on any EC2 instance
  44. running Ubuntu. Just follow Step 1 from :ref:`amazonquickstart` to
  45. pick an image (or use one of your own) and skip the step with the
  46. *User Data*. Then continue with the :ref:`ubuntu_linux` instructions.
  47. .. _amazonvagrant:
  48. Use Vagrant
  49. -----------
  50. .. include:: install_unofficial.inc
  51. And finally, if you prefer to work through Vagrant, you can install
  52. Docker that way too. Vagrant 1.1 or higher is required.
  53. 1. Install vagrant from http://www.vagrantup.com/ (or use your package manager)
  54. 2. Install the vagrant aws plugin
  55. ::
  56. vagrant plugin install vagrant-aws
  57. 3. Get the docker sources, this will give you the latest Vagrantfile.
  58. ::
  59. git clone https://github.com/dotcloud/docker.git
  60. 4. Check your AWS environment.
  61. Create a keypair specifically for EC2, give it a name and save it
  62. to your disk. *I usually store these in my ~/.ssh/ folder*.
  63. Check that your default security group has an inbound rule to
  64. accept SSH (port 22) connections.
  65. 5. Inform Vagrant of your settings
  66. Vagrant will read your access credentials from your environment, so
  67. we need to set them there first. Make sure you have everything on
  68. amazon aws setup so you can (manually) deploy a new image to EC2.
  69. ::
  70. export AWS_ACCESS_KEY_ID=xxx
  71. export AWS_SECRET_ACCESS_KEY=xxx
  72. export AWS_KEYPAIR_NAME=xxx
  73. export AWS_SSH_PRIVKEY=xxx
  74. The environment variables are:
  75. * ``AWS_ACCESS_KEY_ID`` - The API key used to make requests to AWS
  76. * ``AWS_SECRET_ACCESS_KEY`` - The secret key to make AWS API requests
  77. * ``AWS_KEYPAIR_NAME`` - The name of the keypair used for this EC2 instance
  78. * ``AWS_SSH_PRIVKEY`` - The path to the private key for the named
  79. keypair, for example ``~/.ssh/docker.pem``
  80. You can check if they are set correctly by doing something like
  81. ::
  82. echo $AWS_ACCESS_KEY_ID
  83. 6. Do the magic!
  84. ::
  85. vagrant up --provider=aws
  86. If it stalls indefinitely on ``[default] Waiting for SSH to become
  87. available...``, Double check your default security zone on AWS
  88. includes rights to SSH (port 22) to your container.
  89. If you have an advanced AWS setup, you might want to have a look at
  90. https://github.com/mitchellh/vagrant-aws
  91. 7. Connect to your machine
  92. .. code-block:: bash
  93. vagrant ssh
  94. 8. Your first command
  95. Now you are in the VM, run docker
  96. .. code-block:: bash
  97. sudo docker
  98. Continue with the :ref:`hello_world` example.