amazon.rst 5.5 KB

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