Browse code

Merge remote-tracking branch 'dotcloud/master' into local/dotcloud/docs

Thatcher Peskens authored on 2013/03/29 02:58:01
Showing 11 changed files
... ...
@@ -1,4 +1,4 @@
1
-.vagrant
1
+.vagrant*
2 2
 bin
3 3
 docker/docker
4 4
 .*.swp
... ...
@@ -13,4 +13,5 @@ auth/auth.test
13 13
 .DS_Store
14 14
 docs/_build
15 15
 docs/_static
16
-docs/_templates
17 16
\ No newline at end of file
17
+docs/_templates
18
+.gopath/
18 19
new file mode 100644
... ...
@@ -0,0 +1,43 @@
0
+DOCKER_PACKAGE := github.com/dotcloud/docker
1
+
2
+BUILD_DIR := $(CURDIR)/.gopath
3
+
4
+GOPATH ?= $(BUILD_DIR)
5
+export GOPATH
6
+
7
+GO_OPTIONS ?=
8
+ifeq ($(VERBOSE), 1)
9
+GO_OPTIONS += -v
10
+endif
11
+
12
+SRC_DIR := $(GOPATH)/src
13
+
14
+DOCKER_DIR := $(SRC_DIR)/$(DOCKER_PACKAGE)
15
+DOCKER_MAIN := $(DOCKER_DIR)/docker
16
+
17
+DOCKER_BIN_RELATIVE := bin/docker
18
+DOCKER_BIN := $(CURDIR)/$(DOCKER_BIN_RELATIVE)
19
+
20
+.PHONY: all clean test
21
+
22
+all: $(DOCKER_BIN)
23
+
24
+$(DOCKER_BIN): $(DOCKER_DIR)
25
+	@mkdir -p  $(dir $@)
26
+	@(cd $(DOCKER_MAIN); go get $(GO_OPTIONS); go build $(GO_OPTIONS) -o $@)
27
+	@echo $(DOCKER_BIN_RELATIVE) is created.
28
+
29
+$(DOCKER_DIR):
30
+	@mkdir -p $(dir $@)
31
+	@ln -sf $(CURDIR)/ $@
32
+
33
+clean:
34
+	@rm -rf $(dir $(DOCKER_BIN))
35
+ifeq ($(GOPATH), $(BUILD_DIR))
36
+	@rm -rf $(BUILD_DIR)
37
+else ifneq ($(DOCKER_DIR), $(realpath $(DOCKER_DIR)))
38
+	@rm -f $(DOCKER_DIR)
39
+endif
40
+
41
+test: all
42
+	@(cd $(DOCKER_DIR); sudo -E go test $(GO_OPTIONS))
... ...
@@ -25,7 +25,7 @@ Notable features
25 25
 
26 26
 * Network isolation: each process container runs in its own network namespace, with a virtual interface and IP address of its own.
27 27
 
28
-* Copy-on-write: root filesystems are created using copy-on-write, which makes deployment extremeley fast, memory-cheap and disk-cheap.
28
+* Copy-on-write: root filesystems are created using copy-on-write, which makes deployment extremely fast, memory-cheap and disk-cheap.
29 29
 
30 30
 * Logging: the standard streams (stdout/stderr/stdin) of each process container are collected and logged for real-time or batch retrieval.
31 31
 
... ...
@@ -53,6 +53,30 @@ Under the hood, Docker is built on the following components:
53 53
 Install instructions
54 54
 ==================
55 55
 
