发布于 2015-09-10 16:19:11 | 241 次阅读 | 评论: 0 | 来源: 网络整理

注解

Docker is still under heavy development! We don’t recommend using it in production yet, but we’re getting closer with each release. Please see our blog post, “Getting to Docker 1.0”

There are several ways to install Docker on AWS EC2:

You’ll need an AWS account first, of course.

Amazon QuickStart

  1. Choose an image:
    • Launch the Create Instance Wizard menu on your AWS Console.
    • Click the Select button for a 64Bit Ubuntu image. For example: Ubuntu Server 12.04.3 LTS
    • For testing you can use the default (possibly free) t1.micro instance (more info on pricing).
    • Click the Next: Configure Instance Details button at the bottom right.
  2. Tell CloudInit to install Docker:
    • When you’re on the “Configure Instance Details” step, expand the “Advanced Details” section.
    • Under “User data”, select “As text”.
    • Enter #include https://get.docker.io into the instance User Data. CloudInit is part of the Ubuntu image you chose; it will bootstrap Docker by running the shell script located at this URL.
  3. After a few more standard choices where defaults are probably ok, your AWS Ubuntu instance with Docker should be running!

If this is your first AWS instance, you may need to set up your Security Group to allow SSH. By default all incoming ports to your new instance will be blocked by the AWS Security Group, so you might just get timeouts when you try to connect.

Installing with get.docker.io (as above) will create a service named lxc-docker. It will also set up a docker group and you may want to add the ubuntu user to it so that you don’t have to use sudo for every Docker command.

Once you’ve got Docker installed, you’re ready to try it out – head on over to the 使用Docker第一步 or 实例 section.

Standard Ubuntu Installation

If you want a more hands-on installation, then you can follow the Ubuntu instructions installing Docker on any EC2 instance running Ubuntu. Just follow Step 1 from Amazon QuickStart to pick an image (or use one of your own) and skip the step with the User Data. Then continue with the Ubuntu instructions.

Use Vagrant

注解

This is a community contributed installation path. The only ‘official’ installation is using the Ubuntu installation path. This version may be out of date because it depends on some binaries to be updated and published

And finally, if you prefer to work through Vagrant, you can install Docker that way too. Vagrant 1.1 or higher is required.

  1. Install vagrant from http://www.vagrantup.com/ (or use your package manager)

  2. Install the vagrant aws plugin

    vagrant plugin install vagrant-aws
    
  3. Get the docker sources, this will give you the latest Vagrantfile.

    git clone https://github.com/dotcloud/docker.git
    
  4. Check your AWS environment.

    Create a keypair specifically for EC2, give it a name and save it to your disk. I usually store these in my ~/.ssh/ folder.

    Check that your default security group has an inbound rule to accept SSH (port 22) connections.

  5. Inform Vagrant of your settings

    Vagrant will read your access credentials from your environment, so we need to set them there first. Make sure you have everything on amazon aws setup so you can (manually) deploy a new image to EC2.

    Note that where possible these variables are the same as those honored by the ec2 api tools.

    export AWS_ACCESS_KEY=xxx
    export AWS_SECRET_KEY=xxx
    export AWS_KEYPAIR_NAME=xxx
    export SSH_PRIVKEY_PATH=xxx
    
    export BOX_NAME=xxx
    export AWS_REGION=xxx
    export AWS_AMI=xxx
    export AWS_INSTANCE_TYPE=xxx
    

    The required environment variables are:

    < >AWS_ACCESS_KEY - The API key used to make requests to AWSAWS_SECRET_KEY - The secret key to make AWS API requestsAWS_KEYPAIR_NAME - The name of the keypair used for this EC2 instanceSSH_PRIVKEY_PATH - The path to the private key for the named keypair, for example ~/.ssh/docker.pemBOX_NAME - The name of the vagrant box to use. Defaults to ubuntu.AWS_REGION - The aws region to spawn the vm in. Defaults to us-east-1.AWS_AMI - The aws AMI to start with as a base. This must be be an ubuntu 12.04 precise image. You must change this value if AWS_REGION is set to a value other than us-east-1. This is because AMIs are region specific. Defaults to ami-69f5a900.AWS_INSTANCE_TYPE - The aws instance type. Defaults to t1.micro.

    You can check if they are set correctly by doing something like

    echo $AWS_ACCESS_KEY
    
  6. Do the magic!

    vagrant up --provider=aws
    

    If it stalls indefinitely on [default] Waiting for SSH to become available..., Double check your default security zone on AWS includes rights to SSH (port 22) to your container.

    If you have an advanced AWS setup, you might want to have a look at vagrant-aws.

  7. Connect to your machine

    vagrant ssh
    
  8. Your first command

    Now you are in the VM, run docker

    sudo docker
    

Continue with the Hello World example.

最新网友评论  共有(0)条评论 发布评论 返回顶部

Copyright © 2007-2017 PHPERZ.COM All Rights Reserved   冀ICP备14009818号  版权声明  广告服务