From 7009d6c6ddc2acc77e7caa227c08ecf29d747298 Mon Sep 17 00:00:00 2001 From: Mikhail Sobolev Date: Mon, 25 Mar 2013 23:48:46 +0200 Subject: [PATCH 01/21] introduce top-level Makefile to build the docker binary --- .gitignore | 1 + Makefile | 33 +++++++++++++++++++++++++++++++++ README.md | 16 ++++++++++++++++ 3 files changed, 50 insertions(+) create mode 100644 Makefile diff --git a/.gitignore b/.gitignore index cabd399067..809fa8e268 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,4 @@ command-line-arguments.test .flymake* docker.test auth/auth.test +build/ diff --git a/Makefile b/Makefile new file mode 100644 index 0000000000..82cbb2286d --- /dev/null +++ b/Makefile @@ -0,0 +1,33 @@ +DOCKER_PACKAGE := github.com/dotcloud/docker + +BUILD_DIR := $(CURDIR)/build + +GOPATH ?= $(BUILD_DIR) +export GOPATH + +SRC_DIR := $(GOPATH)/src + +DOCKER_DIR := $(SRC_DIR)/$(DOCKER_PACKAGE) +DOCKER_MAIN := $(DOCKER_DIR)/docker + +DOCKER_BIN := $(CURDIR)/bin/docker + +.PHONY: all clean + +all: $(DOCKER_BIN) + +$(DOCKER_BIN): $(DOCKER_DIR) + @mkdir -p $(dir $@) + (cd $(DOCKER_MAIN); go get; go build -o $@) + +$(DOCKER_DIR): + @mkdir -p $(dir $@) + @ln -sf $(CURDIR)/ $@ + +clean: + @rm -rf $(dir $(DOCKER_BIN)) +ifeq ($(GOPATH), $(BUILD_DIR)) + @rm -rf $(BUILD_DIR) +else ifneq ($(DOCKER_DIR), $(realpath $(DOCKER_DIR))) + @rm -f $(DOCKER_DIR) +endif diff --git a/README.md b/README.md index c955a1dcf2..0ff28ec101 100644 --- a/README.md +++ b/README.md @@ -53,6 +53,22 @@ Under the hood, Docker is built on the following components: Install instructions ================== +Building from source +-------------------- + +1. Make sure you have a [Go language](http://golang.org) compiler. + + On a Debian/wheezy or Ubuntu 12.10 install the package: + + ```bash + + $ sudo apt-get install golang-go + ``` + +2. Execute ``make`` + +3. Find your binary in ``bin/docker`` + Installing on Ubuntu 12.04 and 12.10 ------------------------------------ From 6b4bc971fd7ea03227f88b66168b884e2272aea6 Mon Sep 17 00:00:00 2001 From: Mikhail Sobolev Date: Tue, 26 Mar 2013 00:15:37 +0200 Subject: [PATCH 02/21] add a test target --- Makefile | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 82cbb2286d..3b8b1e9249 100644 --- a/Makefile +++ b/Makefile @@ -12,7 +12,7 @@ DOCKER_MAIN := $(DOCKER_DIR)/docker DOCKER_BIN := $(CURDIR)/bin/docker -.PHONY: all clean +.PHONY: all clean test all: $(DOCKER_BIN) @@ -31,3 +31,6 @@ ifeq ($(GOPATH), $(BUILD_DIR)) else ifneq ($(DOCKER_DIR), $(realpath $(DOCKER_DIR))) @rm -f $(DOCKER_DIR) endif + +test: all + (cd $(DOCKER_DIR); sudo -E go test) From a57b37ed0e1531e7cc7b8c91ecf73a904c067891 Mon Sep 17 00:00:00 2001 From: Mikhail Sobolev Date: Tue, 26 Mar 2013 02:23:36 +0200 Subject: [PATCH 03/21] use .gopath/ instead of build/ --- .gitignore | 2 +- Makefile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 809fa8e268..4bbbb2a127 100644 --- a/.gitignore +++ b/.gitignore @@ -9,4 +9,4 @@ command-line-arguments.test .flymake* docker.test auth/auth.test -build/ +.gopath/ diff --git a/Makefile b/Makefile index 3b8b1e9249..be67fcc232 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ DOCKER_PACKAGE := github.com/dotcloud/docker -BUILD_DIR := $(CURDIR)/build +BUILD_DIR := $(CURDIR)/.gopath GOPATH ?= $(BUILD_DIR) export GOPATH From 5a0010abe99869ffb4cb70917caa5ba35346e3e8 Mon Sep 17 00:00:00 2001 From: Mikhail Sobolev Date: Tue, 26 Mar 2013 08:21:10 +0200 Subject: [PATCH 04/21] do not print executed commands --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index be67fcc232..793b14d543 100644 --- a/Makefile +++ b/Makefile @@ -18,7 +18,7 @@ all: $(DOCKER_BIN) $(DOCKER_BIN): $(DOCKER_DIR) @mkdir -p $(dir $@) - (cd $(DOCKER_MAIN); go get; go build -o $@) + @(cd $(DOCKER_MAIN); go get; go build -o $@) $(DOCKER_DIR): @mkdir -p $(dir $@) @@ -33,4 +33,4 @@ else ifneq ($(DOCKER_DIR), $(realpath $(DOCKER_DIR))) endif test: all - (cd $(DOCKER_DIR); sudo -E go test) + @(cd $(DOCKER_DIR); sudo -E go test) From a26c58e27ef5ab1b017097fd8fc75d778d7c9eef Mon Sep 17 00:00:00 2001 From: Mikhail Sobolev Date: Tue, 26 Mar 2013 08:25:20 +0200 Subject: [PATCH 05/21] slightly re-phrase the build from source in README --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 0ff28ec101..247d763e30 100644 --- a/README.md +++ b/README.md @@ -67,7 +67,8 @@ Building from source 2. Execute ``make`` -3. Find your binary in ``bin/docker`` + This command will install all necessary dependencies and build the + executable that you can find in ``bin/docker`` Installing on Ubuntu 12.04 and 12.10 ------------------------------------ From 21f55419b73eaff72fe3383b4ee142b04e701372 Mon Sep 17 00:00:00 2001 From: Mikhail Sobolev Date: Tue, 26 Mar 2013 08:28:35 +0200 Subject: [PATCH 06/21] allow for verbose output from go tools --- Makefile | 9 +++++++-- README.md | 7 +++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 793b14d543..fa5b7a94a8 100644 --- a/Makefile +++ b/Makefile @@ -5,6 +5,11 @@ BUILD_DIR := $(CURDIR)/.gopath GOPATH ?= $(BUILD_DIR) export GOPATH +GO_OPTIONS ?= +ifeq ($(VERBOSE), 1) +GO_OPTIONS += -v +endif + SRC_DIR := $(GOPATH)/src DOCKER_DIR := $(SRC_DIR)/$(DOCKER_PACKAGE) @@ -18,7 +23,7 @@ all: $(DOCKER_BIN) $(DOCKER_BIN): $(DOCKER_DIR) @mkdir -p $(dir $@) - @(cd $(DOCKER_MAIN); go get; go build -o $@) + @(cd $(DOCKER_MAIN); go get $(GO_OPTIONS); go build $(GO_OPTIONS) -o $@) $(DOCKER_DIR): @mkdir -p $(dir $@) @@ -33,4 +38,4 @@ else ifneq ($(DOCKER_DIR), $(realpath $(DOCKER_DIR))) endif test: all - @(cd $(DOCKER_DIR); sudo -E go test) + @(cd $(DOCKER_DIR); sudo -E go test $(GO_OPTIONS)) diff --git a/README.md b/README.md index 247d763e30..3c3765fdc2 100644 --- a/README.md +++ b/README.md @@ -70,6 +70,13 @@ Building from source This command will install all necessary dependencies and build the executable that you can find in ``bin/docker`` +3. Should you like to see what's happening, run ``make`` with ``VERBOSE=1`` parameter: + + ```bash + + $ make VERBOSE=1 + ``` + Installing on Ubuntu 12.04 and 12.10 ------------------------------------ From f961ec55e72ae068c6153f2d20da5295d8d0a4c1 Mon Sep 17 00:00:00 2001 From: Mikhail Sobolev Date: Tue, 26 Mar 2013 16:30:01 +0200 Subject: [PATCH 07/21] print the location of the built binary --- Makefile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index fa5b7a94a8..e716762d31 100644 --- a/Makefile +++ b/Makefile @@ -15,7 +15,8 @@ SRC_DIR := $(GOPATH)/src DOCKER_DIR := $(SRC_DIR)/$(DOCKER_PACKAGE) DOCKER_MAIN := $(DOCKER_DIR)/docker -DOCKER_BIN := $(CURDIR)/bin/docker +DOCKER_BIN_RELATIVE := bin/docker +DOCKER_BIN := $(CURDIR)/$(DOCKER_BIN_RELATIVE) .PHONY: all clean test @@ -24,6 +25,7 @@ all: $(DOCKER_BIN) $(DOCKER_BIN): $(DOCKER_DIR) @mkdir -p $(dir $@) @(cd $(DOCKER_MAIN); go get $(GO_OPTIONS); go build $(GO_OPTIONS) -o $@) + @echo $(DOCKER_BIN_RELATIVE) is created. $(DOCKER_DIR): @mkdir -p $(dir $@) From 5cebc226cc0d734936a3d63e10027d46f39e8025 Mon Sep 17 00:00:00 2001 From: Charles Hooper Date: Tue, 26 Mar 2013 17:40:56 +0000 Subject: [PATCH 08/21] Use new AMI that won't cause issues with cloud-init apply_creds --- Vagrantfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Vagrantfile b/Vagrantfile index 4cf5f0a0e5..36f72b907e 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -119,8 +119,8 @@ end 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.ami = "ami-4a7de623" + aws.ssh_username = "ubuntu" aws.instance_type = "t1.micro" end config.vm.provider :virtualbox do |vb| From afdf29e57fe2213698645298c2381cab27baadc0 Mon Sep 17 00:00:00 2001 From: Charles Hooper Date: Tue, 26 Mar 2013 21:21:54 +0000 Subject: [PATCH 09/21] Fix issue where Vagrant AWS deploys outside of my dev account would fail --- Vagrantfile | 4 +-- puppet/modules/docker/manifests/init.pp | 42 +++++++++++++++++-------- 2 files changed, 31 insertions(+), 15 deletions(-) diff --git a/Vagrantfile b/Vagrantfile index 36f72b907e..db52a1e1b4 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -25,7 +25,7 @@ def v10(config) # Assign this VM to a bridged network, allowing you to connect directly to a # network using the host's network device. This makes the VM appear as another # physical device on your network. - # config.vm.network :bridged + #config.vm.network :bridged # Forward a port from the guest to the host, which allows for outside # computers to access the VM, whereas host only networking does not. @@ -119,7 +119,7 @@ end aws.keypair_name = ENV["AWS_KEYPAIR_NAME"] aws.ssh_private_key_path = ENV["AWS_SSH_PRIVKEY"] aws.region = "us-east-1" - aws.ami = "ami-4a7de623" + aws.ami = "ami-4e75ee27" aws.ssh_username = "ubuntu" aws.instance_type = "t1.micro" end diff --git a/puppet/modules/docker/manifests/init.pp b/puppet/modules/docker/manifests/init.pp index 6f8d249ff7..8f68435a49 100644 --- a/puppet/modules/docker/manifests/init.pp +++ b/puppet/modules/docker/manifests/init.pp @@ -1,12 +1,26 @@ class virtualbox { Package { ensure => "installed" } + user { "vagrant": + name => "vagrant", + ensure => present, + comment => "Vagrant User", + shell => "/bin/bash", + home => "/home/vagrant", + } + + file { "/home/vagrant": + mode => 644, + require => User["vagrant"], + } + # 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, + require => File["/home/vagrant"], } file { "/usr/local/bin/dockerd": ensure => absent, @@ -23,10 +37,21 @@ class virtualbox { } class ec2 { + user { "vagrant": + name => "ubuntu", + ensure => present, + comment => "Vagrant User", + shell => "/bin/bash", + home => "/home/ubuntu", + } + file { "/home/vagrant": + ensure => link, + target => "/home/ubuntu", + require => User["vagrant"], + } } class docker { - # update this with latest docker binary distro $docker_url = "http://get.docker.io/builds/$kernel/$hardwaremodel/docker-master.tgz" # update this with latest go binary distry @@ -44,19 +69,14 @@ class docker { $ec2_version = file("/etc/ec2_version", "/dev/null") if ($ec2_version) { + $vagrant_user = "ubuntu" include ec2 } else { + $vagrant_user = "vagrant" # 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, @@ -83,14 +103,10 @@ class docker { require => Exec["copy-docker-bin"], } - file { "/home/vagrant": - mode => 644, - require => User["vagrant"], - } file { "/home/vagrant/.profile": mode => 644, - owner => "vagrant", + owner => $vagrant_user, group => "ubuntu", content => template("docker/profile"), require => File["/home/vagrant"], From 2b7284db4f4c5b311eadd0432577bf0c263c2cce Mon Sep 17 00:00:00 2001 From: Charles Hooper Date: Wed, 27 Mar 2013 01:20:45 +0000 Subject: [PATCH 10/21] Remove duplicate user definition --- puppet/modules/docker/manifests/init.pp | 7 ------- 1 file changed, 7 deletions(-) diff --git a/puppet/modules/docker/manifests/init.pp b/puppet/modules/docker/manifests/init.pp index ee357ff2d5..8f8c04cd33 100644 --- a/puppet/modules/docker/manifests/init.pp +++ b/puppet/modules/docker/manifests/init.pp @@ -86,13 +86,6 @@ class docker { include virtualbox } - user { "vagrant": - ensure => present, - comment => "Vagrant User", - shell => "/bin/bash", - home => "/home/vagrant", - } - file { "/usr/local/bin": ensure => directory, owner => root, From 5bec4b8f040f366a5a1eed294d98e383d64b46e7 Mon Sep 17 00:00:00 2001 From: Charles Hooper Date: Wed, 27 Mar 2013 01:41:06 +0000 Subject: [PATCH 11/21] Fix Rackspace cloud user, remove dupe /home/vagrant definition --- puppet/modules/docker/manifests/init.pp | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/puppet/modules/docker/manifests/init.pp b/puppet/modules/docker/manifests/init.pp index 8f8c04cd33..843cd021f1 100644 --- a/puppet/modules/docker/manifests/init.pp +++ b/puppet/modules/docker/manifests/init.pp @@ -52,6 +52,18 @@ class ec2 { } class rax { + user { "vagrant": + name => "ubuntu", + ensure => present, + comment => "Vagrant User", + shell => "/bin/bash", + home => "/home/ubuntu", + } + file { "/home/vagrant": + ensure => link, + target => "/home/ubuntu", + require => User["vagrant"], + } } class docker { @@ -112,12 +124,6 @@ class docker { require => Exec["copy-docker-bin"], } - file { "/home/vagrant": - ensure => directory, - mode => 644, - require => User["vagrant"], - } - file { "/home/vagrant/.profile": mode => 644, owner => $vagrant_user, From 8461196a794d0ccd42b958fd93b833b7df9a8ca5 Mon Sep 17 00:00:00 2001 From: Charles Hooper Date: Wed, 27 Mar 2013 01:41:47 +0000 Subject: [PATCH 12/21] Stop using custom AMI and use standard Ubuntu AMI --- Vagrantfile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Vagrantfile b/Vagrantfile index 51614c5c20..37ad298b32 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -119,10 +119,11 @@ end aws.keypair_name = ENV["AWS_KEYPAIR_NAME"] aws.ssh_private_key_path = ENV["AWS_SSH_PRIVKEY"] aws.region = "us-east-1" - aws.ami = "ami-4e75ee27" + aws.ami = "ami-ae9806c7" aws.ssh_username = "ubuntu" aws.instance_type = "t1.micro" end + config.vm.provider :rackspace do |rs| config.vm.box = "dummy" config.vm.box_url = "https://github.com/mitchellh/vagrant-rackspace/raw/master/dummy.box" @@ -133,6 +134,7 @@ end rs.flavor = /512MB/ rs.image = /Ubuntu/ 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" From 7e4ac6c689a00760b38b32edd91f1885e2237cd5 Mon Sep 17 00:00:00 2001 From: Hunter Blanks Date: Tue, 26 Mar 2013 19:31:35 -0700 Subject: [PATCH 13/21] docs - remove references to run -a --- docs/sources/documentation/commandline/basecommands.rst | 2 +- docs/sources/documentation/installation/windows.rst | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/sources/documentation/commandline/basecommands.rst b/docs/sources/documentation/commandline/basecommands.rst index 180ad413a8..10b58ef1f8 100644 --- a/docs/sources/documentation/commandline/basecommands.rst +++ b/docs/sources/documentation/commandline/basecommands.rst @@ -17,7 +17,7 @@ Running an interactive shell # Run an interactive shell in the base image, # allocate a tty, attach stdin and stdout - docker run -a -i -t base /bin/bash + docker run -i -t base /bin/bash Starting a long-running worker process diff --git a/docs/sources/documentation/installation/windows.rst b/docs/sources/documentation/installation/windows.rst index 7c0b15be4b..f731531911 100644 --- a/docs/sources/documentation/installation/windows.rst +++ b/docs/sources/documentation/installation/windows.rst @@ -156,7 +156,7 @@ You are now ready for the docker’s “hello world” example. Run .. code-block:: bash - docker run -a busybox echo hello world + docker run busybox echo hello world .. image:: images/win/run_04.gif :alt: run docker From 4a086dfc0859fb3053925f1651d39056ef7dbfd6 Mon Sep 17 00:00:00 2001 From: Solomon Hykes Date: Tue, 26 Mar 2013 20:28:46 -0700 Subject: [PATCH 14/21] Fixed broken examples in docs --- docs/sources/documentation/commandline/basecommands.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/sources/documentation/commandline/basecommands.rst b/docs/sources/documentation/commandline/basecommands.rst index 10b58ef1f8..0189936bb9 100644 --- a/docs/sources/documentation/commandline/basecommands.rst +++ b/docs/sources/documentation/commandline/basecommands.rst @@ -26,10 +26,10 @@ Starting a long-running worker process .. code-block:: bash # Run docker in daemon mode - (docker -d || echo "Docker daemon already running") & + (sudo docker -d || echo "Docker daemon already running") & # Start a very useful long-running process - JOB=$(docker run base /bin/sh -c "while true; do echo Hello world!; sleep 1; done") + JOB=$(docker run -d base /bin/sh -c "while true; do echo Hello world; sleep 1; done") # Collect the output of the job so far docker logs $JOB @@ -51,7 +51,7 @@ Expose a service on a TCP port .. code-block:: bash # Expose port 4444 of this container, and tell netcat to listen on it - JOB=$(docker run -p 4444 base /bin/nc -l -p 4444) + JOB=$(docker run -d -p 4444 base /bin/nc -l -p 4444) # Which public port is NATed to my container? PORT=$(docker port $JOB 4444) From 43213dfc4a441ca347cd97ceca219e8e021f08ef Mon Sep 17 00:00:00 2001 From: Nelson Chen Date: Tue, 26 Mar 2013 23:14:50 -0700 Subject: [PATCH 15/21] use the directory where the vagrantfile is located for mounting --- Vagrantfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Vagrantfile b/Vagrantfile index 37ad298b32..884cb40a9b 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -37,7 +37,7 @@ def v10(config) # Share an additional folder to the guest VM. The first argument is # an identifier, the second is the path on the guest to mount the # folder, and the third is the path on the host to the actual folder. - config.vm.share_folder "v-data", "~/docker", "~/docker" + config.vm.share_folder "v-data", "~/docker", File.dirname(__FILE__) # Enable provisioning with Puppet stand alone. Puppet manifests # are contained in a directory path relative to this Vagrantfile. From ff04ce3ddfc5bcd681c580b0b4e739e8c737e5b9 Mon Sep 17 00:00:00 2001 From: Daniel Robinson Date: Wed, 27 Mar 2013 10:02:11 -0300 Subject: [PATCH 16/21] Fixed typo in command description for pull --- commands.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/commands.go b/commands.go index 3806323879..c769568536 100644 --- a/commands.go +++ b/commands.go @@ -43,7 +43,7 @@ func (srv *Server) Help() string { {"logs", "Fetch the logs of a container"}, {"port", "Lookup the public-facing port which is NAT-ed to PRIVATE_PORT"}, {"ps", "List containers"}, - {"pull", "Pull an image or a repository to the docker registry server"}, + {"pull", "Pull an image or a repository from the docker registry server"}, {"push", "Push an image or a repository to the docker registry server"}, {"restart", "Restart a running container"}, {"rm", "Remove a container"}, From 165a7f36709ad21d2e03c938855acf75a5a0c60a Mon Sep 17 00:00:00 2001 From: Ken Cochrane Date: Wed, 27 Mar 2013 10:43:05 -0300 Subject: [PATCH 17/21] change docker import to docker pull change docker import to docker pull in the basecommands doc --- docs/sources/documentation/commandline/basecommands.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/sources/documentation/commandline/basecommands.rst b/docs/sources/documentation/commandline/basecommands.rst index 0189936bb9..b065985059 100644 --- a/docs/sources/documentation/commandline/basecommands.rst +++ b/docs/sources/documentation/commandline/basecommands.rst @@ -13,7 +13,7 @@ Running an interactive shell .. code-block:: bash # Download a base image - docker import base + docker pull base # Run an interactive shell in the base image, # allocate a tty, attach stdin and stdout From 212a044a55394f7b79f02344d5ea4ee72ed787d5 Mon Sep 17 00:00:00 2001 From: Ken Cochrane Date: Wed, 27 Mar 2013 10:44:20 -0300 Subject: [PATCH 18/21] changed docker import to docker pull changed docker import to docker pull, still need to make sure that the image is in the registry. --- docs/sources/documentation/examples/python_web_app.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/sources/documentation/examples/python_web_app.rst b/docs/sources/documentation/examples/python_web_app.rst index 5b0ac30b63..922af29345 100644 --- a/docs/sources/documentation/examples/python_web_app.rst +++ b/docs/sources/documentation/examples/python_web_app.rst @@ -12,9 +12,9 @@ The goal of this example is to show you how you can author your own docker image .. code-block:: bash - $ docker import shykes/pybuilder + $ docker pull shykes/pybuilder -We are importing the "shykes/pybuilder" docker image +We are downloading the "shykes/pybuilder" docker image .. code-block:: bash From a3ab89df2b3d9ba654ba85af5d71d063d401f23f Mon Sep 17 00:00:00 2001 From: Jonathan Rudenberg Date: Wed, 27 Mar 2013 19:19:30 -0400 Subject: [PATCH 19/21] vagrant: Simplify provisioning to build from repo This sets up an idiomatic Go workspace in /opt/go with the source shared from the host directory in /opt/go/src/github.com/dotcloud/docker and docker installed into /opt/go --- .gitignore | 2 +- Vagrantfile | 97 +------------- puppet/modules/docker/manifests/init.pp | 131 ++++++------------- puppet/modules/docker/templates/dockerd.conf | 2 +- puppet/modules/docker/templates/profile | 11 +- 5 files changed, 55 insertions(+), 188 deletions(-) diff --git a/.gitignore b/.gitignore index be48820bbe..ffd5d11f91 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ -.vagrant +.vagrant* bin docker/docker .*.swp diff --git a/Vagrantfile b/Vagrantfile index 884cb40a9b..48b3ef567a 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -2,115 +2,30 @@ # vi: set ft=ruby : def v10(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. - - # Every Vagrant virtual environment requires a box to build off of. config.vm.box = "quantal64_3.5.0-25" - - # The url from where the 'config.vm.box' box will be fetched if it - # doesn't already exist on the user's system. config.vm.box_url = "http://get.docker.io/vbox/ubuntu/12.10/quantal64_3.5.0-25.box" - # Boot with a GUI so you can see the screen. (Default is headless) - # config.vm.boot_mode = :gui - - # Assign this VM to a host-only network IP, allowing you to access it - # via the IP. Host-only networks can talk to the host machine as well as - # any other machines on the same network, but cannot be accessed (through this - # network interface) by any external networks. - config.vm.network :hostonly, "192.168.33.10" - - # Assign this VM to a bridged network, allowing you to connect directly to a - # network using the host's network device. This makes the VM appear as another - # physical device on your network. - #config.vm.network :bridged - - # Forward a port from the guest to the host, which allows for outside - # computers to access the VM, whereas host only networking does not. - # config.vm.forward_port 80, 8080 + config.vm.share_folder "v-data", "/opt/go/src/github.com/dotcloud/docker", File.dirname(__FILE__) # Ensure puppet is installed on the instance config.vm.provision :shell, :inline => "apt-get -qq update; apt-get install -y puppet" - # Share an additional folder to the guest VM. The first argument is - # an identifier, the second is the path on the guest to mount the - # folder, and the third is the path on the host to the actual folder. - config.vm.share_folder "v-data", "~/docker", File.dirname(__FILE__) - - # Enable provisioning with Puppet stand alone. Puppet manifests - # are contained in a directory path relative to this Vagrantfile. - # You will need to create the manifests directory and a manifest in - # the file quantal64.pp in the manifests_path directory. - # - # An example Puppet manifest to provision the message of the day: - # - # # group { "puppet": - # # ensure => "present", - # # } - # # - # # File { owner => 0, group => 0, mode => 0644 } - # # - # # file { '/etc/motd': - # # content => "Welcome to your Vagrant-built virtual machine! - # # Managed by Puppet.\n" - # # } - # config.vm.provision :puppet do |puppet| puppet.manifests_path = "puppet/manifests" puppet.manifest_file = "quantal64.pp" puppet.module_path = "puppet/modules" end - - # Enable provisioning with chef solo, specifying a cookbooks path, roles - # path, and data_bags path (all relative to this Vagrantfile), and adding - # some recipes and/or roles. - # - # config.vm.provision :chef_solo do |chef| - # chef.cookbooks_path = "../my-recipes/cookbooks" - # chef.roles_path = "../my-recipes/roles" - # chef.data_bags_path = "../my-recipes/data_bags" - # chef.add_recipe "mysql" - # chef.add_role "web" - # - # # You may also specify custom JSON attributes: - # chef.json = { :mysql_password => "foo" } - # end - - # Enable provisioning with chef server, specifying the chef server URL, - # and the path to the validation key (relative to this Vagrantfile). - # - # The Opscode Platform uses HTTPS. Substitute your organization for - # ORGNAME in the URL and validation key. - # - # If you have your own Chef Server, use the appropriate URL, which may be - # HTTP instead of HTTPS depending on your configuration. Also change the - # validation key to validation.pem. - # - # config.vm.provision :chef_client do |chef| - # chef.chef_server_url = "https://api.opscode.com/organizations/ORGNAME" - # chef.validation_key_path = "ORGNAME-validator.pem" - # end - # - # If you're using the Opscode platform, your validator client is - # ORGNAME-validator, replacing ORGNAME with your organization name. - # - # IF you have your own Chef Server, the default validation client name is - # chef-validator, unless you changed the configuration. - # - # chef.validation_client_name = "ORGNAME-validator" end -"#{Vagrant::VERSION}" < "1.1.0" and Vagrant::Config.run do |config| +Vagrant::VERSION < "1.1.0" and Vagrant::Config.run do |config| v10(config) end -"#{Vagrant::VERSION}" >= "1.1.0" and Vagrant.configure("1") do |config| +Vagrant::VERSION >= "1.1.0" and Vagrant.configure("1") do |config| v10(config) end -"#{Vagrant::VERSION}" >= "1.1.0" and Vagrant.configure("2") do |config| +Vagrant::VERSION >= "1.1.0" and 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" @@ -130,10 +45,10 @@ end config.ssh.private_key_path = ENV["RS_PRIVATE_KEY"] rs.username = ENV["RS_USERNAME"] rs.api_key = ENV["RS_API_KEY"] - rs.public_key_path = ENV["RS_PUBLIC_KEY"] + rs.public_key_path = ENV["RS_PUBLIC_KEY"] rs.flavor = /512MB/ rs.image = /Ubuntu/ - end + end config.vm.provider :virtualbox do |vb| config.vm.box = "quantal64_3.5.0-25" diff --git a/puppet/modules/docker/manifests/init.pp b/puppet/modules/docker/manifests/init.pp index 843cd021f1..0de32a15f9 100644 --- a/puppet/modules/docker/manifests/init.pp +++ b/puppet/modules/docker/manifests/init.pp @@ -1,76 +1,29 @@ class virtualbox { - Package { ensure => "installed" } + Package { ensure => "installed" } - user { "vagrant": - name => "vagrant", - ensure => present, - comment => "Vagrant User", - shell => "/bin/bash", - home => "/home/vagrant", - } + # 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, + } - file { "/home/vagrant": - mode => 644, - require => User["vagrant"], - } - - # 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, - require => File["/home/vagrant"], - } - file { "/usr/local/bin/dockerd": - ensure => absent, - } - - # Set up VirtualBox guest utils - package { "virtualbox-guest-utils": } + # 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"], ], + Package["virtualbox-guest-utils"], + Package["linux-headers-3.5.0-25-generic"], ], } } -class ec2 { - user { "vagrant": - name => "ubuntu", - ensure => present, - comment => "Vagrant User", - shell => "/bin/bash", - home => "/home/ubuntu", - } - file { "/home/vagrant": - ensure => link, - target => "/home/ubuntu", - require => User["vagrant"], - } -} - -class rax { - user { "vagrant": - name => "ubuntu", - ensure => present, - comment => "Vagrant User", - shell => "/bin/bash", - home => "/home/ubuntu", - } - file { "/home/vagrant": - ensure => link, - target => "/home/ubuntu", - require => User["vagrant"], - } -} - class docker { - - # update this with latest docker binary distro - $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 dist $go_url = "http://go.googlecode.com/files/go1.0.3.linux-amd64.tar.gz" Package { ensure => "installed" } @@ -81,67 +34,63 @@ class docker { "linux-image-extra-3.5.0-25-generic", "linux-headers-3.5.0-25-generic"]: } - notify { "docker_url = $docker_url": withpath => true } - $ec2_version = file("/etc/ec2_version", "/dev/null") $rax_version = inline_template("<%= %x{/usr/bin/xenstore-read vm-data/provider_data/provider} %>") if ($ec2_version) { - $vagrant_user = "ubuntu" - include ec2 + $vagrant_user = "ubuntu" + $vagrant_home = "/home/ubuntu" } elsif ($rax_version) { - $vagrant_user = "vagrant" - include rax + $vagrant_user = "root" + $vagrant_home = "/root" } else { - # virtualbox is the vagrant default, so it should be safe to assume - $vagrant_user = "vagrant" + # virtualbox is the vagrant default, so it should be safe to assume + $vagrant_user = "vagrant" + $vagrant_home = "/home/vagrant" include virtualbox } - 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", creates => "/usr/local/go/bin/go", } - exec { "fetch-docker" : - command => "/usr/bin/wget -O - $docker_url | /bin/tar xz -C /tmp", - require => Package["wget"], - } - file { "/etc/init/dockerd.conf": mode => 600, owner => "root", group => "root", content => template("docker/dockerd.conf"), - require => Exec["copy-docker-bin"], } - file { "/home/vagrant/.profile": + file { "/opt/go": + owner => $vagrant_user, + group => $vagrant_user, + recurse => true, + } + + file { "${vagrant_home}/.profile": mode => 644, owner => $vagrant_user, - group => "ubuntu", + group => $vagrant_user, content => template("docker/profile"), - require => File["/home/vagrant"], } - exec { "copy-docker-bin" : - command => "/usr/bin/sudo /bin/cp -f /tmp/docker-master/docker /usr/local/bin/", - require => [ Exec["fetch-docker"], File["/usr/local/bin"] ], + exec { "build-docker" : + cwd => "/opt/go/src/github.com/dotcloud/docker", + user => $vagrant_user, + environment => "GOPATH=/opt/go", + command => "/usr/local/go/bin/go get -v ./... && /usr/local/go/bin/go install ./docker", + creates => "/opt/go/bin/docker", + logoutput => "on_failure", + require => [ Exec["fetch-go"], File["/opt/go"] ], } service { "dockerd" : ensure => "running", start => "/sbin/initctl start dockerd", stop => "/sbin/initctl stop dockerd", - require => File["/etc/init/dockerd.conf"], + require => [ Exec["build-docker"], File["/etc/init/dockerd.conf"] ], name => "dockerd", provider => "base" } diff --git a/puppet/modules/docker/templates/dockerd.conf b/puppet/modules/docker/templates/dockerd.conf index f88d5c347f..3abb798c2b 100644 --- a/puppet/modules/docker/templates/dockerd.conf +++ b/puppet/modules/docker/templates/dockerd.conf @@ -8,5 +8,5 @@ respawn script test -f /etc/default/locale && . /etc/default/locale || true - LANG=$LANG LC_ALL=$LANG /usr/local/bin/docker -d >> /var/log/dockerd 2>&1 + LANG=$LANG LC_ALL=$LANG /opt/go/bin/docker -d >> /var/log/dockerd 2>&1 end script diff --git a/puppet/modules/docker/templates/profile b/puppet/modules/docker/templates/profile index c52d87387c..319c9c5be8 100644 --- a/puppet/modules/docker/templates/profile +++ b/puppet/modules/docker/templates/profile @@ -21,7 +21,10 @@ if [ -d "$HOME/bin" ] ; then PATH="$HOME/bin:$PATH" fi -# set ~/docker as the go path -export GOPATH=~/docker -# add go to the PATH -export PATH=$PATH:/usr/local/go/bin \ No newline at end of file +export GOPATH=/opt/go +export PATH=$PATH:/usr/local/go/bin:$GOPATH/bin + +docker=/opt/go/src/github.com/dotcloud/docker +if [ -d $docker ]; then + cd $docker +fi From fa89076673bd734cebff88717bf79461ecf8d505 Mon Sep 17 00:00:00 2001 From: Charles Hooper Date: Thu, 28 Mar 2013 05:28:11 +0000 Subject: [PATCH 20/21] Remove /usr/local/bin/docker --- puppet/modules/docker/manifests/init.pp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/puppet/modules/docker/manifests/init.pp b/puppet/modules/docker/manifests/init.pp index 0de32a15f9..6f7aec9001 100644 --- a/puppet/modules/docker/manifests/init.pp +++ b/puppet/modules/docker/manifests/init.pp @@ -11,6 +11,9 @@ class virtualbox { file { "/usr/local/bin/dockerd": ensure => absent, } + file { "/usr/local/bin/docker": + ensure => absent, + } # Set up VirtualBox guest utils package { "virtualbox-guest-utils": } From b3cbe87b62f00d0dcc207d4562c9dde99a708366 Mon Sep 17 00:00:00 2001 From: mynamewastaken Date: Thu, 28 Mar 2013 02:55:28 -0500 Subject: [PATCH 21/21] Update README.md Fixed typo --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 9cf3daf6a2..7fcfa4c360 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ Notable features * Network isolation: each process container runs in its own network namespace, with a virtual interface and IP address of its own. -* Copy-on-write: root filesystems are created using copy-on-write, which makes deployment extremeley fast, memory-cheap and disk-cheap. +* Copy-on-write: root filesystems are created using copy-on-write, which makes deployment extremely fast, memory-cheap and disk-cheap. * Logging: the standard streams (stdout/stderr/stdin) of each process container are collected and logged for real-time or batch retrieval.