56
+Building from source
57
+--------------------
58
+
59
+1. Make sure you have a [Go language](http://golang.org) compiler.
60
+
61
+    On a Debian/wheezy or Ubuntu 12.10 install the package:
62
+
63
+    ```bash
64
+
65
+    $ sudo apt-get install golang-go
66
+    ```
67
+
68
+2. Execute ``make``
69
+
70
+   This command will install all necessary dependencies and build the
71
+   executable that you can find in ``bin/docker``
72
+
73
+3. Should you like to see what's happening, run ``make`` with ``VERBOSE=1`` parameter:
74
+
75
+    ```bash
76
+
77
+    $ make VERBOSE=1
78
+    ```
79
+
56 80
 Installing on Ubuntu 12.04 and 12.10
57 81
 ------------------------------------
58 82
 
... ...
@@ -2,115 +2,30 @@
2 2
 # vi: set ft=ruby :
3 3
 
4 4
 def v10(config)
5
-  # All Vagrant configuration is done here. The most common configuration
6
-  # options are documented and commented below. For a complete reference,
7
-  # please see the online documentation at vagrantup.com.
8
-
9
-  # Every Vagrant virtual environment requires a box to build off of.
10 5
   config.vm.box = "quantal64_3.5.0-25"
11
-
12
-  # The url from where the 'config.vm.box' box will be fetched if it
13
-  # doesn't already exist on the user's system.
14 6
   config.vm.box_url = "http://get.docker.io/vbox/ubuntu/12.10/quantal64_3.5.0-25.box"
15 7
 
16
-  # Boot with a GUI so you can see the screen. (Default is headless)
17
-  # config.vm.boot_mode = :gui
18
-
19
-  # Assign this VM to a host-only network IP, allowing you to access it
20
-  # via the IP. Host-only networks can talk to the host machine as well as
21
-  # any other machines on the same network, but cannot be accessed (through this
22
-  # network interface) by any external networks.
23
-  config.vm.network :hostonly, "192.168.33.10"
24
-
25
-  # Assign this VM to a bridged network, allowing you to connect directly to a
26
-  # network using the host's network device. This makes the VM appear as another
27
-  # physical device on your network.
28
-  # config.vm.network :bridged
29
-
30
-  # Forward a port from the guest to the host, which allows for outside
31
-  # computers to access the VM, whereas host only networking does not.
32
-  # config.vm.forward_port 80, 8080
8
+  config.vm.share_folder "v-data", "/opt/go/src/github.com/dotcloud/docker", File.dirname(__FILE__)
33 9
 
34 10
   # Ensure puppet is installed on the instance
35 11
   config.vm.provision :shell, :inline => "apt-get -qq update; apt-get install -y puppet"
36 12
 
37
-  # Share an additional folder to the guest VM. The first argument is
38
-  # an identifier, the second is the path on the guest to mount the
39
-  # folder, and the third is the path on the host to the actual folder.
40
-  config.vm.share_folder "v-data", "~/docker", "~/docker"
41
-
42
-  # Enable provisioning with Puppet stand alone.  Puppet manifests
43
-  # are contained in a directory path relative to this Vagrantfile.
44
-  # You will need to create the manifests directory and a manifest in
45
-  # the file quantal64.pp in the manifests_path directory.
46
-  #
47
-  # An example Puppet manifest to provision the message of the day:
48
-  #
49
-  # # group { "puppet":
50
-  # #   ensure => "present",
51
-  # # }
52
-  # #
53
-  # # File { owner => 0, group => 0, mode => 0644 }
54
-  # #
55
-  # # file { '/etc/motd':
56
-  # #   content => "Welcome to your Vagrant-built virtual machine!
57
-  # #               Managed by Puppet.\n"
58
-  # # }
59
-  #
60 13
   config.vm.provision :puppet do |puppet|
61 14
     puppet.manifests_path = "puppet/manifests"
62 15
     puppet.manifest_file  = "quantal64.pp"
63 16
     puppet.module_path = "puppet/modules"
64 17
   end
65
-
66
-  # Enable provisioning with chef solo, specifying a cookbooks path, roles
67
-  # path, and data_bags path (all relative to this Vagrantfile), and adding 
68
-  # some recipes and/or roles.
69
-  #
70
-  # config.vm.provision :chef_solo do |chef|
71
-  #   chef.cookbooks_path = "../my-recipes/cookbooks"
72
-  #   chef.roles_path = "../my-recipes/roles"
73
-  #   chef.data_bags_path = "../my-recipes/data_bags"
74
-  #   chef.add_recipe "mysql"
75
-  #   chef.add_role "web"
76
-  #
77
-  #   # You may also specify custom JSON attributes:
78
-  #   chef.json = { :mysql_password => "foo" }
79
-  # end
80
-
81
-  # Enable provisioning with chef server, specifying the chef server URL,
82
-  # and the path to the validation key (relative to this Vagrantfile).
83
-  #
84
-  # The Opscode Platform uses HTTPS. Substitute your organization for
85
-  # ORGNAME in the URL and validation key.
86
-  #
87
-  # If you have your own Chef Server, use the appropriate URL, which may be
88
-  # HTTP instead of HTTPS depending on your configuration. Also change the
89
-  # validation key to validation.pem.
90
-  #
91
-  # config.vm.provision :chef_client do |chef|
92
-  #   chef.chef_server_url = "https://api.opscode.com/organizations/ORGNAME"
93
-  #   chef.validation_key_path = "ORGNAME-validator.pem"
94
-  # end
95
-  #
96
-  # If you're using the Opscode platform, your validator client is
97
-  # ORGNAME-validator, replacing ORGNAME with your organization name.
98
-  #
99
-  # IF you have your own Chef Server, the default validation client name is
100
-  # chef-validator, unless you changed the configuration.
101
-  #
102
-  #   chef.validation_client_name = "ORGNAME-validator"
103 18
 end
104 19
 
105
-"#{Vagrant::VERSION}" < "1.1.0" and Vagrant::Config.run do |config|
20
+Vagrant::VERSION < "1.1.0" and Vagrant::Config.run do |config|
106 21
   v10(config)
107 22
 end
108 23
 
109
-"#{Vagrant::VERSION}" >= "1.1.0" and Vagrant.configure("1") do |config|
24
+Vagrant::VERSION >= "1.1.0" and Vagrant.configure("1") do |config|
110 25
   v10(config)
111 26
 end
112 27
 
113
-"#{Vagrant::VERSION}" >= "1.1.0" and Vagrant.configure("2") do |config|
28
+Vagrant::VERSION >= "1.1.0" and Vagrant.configure("2") do |config|
114 29
   config.vm.provider :aws do |aws|
115 30
     config.vm.box = "dummy"
116 31
     config.vm.box_url = "https://github.com/mitchellh/vagrant-aws/raw/master/dummy.box"
... ...
@@ -119,20 +34,22 @@ end
119 119
     aws.keypair_name = ENV["AWS_KEYPAIR_NAME"]
120 120
     aws.ssh_private_key_path = ENV["AWS_SSH_PRIVKEY"]
121 121
     aws.region = "us-east-1"
122
-    aws.ami = "ami-1c1e8075"
123
-    aws.ssh_username = "vagrant"
122
+    aws.ami = "ami-ae9806c7"
123
+    aws.ssh_username = "ubuntu"
124 124
     aws.instance_type = "t1.micro"
125 125
   end
126
+
126 127
   config.vm.provider :rackspace do |rs|
127 128
     config.vm.box = "dummy"
128 129
     config.vm.box_url = "https://github.com/mitchellh/vagrant-rackspace/raw/master/dummy.box"
129 130
     config.ssh.private_key_path = ENV["RS_PRIVATE_KEY"]
130 131
     rs.username = ENV["RS_USERNAME"]
131 132
     rs.api_key  = ENV["RS_API_KEY"]
132
-    rs.public_key_path = ENV["RS_PUBLIC_KEY"] 
133
+    rs.public_key_path = ENV["RS_PUBLIC_KEY"]
133 134
     rs.flavor   = /512MB/
134 135
     rs.image    = /Ubuntu/
135
-  end   
136
+  end
137
+
136 138
   config.vm.provider :virtualbox do |vb|
137 139
     config.vm.box = "quantal64_3.5.0-25"
138 140
     config.vm.box_url = "http://get.docker.io/vbox/ubuntu/12.10/quantal64_3.5.0-25.box"
... ...
@@ -43,7 +43,7 @@ func (srv *Server) Help() string {
43 43
 		{"logs", "Fetch the logs of a container"},
44 44
 		{"port", "Lookup the public-facing port which is NAT-ed to PRIVATE_PORT"},
45 45
 		{"ps", "List containers"},
46
-		{"pull", "Pull an image or a repository to the docker registry server"},
46
+		{"pull", "Pull an image or a repository from the docker registry server"},
47 47
 		{"push", "Push an image or a repository to the docker registry server"},
48 48
 		{"restart", "Restart a running container"},
49 49
 		{"rm", "Remove a container"},
... ...
@@ -13,11 +13,11 @@ Running an interactive shell
13 13
 .. code-block:: bash
14 14
 
15 15
   # Download a base image
16
-  docker import base
16
+  docker pull base
17 17
 
18 18
   # Run an interactive shell in the base image,
19 19
   # allocate a tty, attach stdin and stdout
20
-  docker run -a -i -t base /bin/bash
20
+  docker run -i -t base /bin/bash
21 21
 
22 22
 
23 23
 Starting a long-running worker process
... ...
@@ -26,10 +26,10 @@ Starting a long-running worker process
26 26
 .. code-block:: bash
27 27
 
28 28
   # Run docker in daemon mode
29
-  (docker -d || echo "Docker daemon already running") &
29
+  (sudo docker -d || echo "Docker daemon already running") &
30 30
 
31 31
   # Start a very useful long-running process
32
-  JOB=$(docker run base /bin/sh -c "while true; do echo Hello world!; sleep 1; done")
32
+  JOB=$(docker run -d base /bin/sh -c "while true; do echo Hello world; sleep 1; done")
33 33
 
34 34
   # Collect the output of the job so far
35 35
   docker logs $JOB
... ...
@@ -51,7 +51,7 @@ Expose a service on a TCP port
51 51
 .. code-block:: bash
52 52
 
53 53
   # Expose port 4444 of this container, and tell netcat to listen on it
54
-  JOB=$(docker run -p 4444 base /bin/nc -l -p 4444)
54
+  JOB=$(docker run -d -p 4444 base /bin/nc -l -p 4444)
55 55
 
56 56
   # Which public port is NATed to my container?
57 57
   PORT=$(docker port $JOB 4444)
... ...
@@ -12,9 +12,9 @@ The goal of this example is to show you how you can author your own docker image
12 12
 
13 13
 .. code-block:: bash
14 14
 
15
-    $ docker import shykes/pybuilder
15
+    $ docker pull shykes/pybuilder
16 16
 
17
-We are importing the "shykes/pybuilder" docker image
17
+We are downloading the "shykes/pybuilder" docker image
18 18
 
19 19
 .. code-block:: bash
20 20
 
... ...
@@ -156,7 +156,7 @@ You are now ready for the docker’s “hello world” example. Run
156 156
 
157 157
 .. code-block:: bash
158 158
 
159
-	docker run -a busybox echo hello world 
159
+	docker run busybox echo hello world
160 160
 
161 161
 .. image:: images/win/run_04.gif
162 162
    :alt: run docker
... ...
@@ -1,38 +1,32 @@
1 1
 class virtualbox {
2
-	Package { ensure => "installed" }
2
+    Package { ensure => "installed" }
3 3
 
4
-	# remove some files from the base vagrant image because they're old
5
-	file { "/home/vagrant/docker-master":
6
-		ensure => absent,
7
-		recurse => true,
8
-		force => true,
9
-		purge => true,
10
-	}
11
-	file { "/usr/local/bin/dockerd":
12
-		ensure => absent,
13
-	}
4
+    # remove some files from the base vagrant image because they're old
5
+    file { "/home/vagrant/docker-master":
6
+        ensure => absent,
7
+        recurse => true,
8
+        force => true,
9
+        purge => true,
10
+    }
11
+    file { "/usr/local/bin/dockerd":
12
+        ensure => absent,
13
+    }
14
+    file { "/usr/local/bin/docker":
15
+        ensure => absent,
16
+    }
14 17
 
15
-	# Set up VirtualBox guest utils
16
-	package { "virtualbox-guest-utils": }
18
+    # Set up VirtualBox guest utils
19
+    package { "virtualbox-guest-utils": }
17 20
     exec { "vbox-add" :
18 21
         command => "/etc/init.d/vboxadd setup",
19 22
         require => [
20
-			Package["virtualbox-guest-utils"],
21
-			Package["linux-headers-3.5.0-25-generic"], ],
23
+            Package["virtualbox-guest-utils"],
24
+            Package["linux-headers-3.5.0-25-generic"], ],
22 25
     }
23 26
 }
24 27
 
25
-class ec2 {
26
-}
27
-
28
-class rax {
29
-}
30
-
31 28
 class docker {
32
-
33
-    # update this with latest docker binary distro
34
-    $docker_url = "http://get.docker.io/builds/$kernel/$hardwaremodel/docker-master.tgz"
35
-    # update this with latest go binary distry
29
+    # update this with latest go binary dist
36 30
     $go_url = "http://go.googlecode.com/files/go1.0.3.linux-amd64.tar.gz"
37 31
 
38 32
     Package { ensure => "installed" }
... ...
@@ -43,99 +37,63 @@ class docker {
43 43
                "linux-image-extra-3.5.0-25-generic",
44 44
                "linux-headers-3.5.0-25-generic"]: }
45 45
 
46
-    notify { "docker_url = $docker_url": withpath => true }
47
-
48 46
     $ec2_version = file("/etc/ec2_version", "/dev/null")
49 47
     $rax_version = inline_template("<%= %x{/usr/bin/xenstore-read vm-data/provider_data/provider} %>")
50 48
 
51 49
     if ($ec2_version) {
52
-	include ec2
50
+        $vagrant_user = "ubuntu"
51
+        $vagrant_home = "/home/ubuntu"
53 52
     } elsif ($rax_version) {
54
-        include rax
53
+        $vagrant_user = "root"
54
+        $vagrant_home = "/root"
55 55
     } else {
56
-    # virtualbox is the vagrant default, so it should be safe to assume
56
+        # virtualbox is the vagrant default, so it should be safe to assume
57
+        $vagrant_user = "vagrant"
58
+        $vagrant_home = "/home/vagrant"
57 59
         include virtualbox
58 60
     }
59 61
 
60
-    user { "vagrant":
61
-        ensure => present,
62
-        comment => "Vagrant User",
63
-        shell => "/bin/bash",
64
-        home => "/home/vagrant",
65
-        groups => [
66
-            "sudo",
67
-            "vagrant",
68
-            "ubuntu",
69
-        ],
70
-        require => [
71
-            Group["sudo"],
72
-            Group["vagrant"],
73
-            Group["ubuntu"],
74
-        ],
75
-    }
76
-
77
-	group { "ubuntu":
78
-		ensure => present,
79
-	}
80
-
81
-	group { "vagrant":
82
-		ensure => present,
83
-	}
84
-
85
-	group { "sudo":
86
-		ensure => present,
87
-	}
88
-
89
-	file { "/usr/local/bin":
90
-		ensure => directory,
91
-		owner => root,
92
-		group => root,
93
-		mode => 755,
94
-	}
95
-
96 62
     exec { "fetch-go":
97 63
         require => Package["wget"],
98 64
         command => "/usr/bin/wget -O - $go_url | /bin/tar xz -C /usr/local",
99 65
         creates => "/usr/local/go/bin/go",
100 66
     }
101 67
 
102
-    exec { "fetch-docker" :
103
-        command => "/usr/bin/wget -O - $docker_url | /bin/tar xz -C /tmp",
104
-        require => Package["wget"],
105
-    }
106
-
107 68
     file { "/etc/init/dockerd.conf":
108 69
         mode => 600,
109 70
         owner => "root",
110 71
         group => "root",
111 72
         content => template("docker/dockerd.conf"),
112
-        require => Exec["copy-docker-bin"],
113 73
     }
114 74
 
115
-    file { "/home/vagrant":
116
-        ensure => directory,
117
-        mode => 644,
118
-        require => User["vagrant"],
75
+    file { "/opt/go":
76
+        owner => $vagrant_user,
77
+        group => $vagrant_user,
78
+        recurse => true,
119 79
     }
120 80
 
121
-    file { "/home/vagrant/.profile":
81
+    file { "${vagrant_home}/.profile":
122 82
         mode => 644,
123
-        owner => "vagrant",
124
-        group => "vagrant",
83
+        owner => $vagrant_user,
84
+        group => $vagrant_user,
125 85
         content => template("docker/profile"),
126
-        require => File["/home/vagrant"],
127 86
     }
128 87
 
129
-    exec { "copy-docker-bin" :
130
-        command => "/usr/bin/sudo /bin/cp -f /tmp/docker-master/docker /usr/local/bin/",
131
-        require => [ Exec["fetch-docker"], File["/usr/local/bin"] ],
88
+     exec { "build-docker" :
89
+        cwd  => "/opt/go/src/github.com/dotcloud/docker",
90
+        user => $vagrant_user,
91
+        environment => "GOPATH=/opt/go",
92
+        command => "/usr/local/go/bin/go get -v ./... && /usr/local/go/bin/go install ./docker",
93
+        creates => "/opt/go/bin/docker",
94
+        logoutput => "on_failure",
95
+        require => [ Exec["fetch-go"], File["/opt/go"] ],
132 96
     }
133 97
 
134 98
     service { "dockerd" :
135 99
         ensure => "running",
136 100
         start => "/sbin/initctl start dockerd",
137 101
         stop => "/sbin/initctl stop dockerd",
138
-        require => File["/etc/init/dockerd.conf"],
102
+        require => [ Exec["build-docker"], File["/etc/init/dockerd.conf"] ],
139 103
         name => "dockerd",
140 104
         provider => "base"
141 105
     }
... ...
@@ -8,5 +8,5 @@ respawn
8 8
 
9 9
 script
10 10
     test -f /etc/default/locale && . /etc/default/locale || true
11
-    LANG=$LANG LC_ALL=$LANG /usr/local/bin/docker -d >> /var/log/dockerd 2>&1
11
+    LANG=$LANG LC_ALL=$LANG /opt/go/bin/docker -d >> /var/log/dockerd 2>&1
12 12
 end script
... ...
@@ -21,7 +21,10 @@ if [ -d "$HOME/bin" ] ; then
21 21
     PATH="$HOME/bin:$PATH"
22 22
 fi
23 23
 
24
-# set ~/docker as the go path
25
-export GOPATH=~/docker
26
-# add go to the PATH
27
-export PATH=$PATH:/usr/local/go/bin
28 24
\ No newline at end of file
25
+export GOPATH=/opt/go
26
+export PATH=$PATH:/usr/local/go/bin:$GOPATH/bin
27
+
28
+docker=/opt/go/src/github.com/dotcloud/docker
29
+if [ -d $docker ]; then
30
+  cd $docker
31
+fi