зеркало из https://github.com/microsoft/docker.git
Add AWS support for running Docker on AWS
This commit is contained in:
Родитель
c65c1738b5
Коммит
8c83484bf2
31
README.md
31
README.md
|
@ -53,6 +53,37 @@ Under the hood, Docker is built on the following components:
|
|||
Install instructions
|
||||
==================
|
||||
|
||||
Installing with Vagrant
|
||||
-----------------------
|
||||
|
||||
Currently, Docker can be installed with Vagrant both on your localhost
|
||||
with VirtualBox as well as on Amazon EC2. Vagrant 1.1 is required for
|
||||
EC2, but deploying is as simple as:
|
||||
|
||||
```bash
|
||||
$ export AWS_ACCESS_KEY_ID=xxx \
|
||||
AWS_SECRET_ACCESS_KEY=xxx \
|
||||
AWS_KEYPAIR_NAME=xxx \
|
||||
AWS_SSH_PRIVKEY=xxx
|
||||
$ vagrant plugin install vagrant-aws
|
||||
$ vagrant up --provider=aws
|
||||
```
|
||||
|
||||
The environment variables are:
|
||||
|
||||
* `AWS_ACCESS_KEY_ID` - The API key used to make requests to AWS
|
||||
* `AWS_SECRET_ACCESS_KEY` - The secret key to make AWS API requests
|
||||
* `AWS_KEYPAIR_NAME` - The name of the keypair used for this EC2 instance
|
||||
* `AWS_SSH_PRIVKEY` - The path to the private key for the named keypair
|
||||
|
||||
For VirtualBox, you can simply ignore setting any of the environment
|
||||
variables and omit the ``provider`` flag. VirtualBox is still supported with
|
||||
VirtualBox <= 1.1:
|
||||
|
||||
```bash
|
||||
$ vagrant up --provider=aws
|
||||
```
|
||||
|
||||
Installing on Ubuntu 12.04 and 12.10
|
||||
------------------------------------
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# -*- mode: ruby -*-
|
||||
# vi: set ft=ruby :
|
||||
|
||||
Vagrant::Config.run do |config|
|
||||
Vagrant.configure("1") do |config|
|
||||
# All Vagrant configuration is done here. The most common configuration
|
||||
# options are documented and commented below. For a complete reference,
|
||||
# please see the online documentation at vagrantup.com.
|
||||
|
@ -98,3 +98,22 @@ Vagrant::Config.run do |config|
|
|||
#
|
||||
# chef.validation_client_name = "ORGNAME-validator"
|
||||
end
|
||||
|
||||
Vagrant.configure("2") do |config|
|
||||
config.vm.provider :aws do |aws|
|
||||
config.vm.box = "dummy"
|
||||
config.vm.box_url = "https://github.com/mitchellh/vagrant-aws/raw/master/dummy.box"
|
||||
aws.access_key_id = ENV["AWS_ACCESS_KEY_ID"]
|
||||
aws.secret_access_key = ENV["AWS_SECRET_ACCESS_KEY"]
|
||||
aws.keypair_name = ENV["AWS_KEYPAIR_NAME"]
|
||||
aws.ssh_private_key_path = ENV["AWS_SSH_PRIVKEY"]
|
||||
aws.region = "us-east-1"
|
||||
aws.ami = "ami-1c1e8075"
|
||||
aws.ssh_username = "vagrant"
|
||||
aws.instance_type = "t1.micro"
|
||||
end
|
||||
config.vm.provider :virtualbox do |vb|
|
||||
config.vm.box = "quantal64_3.5.0-25"
|
||||
config.vm.box_url = "http://get.docker.io/vbox/ubuntu/12.10/quantal64_3.5.0-25.box"
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,7 +1,34 @@
|
|||
class virtualbox {
|
||||
Package { ensure => "installed" }
|
||||
|
||||
# remove some files from the base vagrant image because they're old
|
||||
file { "/home/vagrant/docker-master":
|
||||
ensure => absent,
|
||||
recurse => true,
|
||||
force => true,
|
||||
purge => true,
|
||||
}
|
||||
file { "/usr/local/bin/dockerd":
|
||||
ensure => absent,
|
||||
}
|
||||
|
||||
# Set up VirtualBox guest utils
|
||||
package { "virtualbox-guest-utils": }
|
||||
exec { "vbox-add" :
|
||||
command => "/etc/init.d/vboxadd setup",
|
||||
require => [
|
||||
Package["virtualbox-guest-utils"],
|
||||
Package["linux-headers-3.5.0-25-generic"], ],
|
||||
}
|
||||
}
|
||||
|
||||
class ec2 {
|
||||
}
|
||||
|
||||
class docker {
|
||||
|
||||
# update this with latest docker binary distro
|
||||
$docker_url = "http://docker.io.s3.amazonaws.com/builds/$kernel/$hardwaremodel/docker-master.tgz"
|
||||
$docker_url = "http://get.docker.io/builds/$kernel/$hardwaremodel/docker-master.tgz"
|
||||
# update this with latest go binary distry
|
||||
$go_url = "http://go.googlecode.com/files/go1.0.3.linux-amd64.tar.gz"
|
||||
|
||||
|
@ -11,18 +38,32 @@ class docker {
|
|||
"pkg-config", "libsqlite3-dev",
|
||||
"linux-image-3.5.0-25-generic",
|
||||
"linux-image-extra-3.5.0-25-generic",
|
||||
"virtualbox-guest-utils",
|
||||
"linux-headers-3.5.0-25-generic"]: }
|
||||
|
||||
notify { "docker_url = $docker_url": withpath => true }
|
||||
|
||||
exec { "debootstrap" :
|
||||
require => Package["debootstrap"],
|
||||
command => "/usr/sbin/debootstrap --arch=amd64 quantal /var/lib/docker/images/docker-ut",
|
||||
creates => "/var/lib/docker/images/docker-ut",
|
||||
timeout => 0
|
||||
$ec2_version = file("/etc/ec2_version", "/dev/null")
|
||||
if ($ec2_version) {
|
||||
include ec2
|
||||
} else {
|
||||
# virtualbox is the vagrant default, so it should be safe to assume
|
||||
include virtualbox
|
||||
}
|
||||
|
||||
user { "vagrant":
|
||||
ensure => present,
|
||||
comment => "Vagrant User",
|
||||
shell => "/bin/bash",
|
||||
home => "/home/vagrant",
|
||||
}
|
||||
|
||||
file { "/usr/local/bin":
|
||||
ensure => directory,
|
||||
owner => root,
|
||||
group => root,
|
||||
mode => 755,
|
||||
}
|
||||
|
||||
exec { "fetch-go":
|
||||
require => Package["wget"],
|
||||
command => "/usr/bin/wget -O - $go_url | /bin/tar xz -C /usr/local",
|
||||
|
@ -30,9 +71,8 @@ class docker {
|
|||
}
|
||||
|
||||
exec { "fetch-docker" :
|
||||
command => "/usr/bin/wget -O - $docker_url | /bin/tar xz -C /tmp",
|
||||
require => Package["wget"],
|
||||
command => "/usr/bin/wget -O - $docker_url | /bin/tar xz -C /home/vagrant",
|
||||
creates => "/home/vagrant/docker-master"
|
||||
}
|
||||
|
||||
file { "/etc/init/dockerd.conf":
|
||||
|
@ -40,25 +80,25 @@ class docker {
|
|||
owner => "root",
|
||||
group => "root",
|
||||
content => template("docker/dockerd.conf"),
|
||||
require => [Exec["fetch-docker"], Exec["debootstrap"]]
|
||||
require => Exec["fetch-docker"],
|
||||
}
|
||||
|
||||
file { "/home/vagrant":
|
||||
mode => 644,
|
||||
require => User["vagrant"],
|
||||
}
|
||||
|
||||
file { "/home/vagrant/.profile":
|
||||
mode => 644,
|
||||
owner => "vagrant",
|
||||
group => "vagrant",
|
||||
group => "ubuntu",
|
||||
content => template("docker/profile"),
|
||||
require => File["/home/vagrant"],
|
||||
}
|
||||
|
||||
exec { "copy-docker-bin" :
|
||||
require => Exec["fetch-docker"],
|
||||
command => "/bin/cp /home/vagrant/docker-master/docker /usr/local/bin",
|
||||
creates => "/usr/local/bin/docker"
|
||||
}
|
||||
|
||||
exec { "vbox-add" :
|
||||
require => Package["linux-headers-3.5.0-25-generic"],
|
||||
command => "/etc/init.d/vboxadd setup",
|
||||
command => "/usr/bin/sudo /bin/cp -f /tmp/docker-master/docker /usr/local/bin/",
|
||||
require => [ Exec["fetch-docker"], File["/usr/local/bin"] ],
|
||||
}
|
||||
|
||||
service { "dockerd" :
|
||||
|
@ -69,6 +109,4 @@ class docker {
|
|||
name => "dockerd",
|
||||
provider => "base"
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче