mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Add AWS support for running Docker on AWS
This commit is contained in:
parent
c65c1738b5
commit
8c83484bf2
3 changed files with 110 additions and 22 deletions
31
README.md
31
README.md
|
@ -53,6 +53,37 @@ Under the hood, Docker is built on the following components:
|
||||||
Install instructions
|
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
|
Installing on Ubuntu 12.04 and 12.10
|
||||||
------------------------------------
|
------------------------------------
|
||||||
|
|
||||||
|
|
21
Vagrantfile
vendored
21
Vagrantfile
vendored
|
@ -1,7 +1,7 @@
|
||||||
# -*- mode: ruby -*-
|
# -*- mode: ruby -*-
|
||||||
# vi: set ft=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
|
# All Vagrant configuration is done here. The most common configuration
|
||||||
# options are documented and commented below. For a complete reference,
|
# options are documented and commented below. For a complete reference,
|
||||||
# please see the online documentation at vagrantup.com.
|
# please see the online documentation at vagrantup.com.
|
||||||
|
@ -98,3 +98,22 @@ Vagrant::Config.run do |config|
|
||||||
#
|
#
|
||||||
# chef.validation_client_name = "ORGNAME-validator"
|
# chef.validation_client_name = "ORGNAME-validator"
|
||||||
end
|
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 {
|
class docker {
|
||||||
|
|
||||||
# update this with latest docker binary distro
|
# 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
|
# update this with latest go binary distry
|
||||||
$go_url = "http://go.googlecode.com/files/go1.0.3.linux-amd64.tar.gz"
|
$go_url = "http://go.googlecode.com/files/go1.0.3.linux-amd64.tar.gz"
|
||||||
|
|
||||||
|
@ -11,16 +38,30 @@ class docker {
|
||||||
"pkg-config", "libsqlite3-dev",
|
"pkg-config", "libsqlite3-dev",
|
||||||
"linux-image-3.5.0-25-generic",
|
"linux-image-3.5.0-25-generic",
|
||||||
"linux-image-extra-3.5.0-25-generic",
|
"linux-image-extra-3.5.0-25-generic",
|
||||||
"virtualbox-guest-utils",
|
|
||||||
"linux-headers-3.5.0-25-generic"]: }
|
"linux-headers-3.5.0-25-generic"]: }
|
||||||
|
|
||||||
notify { "docker_url = $docker_url": withpath => true }
|
notify { "docker_url = $docker_url": withpath => true }
|
||||||
|
|
||||||
exec { "debootstrap" :
|
$ec2_version = file("/etc/ec2_version", "/dev/null")
|
||||||
require => Package["debootstrap"],
|
if ($ec2_version) {
|
||||||
command => "/usr/sbin/debootstrap --arch=amd64 quantal /var/lib/docker/images/docker-ut",
|
include ec2
|
||||||
creates => "/var/lib/docker/images/docker-ut",
|
} else {
|
||||||
timeout => 0
|
# 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":
|
exec { "fetch-go":
|
||||||
|
@ -30,9 +71,8 @@ class docker {
|
||||||
}
|
}
|
||||||
|
|
||||||
exec { "fetch-docker" :
|
exec { "fetch-docker" :
|
||||||
|
command => "/usr/bin/wget -O - $docker_url | /bin/tar xz -C /tmp",
|
||||||
require => Package["wget"],
|
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":
|
file { "/etc/init/dockerd.conf":
|
||||||
|
@ -40,25 +80,25 @@ class docker {
|
||||||
owner => "root",
|
owner => "root",
|
||||||
group => "root",
|
group => "root",
|
||||||
content => template("docker/dockerd.conf"),
|
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":
|
file { "/home/vagrant/.profile":
|
||||||
mode => 644,
|
mode => 644,
|
||||||
owner => "vagrant",
|
owner => "vagrant",
|
||||||
group => "vagrant",
|
group => "ubuntu",
|
||||||
content => template("docker/profile"),
|
content => template("docker/profile"),
|
||||||
|
require => File["/home/vagrant"],
|
||||||
}
|
}
|
||||||
|
|
||||||
exec { "copy-docker-bin" :
|
exec { "copy-docker-bin" :
|
||||||
require => Exec["fetch-docker"],
|
command => "/usr/bin/sudo /bin/cp -f /tmp/docker-master/docker /usr/local/bin/",
|
||||||
command => "/bin/cp /home/vagrant/docker-master/docker /usr/local/bin",
|
require => [ Exec["fetch-docker"], File["/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",
|
|
||||||
}
|
}
|
||||||
|
|
||||||
service { "dockerd" :
|
service { "dockerd" :
|
||||||
|
@ -69,6 +109,4 @@ class docker {
|
||||||
name => "dockerd",
|
name => "dockerd",
|
||||||
provider => "base"
|
provider => "base"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue