├── .gitignore ├── LICENSE ├── README.md ├── docker.go ├── main.go ├── src ├── github.com │ ├── dotcloud │ │ └── docker │ │ │ ├── .gitignore │ │ │ ├── .mailmap │ │ │ ├── AUTHORS │ │ │ ├── CHANGELOG.md │ │ │ ├── CONTRIBUTING.md │ │ │ ├── FIXME │ │ │ ├── LICENSE │ │ │ ├── MAINTAINERS │ │ │ ├── Makefile │ │ │ ├── NOTICE │ │ │ ├── README.md │ │ │ ├── Vagrantfile │ │ │ ├── api.go │ │ │ ├── api_params.go │ │ │ ├── api_test.go │ │ │ ├── archive.go │ │ │ ├── archive_test.go │ │ │ ├── auth │ │ │ ├── MAINTAINERS │ │ │ ├── auth.go │ │ │ └── auth_test.go │ │ │ ├── builder.go │ │ │ ├── builder_client.go │ │ │ ├── buildfile.go │ │ │ ├── buildfile_test.go │ │ │ ├── changes.go │ │ │ ├── commands.go │ │ │ ├── commands_test.go │ │ │ ├── container.go │ │ │ ├── container_test.go │ │ │ ├── contrib │ │ │ ├── MAINTAINERS │ │ │ ├── README │ │ │ ├── crashTest.go │ │ │ ├── install.sh │ │ │ ├── mkimage-busybox.sh │ │ │ ├── mkimage-debian.sh │ │ │ └── vagrant-docker │ │ │ │ └── README.md │ │ │ ├── docker │ │ │ └── docker.go │ │ │ ├── docs │ │ │ ├── MAINTAINERS │ │ │ ├── Makefile │ │ │ ├── README.md │ │ │ ├── requirements.txt │ │ │ ├── sources │ │ │ │ ├── api │ │ │ │ │ ├── MAINTAINERS │ │ │ │ │ ├── README.md │ │ │ │ │ ├── docker_remote_api.rst │ │ │ │ │ ├── docker_remote_api_v1.0.rst │ │ │ │ │ ├── docker_remote_api_v1.1.rst │ │ │ │ │ ├── docker_remote_api_v1.2.rst │ │ │ │ │ ├── index.rst │ │ │ │ │ ├── index_api.rst │ │ │ │ │ ├── registry_api.rst │ │ │ │ │ └── registry_index_spec.rst │ │ │ │ ├── commandline │ │ │ │ │ ├── cli.rst │ │ │ │ │ ├── command │ │ │ │ │ │ ├── attach.rst │ │ │ │ │ │ ├── build.rst │ │ │ │ │ │ ├── commit.rst │ │ │ │ │ │ ├── diff.rst │ │ │ │ │ │ ├── export.rst │ │ │ │ │ │ ├── history.rst │ │ │ │ │ │ ├── images.rst │ │ │ │ │ │ ├── images │ │ │ │ │ │ │ └── docker_images.gif │ │ │ │ │ │ ├── import.rst │ │ │ │ │ │ ├── info.rst │ │ │ │ │ │ ├── inspect.rst │ │ │ │ │ │ ├── kill.rst │ │ │ │ │ │ ├── login.rst │ │ │ │ │ │ ├── logs.rst │ │ │ │ │ │ ├── port.rst │ │ │ │ │ │ ├── ps.rst │ │ │ │ │ │ ├── pull.rst │ │ │ │ │ │ ├── push.rst │ │ │ │ │ │ ├── restart.rst │ │ │ │ │ │ ├── rm.rst │ │ │ │ │ │ ├── rmi.rst │ │ │ │ │ │ ├── run.rst │ │ │ │ │ │ ├── search.rst │ │ │ │ │ │ ├── start.rst │ │ │ │ │ │ ├── stop.rst │ │ │ │ │ │ ├── tag.rst │ │ │ │ │ │ ├── version.rst │ │ │ │ │ │ └── wait.rst │ │ │ │ │ └── index.rst │ │ │ │ ├── concepts │ │ │ │ │ ├── containers.rst │ │ │ │ │ ├── images │ │ │ │ │ │ └── lego_docker.jpg │ │ │ │ │ ├── index.rst │ │ │ │ │ └── introduction.rst │ │ │ │ ├── conf.py │ │ │ │ ├── contributing │ │ │ │ │ ├── contributing.rst │ │ │ │ │ ├── devenvironment.rst │ │ │ │ │ └── index.rst │ │ │ │ ├── examples │ │ │ │ │ ├── couchdb_data_volumes.rst │ │ │ │ │ ├── example_header.inc │ │ │ │ │ ├── hello_world.rst │ │ │ │ │ ├── hello_world_daemon.rst │ │ │ │ │ ├── index.rst │ │ │ │ │ ├── nodejs_web_app.rst │ │ │ │ │ ├── python_web_app.rst │ │ │ │ │ ├── running_examples.rst │ │ │ │ │ ├── running_redis_service.rst │ │ │ │ │ └── running_ssh_service.rst │ │ │ │ ├── faq.rst │ │ │ │ ├── index.rst │ │ │ │ ├── index │ │ │ │ │ └── variable.rst │ │ │ │ ├── installation │ │ │ │ │ ├── amazon.rst │ │ │ │ │ ├── archlinux.rst │ │ │ │ │ ├── binaries.rst │ │ │ │ │ ├── images │ │ │ │ │ │ └── win │ │ │ │ │ │ │ ├── _01.gif │ │ │ │ │ │ │ ├── _02.gif │ │ │ │ │ │ │ ├── _06.gif │ │ │ │ │ │ │ ├── cygwin.gif │ │ │ │ │ │ │ ├── putty.gif │ │ │ │ │ │ │ ├── putty_2.gif │ │ │ │ │ │ │ ├── run_02_.gif │ │ │ │ │ │ │ ├── run_03.gif │ │ │ │ │ │ │ ├── run_04.gif │ │ │ │ │ │ │ └── ssh-config.gif │ │ │ │ │ ├── index.rst │ │ │ │ │ ├── kernel.rst │ │ │ │ │ ├── rackspace.rst │ │ │ │ │ ├── ubuntulinux.rst │ │ │ │ │ ├── upgrading.rst │ │ │ │ │ ├── vagrant.rst │ │ │ │ │ └── windows.rst │ │ │ │ ├── static_files │ │ │ │ │ ├── README.md │ │ │ │ │ ├── docker_pull_chart.png │ │ │ │ │ └── docker_push_chart.png │ │ │ │ ├── toctree.rst │ │ │ │ └── use │ │ │ │ │ ├── basics.rst │ │ │ │ │ ├── builder.rst │ │ │ │ │ ├── index.rst │ │ │ │ │ ├── puppet.rst │ │ │ │ │ └── workingwithrepository.rst │ │ │ ├── theme │ │ │ │ ├── MAINTAINERS │ │ │ │ └── docker │ │ │ │ │ ├── layout.html │ │ │ │ │ ├── static │ │ │ │ │ ├── css │ │ │ │ │ │ ├── bootstrap-responsive.css │ │ │ │ │ │ ├── bootstrap-responsive.min.css │ │ │ │ │ │ ├── bootstrap.css │ │ │ │ │ │ ├── bootstrap.min.css │ │ │ │ │ │ ├── main.css │ │ │ │ │ │ ├── main.less │ │ │ │ │ │ ├── variables.css │ │ │ │ │ │ └── variables.less │ │ │ │ │ ├── favicon.ico │ │ │ │ │ ├── img │ │ │ │ │ │ ├── docker-letters-logo.gif │ │ │ │ │ │ ├── docker_letters_500px.png │ │ │ │ │ │ ├── docs-splash-colhead320.png │ │ │ │ │ │ ├── footer-links.png │ │ │ │ │ │ ├── fork-us.png │ │ │ │ │ │ ├── glyphicons-halflings-white.png │ │ │ │ │ │ ├── glyphicons-halflings.png │ │ │ │ │ │ └── hiring_graphic.png │ │ │ │ │ └── js │ │ │ │ │ │ ├── docs.js │ │ │ │ │ │ ├── jquery.ba-bbq.min.js │ │ │ │ │ │ ├── jquery.ba-urlinternal.min.js │ │ │ │ │ │ ├── main.js │ │ │ │ │ │ └── vendor │ │ │ │ │ │ ├── bootstrap.js │ │ │ │ │ │ ├── bootstrap.min.js │ │ │ │ │ │ ├── jquery-1.9.1.min.js │ │ │ │ │ │ └── modernizr-2.6.2-respond-1.1.0.min.js │ │ │ │ │ └── theme.conf │ │ │ └── website │ │ │ │ ├── MAINTAINERS │ │ │ │ ├── dotcloud.yml │ │ │ │ ├── gettingstarted │ │ │ │ └── index.html │ │ │ │ ├── index.html │ │ │ │ ├── nginx.conf │ │ │ │ └── static │ │ │ ├── getKernelVersion_darwin.go │ │ │ ├── getKernelVersion_linux.go │ │ │ ├── graph.go │ │ │ ├── graph_test.go │ │ │ ├── hack │ │ │ ├── PRINCIPLES.md │ │ │ ├── README.rst │ │ │ ├── ROADMAP.md │ │ │ ├── Vagrantfile │ │ │ ├── allmaintainers.sh │ │ │ ├── dockerbuilder │ │ │ │ ├── Dockerfile │ │ │ │ ├── MAINTAINERS │ │ │ │ ├── dockerbuilder │ │ │ │ └── s3cfg │ │ │ ├── environment │ │ │ │ ├── README.rst │ │ │ │ ├── bash_profile │ │ │ │ ├── buildbot.conf │ │ │ │ ├── master.cfg │ │ │ │ ├── post-commit │ │ │ │ ├── requirements.txt │ │ │ │ └── setup.sh │ │ │ ├── fmt-check.hook │ │ │ ├── getmaintainer.sh │ │ │ └── infrastructure │ │ │ │ ├── MAINTAINERS │ │ │ │ └── README.md │ │ │ ├── image.go │ │ │ ├── lxc_template.go │ │ │ ├── mount.go │ │ │ ├── mount_darwin.go │ │ │ ├── mount_linux.go │ │ │ ├── network.go │ │ │ ├── network_test.go │ │ │ ├── packaging │ │ │ ├── MAINTAINERS │ │ │ ├── README.rst │ │ │ ├── archlinux │ │ │ │ └── README.archlinux │ │ │ ├── debian │ │ │ │ ├── Makefile │ │ │ │ ├── README.Debian │ │ │ │ ├── Vagrantfile │ │ │ │ ├── changelog │ │ │ │ ├── compat │ │ │ │ ├── control │ │ │ │ ├── copyright │ │ │ │ ├── docs │ │ │ │ ├── lxc-docker.1 │ │ │ │ ├── lxc-docker.init │ │ │ │ ├── maintainer.rst │ │ │ │ ├── rules │ │ │ │ └── source │ │ │ │ │ └── format │ │ │ └── ubuntu │ │ │ │ ├── Makefile │ │ │ │ ├── README.ubuntu │ │ │ │ ├── Vagrantfile │ │ │ │ ├── changelog │ │ │ │ ├── compat │ │ │ │ ├── control │ │ │ │ ├── copyright │ │ │ │ ├── docker.upstart │ │ │ │ ├── docs │ │ │ │ ├── lxc-docker.postinst │ │ │ │ ├── lxc-docker.prerm │ │ │ │ ├── maintainer.ubuntu │ │ │ │ ├── rules │ │ │ │ └── source │ │ │ │ └── format │ │ │ ├── registry │ │ │ ├── MAINTAINERS │ │ │ ├── registry.go │ │ │ └── registry_test.go │ │ │ ├── runtime.go │ │ │ ├── runtime_test.go │ │ │ ├── server.go │ │ │ ├── server_test.go │ │ │ ├── state.go │ │ │ ├── sysinit.go │ │ │ ├── tags.go │ │ │ ├── tags_test.go │ │ │ ├── term │ │ │ ├── MAINTAINERS │ │ │ ├── term.go │ │ │ ├── termios_darwin.go │ │ │ └── termios_linux.go │ │ │ ├── testing │ │ │ ├── MAINTAINERS │ │ │ ├── README.rst │ │ │ ├── Vagrantfile │ │ │ └── buildbot │ │ │ │ ├── README.rst │ │ │ │ ├── buildbot.conf │ │ │ │ ├── master.cfg │ │ │ │ ├── requirements.txt │ │ │ │ └── setup.sh │ │ │ ├── utils.go │ │ │ └── utils │ │ │ ├── uname_darwin.go │ │ │ ├── uname_linux.go │ │ │ ├── utils.go │ │ │ └── utils_test.go │ ├── gorilla │ │ ├── context │ │ │ ├── LICENSE │ │ │ ├── README.md │ │ │ ├── context.go │ │ │ ├── context_test.go │ │ │ └── doc.go │ │ └── mux │ │ │ ├── LICENSE │ │ │ ├── README.md │ │ │ ├── bench_test.go │ │ │ ├── doc.go │ │ │ ├── mux.go │ │ │ ├── mux_test.go │ │ │ ├── old_test.go │ │ │ ├── regexp.go │ │ │ └── route.go │ ├── kr │ │ └── pty │ │ │ ├── .gitignore │ │ │ ├── License │ │ │ ├── README.md │ │ │ ├── doc.go │ │ │ ├── pty_darwin.go │ │ │ ├── pty_linux.go │ │ │ ├── run.go │ │ │ └── util.go │ ├── philips │ │ └── go-systemd │ │ │ └── systemd.go │ └── shin- │ │ └── cookiejar │ │ └── jar.go └── launchpad.net │ └── go-dbus │ ├── .gitignore │ ├── LICENSE │ ├── README.markdown │ ├── auth.go │ ├── auth_test.go │ ├── dbus.go │ ├── dbus_test.go │ ├── decoder.go │ ├── decoder_test.go │ ├── encoder.go │ ├── encoder_test.go │ ├── introspect.go │ ├── introspect_test.go │ ├── matchrule.go │ ├── matchrule_test.go │ ├── message.go │ ├── message_test.go │ ├── names.go │ ├── names_test.go │ ├── proxy.go │ ├── signal.go │ ├── signal_test.go │ ├── suite_test.go │ ├── transport.go │ ├── transport_test.go │ ├── types.go │ └── types_test.go ├── units.go └── update.go /.gitignore: -------------------------------------------------------------------------------- 1 | pkg/* 2 | systemd-rest 3 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## Usage 2 | 3 | ### Controlling Units 4 | 5 | ``` 6 | curl -v http://127.0.0.1:8080/units/dnsmasq.service/start/replace 7 | curl http://127.0.0.1:8080/units/dnsmasq.service/stop/replace 8 | ``` 9 | 10 | ### Pulling images from a registry 11 | 12 | ``` 13 | curl localhost:8080/docker/registry/pull/busybox 14 | curl -F "image=busybox" localhost:8080/docker/container/create/busybox 15 | systemd-nspawn -b -D /var/lib/containers/busybox 16 | ``` 17 | -------------------------------------------------------------------------------- /main.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013 CoreOS, Inc 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package main 18 | 19 | import ( 20 | "flag" 21 | "github.com/gorilla/mux" 22 | "log" 23 | "net/http" 24 | ) 25 | 26 | type Options struct { 27 | Dir string 28 | Port string 29 | } 30 | 31 | var options = Options{} 32 | 33 | func init() { 34 | const ( 35 | defaultDir = "/" 36 | defaultPort = "8080" 37 | ) 38 | 39 | flag.StringVar(&options.Dir, "D", defaultDir, "Directory prefix (default /)") 40 | flag.StringVar(&options.Port, "p", defaultPort, "Port to bind to") 41 | } 42 | 43 | const StateDir = "/var/lib/systemd-rest/" 44 | 45 | func main() { 46 | flag.Parse() 47 | 48 | r := mux.NewRouter() 49 | 50 | setupUnits(r.PathPrefix("/units").Subrouter(), options) 51 | setupDocker(r.PathPrefix("/docker").Subrouter(), options) 52 | setupUpdate(r.PathPrefix("/update").Subrouter(), options) 53 | 54 | http.Handle("/", r) 55 | err := http.ListenAndServe(":"+options.Port, nil) 56 | if err != nil { 57 | log.Fatal("ListenAndServe: ", err) 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /src/github.com/dotcloud/docker/.gitignore: -------------------------------------------------------------------------------- 1 | .vagrant* 2 | bin 3 | docker/docker 4 | .*.swp 5 | a.out 6 | *.orig 7 | build_src 8 | command-line-arguments.test 9 | .flymake* 10 | docker.test 11 | auth/auth.test 12 | .idea 13 | .DS_Store 14 | docs/_build 15 | docs/_static 16 | docs/_templates 17 | .gopath/ 18 | -------------------------------------------------------------------------------- /src/github.com/dotcloud/docker/.mailmap: -------------------------------------------------------------------------------- 1 | # Generate AUTHORS: git log --all --format='%aN <%aE>' | sort -uf | grep -v vagrant-ubuntu-12 2 | 3 | 4 | 5 | Guillaume J. Charmes 6 | 7 | 8 | 9 | Thatcher Peskens dhrp 10 | Thatcher Peskens dhrp 11 | Jérôme Petazzoni jpetazzo 12 | Jérôme Petazzoni 13 | Joffrey F 14 | 15 | Tim Terhorst 16 | Andy Smith 17 | 18 | 19 | 20 | 21 | Thatcher Peskens 22 | -------------------------------------------------------------------------------- /src/github.com/dotcloud/docker/AUTHORS: -------------------------------------------------------------------------------- 1 | # This file lists all individuals having contributed content to the repository. 2 | # If you're submitting a patch, please add your name here in alphabetical order as part of the patch. 3 | # 4 | # For a list of active project maintainers, see the MAINTAINERS file. 5 | # 6 | Al Tobey 7 | Alexey Shamrin 8 | Andrea Luzzardi 9 | Andy Rothfusz 10 | Andy Smith 11 | Antony Messerli 12 | Barry Allard 13 | Brandon Liu 14 | Brian McCallister 15 | Bruno Bigras 16 | Caleb Spare 17 | Charles Hooper 18 | Daniel Gasienica 19 | Daniel Mizyrycki 20 | Daniel Robinson 21 | Daniel Von Fange 22 | Dominik Honnef 23 | Don Spaulding 24 | Dr Nic Williams 25 | Evan Wies 26 | ezbercih 27 | Flavio Castelli 28 | Francisco Souza 29 | Frederick F. Kautz IV 30 | Guillaume J. Charmes 31 | Harley Laue 32 | Hunter Blanks 33 | Jeff Lindsay 34 | Jeremy Grosser 35 | Joffrey F 36 | John Costa 37 | Jonas Pfenniger 38 | Jonathan Rudenberg 39 | Julien Barbier 40 | Jérôme Petazzoni 41 | Ken Cochrane 42 | Kevin J. Lynagh 43 | Louis Opter 44 | Maxim Treskin 45 | Michael Crosby 46 | Mikhail Sobolev 47 | Nate Jones 48 | Nelson Chen 49 | Niall O'Higgins 50 | odk- 51 | Paul Bowsher 52 | Paul Hammond 53 | Piotr Bogdan 54 | Robert Obryk 55 | Sam Alba 56 | Shawn Siefkas 57 | Silas Sewell 58 | Solomon Hykes 59 | Sridhar Ratnakumar 60 | Thatcher Peskens 61 | Thomas Bikeev 62 | Tianon Gravi 63 | Tim Terhorst 64 | Troy Howard 65 | unclejack 66 | Victor Vieux 67 | Vivek Agarwal 68 | -------------------------------------------------------------------------------- /src/github.com/dotcloud/docker/FIXME: -------------------------------------------------------------------------------- 1 | 2 | ## FIXME 3 | 4 | This file is a loose collection of things to improve in the codebase, for the internal 5 | use of the maintainers. 6 | 7 | They are not big enough to be in the roadmap, not user-facing enough to be github issues, 8 | and not important enough to be discussed in the mailing list. 9 | 10 | They are just like FIXME comments in the source code, except we're not sure where in the source 11 | to put them - so we put them here :) 12 | 13 | 14 | * Merge Runtime, Server and Builder into Runtime 15 | * Run linter on codebase 16 | * Unify build commands and regular commands 17 | * Move source code into src/ subdir for clarity 18 | * Clean up the Makefile, it's a mess 19 | -------------------------------------------------------------------------------- /src/github.com/dotcloud/docker/MAINTAINERS: -------------------------------------------------------------------------------- 1 | Solomon Hykes 2 | Guillaume Charmes 3 | Victor Vieux 4 | api.go: Victor Vieux 5 | Vagrantfile: Daniel Mizyrycki 6 | -------------------------------------------------------------------------------- /src/github.com/dotcloud/docker/Makefile: -------------------------------------------------------------------------------- 1 | DOCKER_PACKAGE := github.com/dotcloud/docker 2 | RELEASE_VERSION := $(shell git tag | grep -E "v[0-9\.]+$$" | sort -nr | head -n 1) 3 | SRCRELEASE := docker-$(RELEASE_VERSION) 4 | BINRELEASE := docker-$(RELEASE_VERSION).tgz 5 | 6 | GIT_ROOT := $(shell git rev-parse --show-toplevel) 7 | BUILD_DIR := $(CURDIR)/.gopath 8 | 9 | GOPATH ?= $(BUILD_DIR) 10 | export GOPATH 11 | 12 | GO_OPTIONS ?= 13 | ifeq ($(VERBOSE), 1) 14 | GO_OPTIONS += -v 15 | endif 16 | 17 | GIT_COMMIT = $(shell git rev-parse --short HEAD) 18 | GIT_STATUS = $(shell test -n "`git status --porcelain`" && echo "+CHANGES") 19 | 20 | BUILD_OPTIONS = -ldflags "-X main.GIT_COMMIT $(GIT_COMMIT)$(GIT_STATUS)" 21 | 22 | SRC_DIR := $(GOPATH)/src 23 | 24 | DOCKER_DIR := $(SRC_DIR)/$(DOCKER_PACKAGE) 25 | DOCKER_MAIN := $(DOCKER_DIR)/docker 26 | 27 | DOCKER_BIN_RELATIVE := bin/docker 28 | DOCKER_BIN := $(CURDIR)/$(DOCKER_BIN_RELATIVE) 29 | 30 | .PHONY: all clean test hack release srcrelease $(BINRELEASE) $(SRCRELEASE) $(DOCKER_BIN) $(DOCKER_DIR) 31 | 32 | all: $(DOCKER_BIN) 33 | 34 | $(DOCKER_BIN): $(DOCKER_DIR) 35 | @mkdir -p $(dir $@) 36 | @(cd $(DOCKER_MAIN); go build $(GO_OPTIONS) $(BUILD_OPTIONS) -o $@) 37 | @echo $(DOCKER_BIN_RELATIVE) is created. 38 | 39 | $(DOCKER_DIR): 40 | @mkdir -p $(dir $@) 41 | @if [ -h $@ ]; then rm -f $@; fi; ln -sf $(CURDIR)/ $@ 42 | @(cd $(DOCKER_MAIN); go get -d $(GO_OPTIONS)) 43 | 44 | whichrelease: 45 | echo $(RELEASE_VERSION) 46 | 47 | release: $(BINRELEASE) 48 | s3cmd -P put $(BINRELEASE) s3://get.docker.io/builds/`uname -s`/`uname -m`/docker-$(RELEASE_VERSION).tgz 49 | 50 | srcrelease: $(SRCRELEASE) 51 | deps: $(DOCKER_DIR) 52 | 53 | # A clean checkout of $RELEASE_VERSION, with vendored dependencies 54 | $(SRCRELEASE): 55 | rm -fr $(SRCRELEASE) 56 | git clone $(GIT_ROOT) $(SRCRELEASE) 57 | cd $(SRCRELEASE); git checkout -q $(RELEASE_VERSION) 58 | 59 | # A binary release ready to be uploaded to a mirror 60 | $(BINRELEASE): $(SRCRELEASE) 61 | rm -f $(BINRELEASE) 62 | cd $(SRCRELEASE); make; cp -R bin docker-$(RELEASE_VERSION); tar -f ../$(BINRELEASE) -zv -c docker-$(RELEASE_VERSION) 63 | 64 | clean: 65 | @rm -rf $(dir $(DOCKER_BIN)) 66 | ifeq ($(GOPATH), $(BUILD_DIR)) 67 | @rm -rf $(BUILD_DIR) 68 | else ifneq ($(DOCKER_DIR), $(realpath $(DOCKER_DIR))) 69 | @rm -f $(DOCKER_DIR) 70 | endif 71 | 72 | test: all 73 | @(cd $(DOCKER_DIR); sudo -E go test $(GO_OPTIONS)) 74 | 75 | fmt: 76 | @gofmt -s -l -w . 77 | 78 | hack: 79 | cd $(CURDIR)/hack && vagrant up 80 | 81 | ssh-dev: 82 | cd $(CURDIR)/hack && vagrant ssh 83 | -------------------------------------------------------------------------------- /src/github.com/dotcloud/docker/NOTICE: -------------------------------------------------------------------------------- 1 | Docker 2 | Copyright 2012-2013 dotCloud, inc. 3 | 4 | This product includes software developed at dotCloud, inc. (http://www.dotcloud.com). 5 | 6 | This product contains software (https://github.com/kr/pty) developed by Keith Rarick, licensed under the MIT License. 7 | 8 | Transfers of Docker shall be in accordance with applicable export controls of any country and all other applicable 9 | legal requirements. Docker shall not be distributed or downloaded to or in Cuba, Iran, North Korea, Sudan or Syria 10 | and shall not be distributed or downloaded to any person on the Denied Persons List administered by the U.S. 11 | Department of Commerce. 12 | -------------------------------------------------------------------------------- /src/github.com/dotcloud/docker/api_params.go: -------------------------------------------------------------------------------- 1 | package docker 2 | 3 | type APIHistory struct { 4 | ID string `json:"Id"` 5 | Created int64 6 | CreatedBy string `json:",omitempty"` 7 | } 8 | 9 | type APIImages struct { 10 | Repository string `json:",omitempty"` 11 | Tag string `json:",omitempty"` 12 | ID string `json:"Id"` 13 | Created int64 14 | } 15 | 16 | type APIInfo struct { 17 | Debug bool 18 | Containers int 19 | Images int 20 | NFd int `json:",omitempty"` 21 | NGoroutines int `json:",omitempty"` 22 | MemoryLimit bool `json:",omitempty"` 23 | SwapLimit bool `json:",omitempty"` 24 | } 25 | 26 | type APIRmi struct { 27 | Deleted string `json:",omitempty"` 28 | Untagged string `json:",omitempty"` 29 | } 30 | 31 | type APIContainers struct { 32 | ID string `json:"Id"` 33 | Image string 34 | Command string 35 | Created int64 36 | Status string 37 | Ports string 38 | } 39 | 40 | type APISearch struct { 41 | Name string 42 | Description string 43 | } 44 | 45 | type APIID struct { 46 | ID string `json:"Id"` 47 | } 48 | 49 | type APIRun struct { 50 | ID string `json:"Id"` 51 | Warnings []string `json:",omitempty"` 52 | } 53 | 54 | type APIPort struct { 55 | Port string 56 | } 57 | 58 | type APIVersion struct { 59 | Version string 60 | GitCommit string `json:",omitempty"` 61 | GoVersion string `json:",omitempty"` 62 | } 63 | 64 | type APIWait struct { 65 | StatusCode int 66 | } 67 | 68 | type APIAuth struct { 69 | Status string 70 | } 71 | 72 | type APIImageConfig struct { 73 | ID string `json:"Id"` 74 | *Config 75 | } 76 | -------------------------------------------------------------------------------- /src/github.com/dotcloud/docker/archive_test.go: -------------------------------------------------------------------------------- 1 | package docker 2 | 3 | import ( 4 | "io" 5 | "io/ioutil" 6 | "os" 7 | "os/exec" 8 | "testing" 9 | "time" 10 | ) 11 | 12 | func TestCmdStreamLargeStderr(t *testing.T) { 13 | cmd := exec.Command("/bin/sh", "-c", "dd if=/dev/zero bs=1k count=1000 of=/dev/stderr; echo hello") 14 | out, err := CmdStream(cmd) 15 | if err != nil { 16 | t.Fatalf("Failed to start command: " + err.Error()) 17 | } 18 | errCh := make(chan error) 19 | go func() { 20 | _, err := io.Copy(ioutil.Discard, out) 21 | errCh <- err 22 | }() 23 | select { 24 | case err := <-errCh: 25 | if err != nil { 26 | t.Fatalf("Command should not have failed (err=%s...)", err.Error()[:100]) 27 | } 28 | case <-time.After(5 * time.Second): 29 | t.Fatalf("Command did not complete in 5 seconds; probable deadlock") 30 | } 31 | } 32 | 33 | func TestCmdStreamBad(t *testing.T) { 34 | badCmd := exec.Command("/bin/sh", "-c", "echo hello; echo >&2 error couldn\\'t reverse the phase pulser; exit 1") 35 | out, err := CmdStream(badCmd) 36 | if err != nil { 37 | t.Fatalf("Failed to start command: " + err.Error()) 38 | } 39 | if output, err := ioutil.ReadAll(out); err == nil { 40 | t.Fatalf("Command should have failed") 41 | } else if err.Error() != "exit status 1: error couldn't reverse the phase pulser\n" { 42 | t.Fatalf("Wrong error value (%s)", err.Error()) 43 | } else if s := string(output); s != "hello\n" { 44 | t.Fatalf("Command output should be '%s', not '%s'", "hello\\n", output) 45 | } 46 | } 47 | 48 | func TestCmdStreamGood(t *testing.T) { 49 | cmd := exec.Command("/bin/sh", "-c", "echo hello; exit 0") 50 | out, err := CmdStream(cmd) 51 | if err != nil { 52 | t.Fatal(err) 53 | } 54 | if output, err := ioutil.ReadAll(out); err != nil { 55 | t.Fatalf("Command should not have failed (err=%s)", err) 56 | } else if s := string(output); s != "hello\n" { 57 | t.Fatalf("Command output should be '%s', not '%s'", "hello\\n", output) 58 | } 59 | } 60 | 61 | func TestTarUntar(t *testing.T) { 62 | archive, err := Tar(".", Uncompressed) 63 | if err != nil { 64 | t.Fatal(err) 65 | } 66 | tmp, err := ioutil.TempDir("", "docker-test-untar") 67 | if err != nil { 68 | t.Fatal(err) 69 | } 70 | defer os.RemoveAll(tmp) 71 | if err := Untar(archive, tmp); err != nil { 72 | t.Fatal(err) 73 | } 74 | if _, err := os.Stat(tmp); err != nil { 75 | t.Fatalf("Error stating %s: %s", tmp, err.Error()) 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /src/github.com/dotcloud/docker/auth/MAINTAINERS: -------------------------------------------------------------------------------- 1 | ../registry/MAINTAINERS -------------------------------------------------------------------------------- /src/github.com/dotcloud/docker/auth/auth_test.go: -------------------------------------------------------------------------------- 1 | package auth 2 | 3 | import ( 4 | "crypto/rand" 5 | "encoding/hex" 6 | "os" 7 | "strings" 8 | "testing" 9 | ) 10 | 11 | func TestEncodeAuth(t *testing.T) { 12 | newAuthConfig := &AuthConfig{Username: "ken", Password: "test", Email: "test@example.com"} 13 | authStr := EncodeAuth(newAuthConfig) 14 | decAuthConfig, err := DecodeAuth(authStr) 15 | if err != nil { 16 | t.Fatal(err) 17 | } 18 | if newAuthConfig.Username != decAuthConfig.Username { 19 | t.Fatal("Encode Username doesn't match decoded Username") 20 | } 21 | if newAuthConfig.Password != decAuthConfig.Password { 22 | t.Fatal("Encode Password doesn't match decoded Password") 23 | } 24 | if authStr != "a2VuOnRlc3Q=" { 25 | t.Fatal("AuthString encoding isn't correct.") 26 | } 27 | } 28 | 29 | func TestLogin(t *testing.T) { 30 | os.Setenv("DOCKER_INDEX_URL", "https://indexstaging-docker.dotcloud.com") 31 | defer os.Setenv("DOCKER_INDEX_URL", "") 32 | authConfig := NewAuthConfig("unittester", "surlautrerivejetattendrai", "noise+unittester@dotcloud.com", "/tmp") 33 | status, err := Login(authConfig) 34 | if err != nil { 35 | t.Fatal(err) 36 | } 37 | if status != "Login Succeeded\n" { 38 | t.Fatalf("Expected status \"Login Succeeded\", found \"%s\" instead", status) 39 | } 40 | } 41 | 42 | func TestCreateAccount(t *testing.T) { 43 | os.Setenv("DOCKER_INDEX_URL", "https://indexstaging-docker.dotcloud.com") 44 | defer os.Setenv("DOCKER_INDEX_URL", "") 45 | tokenBuffer := make([]byte, 16) 46 | _, err := rand.Read(tokenBuffer) 47 | if err != nil { 48 | t.Fatal(err) 49 | } 50 | token := hex.EncodeToString(tokenBuffer)[:12] 51 | username := "ut" + token 52 | authConfig := NewAuthConfig(username, "test42", "docker-ut+"+token+"@example.com", "/tmp") 53 | status, err := Login(authConfig) 54 | if err != nil { 55 | t.Fatal(err) 56 | } 57 | expectedStatus := "Account created. Please use the confirmation link we sent" + 58 | " to your e-mail to activate it.\n" 59 | if status != expectedStatus { 60 | t.Fatalf("Expected status: \"%s\", found \"%s\" instead.", expectedStatus, status) 61 | } 62 | 63 | status, err = Login(authConfig) 64 | if err == nil { 65 | t.Fatalf("Expected error but found nil instead") 66 | } 67 | 68 | expectedError := "Login: Account is not Active" 69 | 70 | if !strings.Contains(err.Error(), expectedError) { 71 | t.Fatalf("Expected message \"%s\" but found \"%s\" instead", expectedError, err.Error()) 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /src/github.com/dotcloud/docker/buildfile_test.go: -------------------------------------------------------------------------------- 1 | package docker 2 | 3 | import ( 4 | "github.com/dotcloud/docker/utils" 5 | "strings" 6 | "testing" 7 | ) 8 | 9 | const Dockerfile = ` 10 | # VERSION 0.1 11 | # DOCKER-VERSION 0.2 12 | 13 | from ` + unitTestImageName + ` 14 | run sh -c 'echo root:testpass > /tmp/passwd' 15 | run mkdir -p /var/run/sshd 16 | ` 17 | 18 | const DockerfileNoNewLine = ` 19 | # VERSION 0.1 20 | # DOCKER-VERSION 0.2 21 | 22 | from ` + unitTestImageName + ` 23 | run sh -c 'echo root:testpass > /tmp/passwd' 24 | run mkdir -p /var/run/sshd` 25 | 26 | func TestBuild(t *testing.T) { 27 | dockerfiles := []string{Dockerfile, DockerfileNoNewLine} 28 | for _, Dockerfile := range dockerfiles { 29 | runtime, err := newTestRuntime() 30 | if err != nil { 31 | t.Fatal(err) 32 | } 33 | defer nuke(runtime) 34 | 35 | srv := &Server{runtime: runtime} 36 | 37 | buildfile := NewBuildFile(srv, &utils.NopWriter{}) 38 | 39 | imgID, err := buildfile.Build(strings.NewReader(Dockerfile), nil) 40 | if err != nil { 41 | t.Fatal(err) 42 | } 43 | 44 | builder := NewBuilder(runtime) 45 | container, err := builder.Create( 46 | &Config{ 47 | Image: imgID, 48 | Cmd: []string{"cat", "/tmp/passwd"}, 49 | }, 50 | ) 51 | if err != nil { 52 | t.Fatal(err) 53 | } 54 | defer runtime.Destroy(container) 55 | 56 | output, err := container.Output() 57 | if err != nil { 58 | t.Fatal(err) 59 | } 60 | if string(output) != "root:testpass\n" { 61 | t.Fatalf("Unexpected output. Read '%s', expected '%s'", output, "root:testpass\n") 62 | } 63 | 64 | container2, err := builder.Create( 65 | &Config{ 66 | Image: imgID, 67 | Cmd: []string{"ls", "-d", "/var/run/sshd"}, 68 | }, 69 | ) 70 | if err != nil { 71 | t.Fatal(err) 72 | } 73 | defer runtime.Destroy(container2) 74 | 75 | output, err = container2.Output() 76 | if err != nil { 77 | t.Fatal(err) 78 | } 79 | if string(output) != "/var/run/sshd\n" { 80 | t.Fatal("/var/run/sshd has not been created") 81 | } 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /src/github.com/dotcloud/docker/changes.go: -------------------------------------------------------------------------------- 1 | package docker 2 | 3 | import ( 4 | "fmt" 5 | "os" 6 | "path/filepath" 7 | "strings" 8 | ) 9 | 10 | type ChangeType int 11 | 12 | const ( 13 | ChangeModify = iota 14 | ChangeAdd 15 | ChangeDelete 16 | ) 17 | 18 | type Change struct { 19 | Path string 20 | Kind ChangeType 21 | } 22 | 23 | func (change *Change) String() string { 24 | var kind string 25 | switch change.Kind { 26 | case ChangeModify: 27 | kind = "C" 28 | case ChangeAdd: 29 | kind = "A" 30 | case ChangeDelete: 31 | kind = "D" 32 | } 33 | return fmt.Sprintf("%s %s", kind, change.Path) 34 | } 35 | 36 | func Changes(layers []string, rw string) ([]Change, error) { 37 | var changes []Change 38 | err := filepath.Walk(rw, func(path string, f os.FileInfo, err error) error { 39 | if err != nil { 40 | return err 41 | } 42 | 43 | // Rebase path 44 | path, err = filepath.Rel(rw, path) 45 | if err != nil { 46 | return err 47 | } 48 | path = filepath.Join("/", path) 49 | 50 | // Skip root 51 | if path == "/" { 52 | return nil 53 | } 54 | 55 | // Skip AUFS metadata 56 | if matched, err := filepath.Match("/.wh..wh.*", path); err != nil || matched { 57 | return err 58 | } 59 | 60 | change := Change{ 61 | Path: path, 62 | } 63 | 64 | // Find out what kind of modification happened 65 | file := filepath.Base(path) 66 | // If there is a whiteout, then the file was removed 67 | if strings.HasPrefix(file, ".wh.") { 68 | originalFile := file[len(".wh."):] 69 | change.Path = filepath.Join(filepath.Dir(path), originalFile) 70 | change.Kind = ChangeDelete 71 | } else { 72 | // Otherwise, the file was added 73 | change.Kind = ChangeAdd 74 | 75 | // ...Unless it already existed in a top layer, in which case, it's a modification 76 | for _, layer := range layers { 77 | stat, err := os.Stat(filepath.Join(layer, path)) 78 | if err != nil && !os.IsNotExist(err) { 79 | return err 80 | } 81 | if err == nil { 82 | // The file existed in the top layer, so that's a modification 83 | 84 | // However, if it's a directory, maybe it wasn't actually modified. 85 | // If you modify /foo/bar/baz, then /foo will be part of the changed files only because it's the parent of bar 86 | if stat.IsDir() && f.IsDir() { 87 | if f.Size() == stat.Size() && f.Mode() == stat.Mode() && f.ModTime() == stat.ModTime() { 88 | // Both directories are the same, don't record the change 89 | return nil 90 | } 91 | } 92 | change.Kind = ChangeModify 93 | break 94 | } 95 | } 96 | } 97 | 98 | // Record change 99 | changes = append(changes, change) 100 | return nil 101 | }) 102 | if err != nil { 103 | return nil, err 104 | } 105 | return changes, nil 106 | } 107 | -------------------------------------------------------------------------------- /src/github.com/dotcloud/docker/contrib/MAINTAINERS: -------------------------------------------------------------------------------- 1 | # Maintainer wanted! Enroll on #docker@freenode 2 | -------------------------------------------------------------------------------- /src/github.com/dotcloud/docker/contrib/README: -------------------------------------------------------------------------------- 1 | The `contrib` directory contains scripts, images, and other helpful things 2 | which are not part of the core docker distribution. Please note that they 3 | could be out of date, since they do not receive the same attention as the 4 | rest of the repository. 5 | -------------------------------------------------------------------------------- /src/github.com/dotcloud/docker/contrib/crashTest.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "io" 6 | "log" 7 | "net" 8 | "os" 9 | "os/exec" 10 | "path" 11 | "time" 12 | ) 13 | 14 | var DOCKERPATH = path.Join(os.Getenv("DOCKERPATH"), "docker") 15 | 16 | // WARNING: this crashTest will 1) crash your host, 2) remove all containers 17 | func runDaemon() (*exec.Cmd, error) { 18 | os.Remove("/var/run/docker.pid") 19 | exec.Command("rm", "-rf", "/var/lib/docker/containers").Run() 20 | cmd := exec.Command(DOCKERPATH, "-d") 21 | outPipe, err := cmd.StdoutPipe() 22 | if err != nil { 23 | return nil, err 24 | } 25 | errPipe, err := cmd.StderrPipe() 26 | if err != nil { 27 | return nil, err 28 | } 29 | if err := cmd.Start(); err != nil { 30 | return nil, err 31 | } 32 | go func() { 33 | io.Copy(os.Stdout, outPipe) 34 | }() 35 | go func() { 36 | io.Copy(os.Stderr, errPipe) 37 | }() 38 | return cmd, nil 39 | } 40 | 41 | func crashTest() error { 42 | if err := exec.Command("/bin/bash", "-c", "while true; do true; done").Start(); err != nil { 43 | return err 44 | } 45 | 46 | var endpoint string 47 | if ep := os.Getenv("TEST_ENDPOINT"); ep == "" { 48 | endpoint = "192.168.56.1:7979" 49 | } else { 50 | endpoint = ep 51 | } 52 | 53 | c := make(chan bool) 54 | var conn io.Writer 55 | 56 | go func() { 57 | conn, _ = net.Dial("tcp", endpoint) 58 | c <- false 59 | }() 60 | go func() { 61 | time.Sleep(2 * time.Second) 62 | c <- true 63 | }() 64 | <-c 65 | 66 | restartCount := 0 67 | totalTestCount := 1 68 | for { 69 | daemon, err := runDaemon() 70 | if err != nil { 71 | return err 72 | } 73 | restartCount++ 74 | // time.Sleep(5000 * time.Millisecond) 75 | var stop bool 76 | go func() error { 77 | stop = false 78 | for i := 0; i < 100 && !stop; { 79 | func() error { 80 | cmd := exec.Command(DOCKERPATH, "run", "base", "echo", fmt.Sprintf("%d", totalTestCount)) 81 | i++ 82 | totalTestCount++ 83 | outPipe, err := cmd.StdoutPipe() 84 | if err != nil { 85 | return err 86 | } 87 | inPipe, err := cmd.StdinPipe() 88 | if err != nil { 89 | return err 90 | } 91 | if err := cmd.Start(); err != nil { 92 | return err 93 | } 94 | if conn != nil { 95 | go io.Copy(conn, outPipe) 96 | } 97 | 98 | // Expecting error, do not check 99 | inPipe.Write([]byte("hello world!!!!!\n")) 100 | go inPipe.Write([]byte("hello world!!!!!\n")) 101 | go inPipe.Write([]byte("hello world!!!!!\n")) 102 | inPipe.Close() 103 | 104 | if err := cmd.Wait(); err != nil { 105 | return err 106 | } 107 | outPipe.Close() 108 | return nil 109 | }() 110 | } 111 | return nil 112 | }() 113 | time.Sleep(20 * time.Second) 114 | stop = true 115 | if err := daemon.Process.Kill(); err != nil { 116 | return err 117 | } 118 | } 119 | return nil 120 | } 121 | 122 | func main() { 123 | if err := crashTest(); err != nil { 124 | log.Println(err) 125 | } 126 | } 127 | -------------------------------------------------------------------------------- /src/github.com/dotcloud/docker/contrib/install.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # This script is meant for quick & easy install via 'curl URL-OF-SCRIPT | sh' 3 | # Original version by Jeff Lindsay 4 | # Revamped by Jerome Petazzoni 5 | # 6 | # This script canonical location is http://get.docker.io/; to update it, run: 7 | # s3cmd put -m text/x-shellscript -P install.sh s3://get.docker.io/index 8 | 9 | echo "Ensuring basic dependencies are installed..." 10 | apt-get -qq update 11 | apt-get -qq install lxc wget bsdtar 12 | 13 | echo "Looking in /proc/filesystems to see if we have AUFS support..." 14 | if grep -q aufs /proc/filesystems 15 | then 16 | echo "Found." 17 | else 18 | echo "Ahem, it looks like the current kernel does not support AUFS." 19 | echo "Let's see if we can load the AUFS module with modprobe..." 20 | if modprobe aufs 21 | then 22 | echo "Module loaded." 23 | else 24 | echo "Ahem, things didn't turn out as expected." 25 | KPKG=linux-image-extra-$(uname -r) 26 | echo "Trying to install $KPKG..." 27 | if apt-get -qq install $KPKG 28 | then 29 | echo "Installed." 30 | else 31 | echo "Oops, we couldn't install the -extra kernel." 32 | echo "Are you sure you are running a supported version of Ubuntu?" 33 | echo "Proceeding anyway, but Docker will probably NOT WORK!" 34 | fi 35 | fi 36 | fi 37 | 38 | echo "Downloading docker binary and uncompressing into /usr/local/bin..." 39 | curl -s http://get.docker.io/builds/$(uname -s)/$(uname -m)/docker-latest.tgz | 40 | tar -C /usr/local/bin --strip-components=1 -zxf- \ 41 | docker-latest/docker 42 | 43 | if [ -f /etc/init/dockerd.conf ] 44 | then 45 | echo "Upstart script already exists." 46 | else 47 | echo "Creating /etc/init/dockerd.conf..." 48 | echo "exec env LANG=\"en_US.UTF-8\" /usr/local/bin/docker -d" > /etc/init/dockerd.conf 49 | fi 50 | 51 | echo "Starting dockerd..." 52 | start dockerd > /dev/null 53 | 54 | echo "Done." 55 | echo 56 | -------------------------------------------------------------------------------- /src/github.com/dotcloud/docker/contrib/mkimage-busybox.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Generate a very minimal filesystem based on busybox-static, 3 | # and load it into the local docker under the name "busybox". 4 | 5 | BUSYBOX=$(which busybox) 6 | [ "$BUSYBOX" ] || { 7 | echo "Sorry, I could not locate busybox." 8 | echo "Try 'apt-get install busybox-static'?" 9 | exit 1 10 | } 11 | 12 | set -e 13 | ROOTFS=/tmp/rootfs-busybox-$$-$RANDOM 14 | mkdir $ROOTFS 15 | cd $ROOTFS 16 | 17 | mkdir bin etc dev dev/pts lib proc sys tmp 18 | touch etc/resolv.conf 19 | cp /etc/nsswitch.conf etc/nsswitch.conf 20 | echo root:x:0:0:root:/:/bin/sh > etc/passwd 21 | echo root:x:0: > etc/group 22 | ln -s lib lib64 23 | ln -s bin sbin 24 | cp $BUSYBOX bin 25 | for X in $(busybox --list) 26 | do 27 | ln -s busybox bin/$X 28 | done 29 | rm bin/init 30 | ln bin/busybox bin/init 31 | cp /lib/x86_64-linux-gnu/lib{pthread,c,dl,nsl,nss_*}.so.* lib 32 | cp /lib/x86_64-linux-gnu/ld-linux-x86-64.so.2 lib 33 | for X in console null ptmx random stdin stdout stderr tty urandom zero 34 | do 35 | cp -a /dev/$X dev 36 | done 37 | 38 | tar -cf- . | docker import - busybox 39 | docker run -i -u root busybox /bin/echo Success. 40 | -------------------------------------------------------------------------------- /src/github.com/dotcloud/docker/contrib/mkimage-debian.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | 4 | # these should match the names found at http://www.debian.org/releases/ 5 | stableSuite='wheezy' 6 | testingSuite='jessie' 7 | unstableSuite='sid' 8 | 9 | variant='minbase' 10 | include='iproute,iputils-ping' 11 | 12 | repo="$1" 13 | suite="${2:-$stableSuite}" 14 | mirror="${3:-}" # stick to the default debootstrap mirror if one is not provided 15 | 16 | if [ ! "$repo" ]; then 17 | echo >&2 "usage: $0 repo [suite [mirror]]" 18 | echo >&2 " ie: $0 tianon/debian squeeze" 19 | exit 1 20 | fi 21 | 22 | target="/tmp/docker-rootfs-debian-$suite-$$-$RANDOM" 23 | 24 | cd "$(dirname "$(readlink -f "$BASH_SOURCE")")" 25 | returnTo="$(pwd -P)" 26 | 27 | set -x 28 | 29 | # bootstrap 30 | mkdir -p "$target" 31 | sudo debootstrap --verbose --variant="$variant" --include="$include" "$suite" "$target" "$mirror" 32 | 33 | cd "$target" 34 | 35 | # create the image 36 | img=$(sudo tar -c . | docker import -) 37 | 38 | # tag suite 39 | docker tag $img $repo $suite 40 | 41 | # test the image 42 | docker run -i -t $repo:$suite echo success 43 | 44 | if [ "$suite" = "$stableSuite" -o "$suite" = 'stable' ]; then 45 | # tag latest 46 | docker tag $img $repo latest 47 | 48 | # tag the specific debian release version 49 | ver=$(docker run $repo:$suite cat /etc/debian_version) 50 | docker tag $img $repo $ver 51 | fi 52 | 53 | # cleanup 54 | cd "$returnTo" 55 | sudo rm -rf "$target" 56 | -------------------------------------------------------------------------------- /src/github.com/dotcloud/docker/contrib/vagrant-docker/README.md: -------------------------------------------------------------------------------- 1 | # Vagrant-docker 2 | 3 | This is a placeholder for the official vagrant-docker, a plugin for Vagrant (http://vagrantup.com) which exposes Docker as a provider. 4 | -------------------------------------------------------------------------------- /src/github.com/dotcloud/docker/docs/MAINTAINERS: -------------------------------------------------------------------------------- 1 | Andy Rothfusz 2 | Ken Cochrane 3 | -------------------------------------------------------------------------------- /src/github.com/dotcloud/docker/docs/README.md: -------------------------------------------------------------------------------- 1 | Docker documentation and website 2 | ================================ 3 | 4 | Documentation 5 | ------------- 6 | This is your definite place to contribute to the docker documentation. The documentation is generated from the 7 | .rst files under sources. 8 | 9 | The folder also contains the other files to create the http://docker.io website, but you can generally ignore 10 | most of those. 11 | 12 | 13 | Installation 14 | ------------ 15 | 16 | * Work in your own fork of the code, we accept pull requests. 17 | * Install sphinx: `pip install sphinx` 18 | * Mac OS X: `[sudo] pip-2.7 install sphinx`) 19 | * Install sphinx httpdomain contrib package: `pip install sphinxcontrib-httpdomain` 20 | * Mac OS X: `[sudo] pip-2.7 install sphinxcontrib-httpdomain` 21 | * If pip is not available you can probably install it using your favorite package manager as **python-pip** 22 | 23 | Usage 24 | ----- 25 | * Change the `.rst` files with your favorite editor to your liking. 26 | * Run `make docs` to clean up old files and generate new ones. 27 | * Your static website can now be found in the `_build` directory. 28 | * To preview what you have generated run `make server` and open in your favorite browser. 29 | 30 | Working using GitHub's file editor 31 | ---------------------------------- 32 | Alternatively, for small changes and typo's you might want to use GitHub's built in file editor. It allows 33 | you to preview your changes right online. Just be carefull not to create many commits. 34 | 35 | Images 36 | ------ 37 | When you need to add images, try to make them as small as possible (e.g. as gif). 38 | 39 | 40 | Notes 41 | ----- 42 | * The index.html and gettingstarted.html files are copied from the source dir to the output dir without modification. 43 | So changes to those pages should be made directly in html 44 | * For the template the css is compiled from less. When changes are needed they can be compiled using 45 | lessc ``lessc main.less`` or watched using watch-lessc ``watch-lessc -i main.less -o main.css`` 46 | 47 | 48 | Guides on using sphinx 49 | ---------------------- 50 | * To make links to certain pages create a link target like so: 51 | 52 | ``` 53 | .. _hello_world: 54 | 55 | Hello world 56 | =========== 57 | 58 | This is.. (etc.) 59 | ``` 60 | 61 | The ``_hello_world:`` will make it possible to link to this position (page and marker) from all other pages. 62 | 63 | * Notes, warnings and alarms 64 | 65 | ``` 66 | # a note (use when something is important) 67 | .. note:: 68 | 69 | # a warning (orange) 70 | .. warning:: 71 | 72 | # danger (red, use sparsely) 73 | .. danger:: 74 | 75 | * Code examples 76 | 77 | Start without $, so it's easy to copy and paste. 78 | -------------------------------------------------------------------------------- /src/github.com/dotcloud/docker/docs/requirements.txt: -------------------------------------------------------------------------------- 1 | Sphinx==1.1.3 2 | sphinxcontrib-httpdomain==1.1.8 -------------------------------------------------------------------------------- /src/github.com/dotcloud/docker/docs/sources/api/MAINTAINERS: -------------------------------------------------------------------------------- 1 | Solomon Hykes 2 | -------------------------------------------------------------------------------- /src/github.com/dotcloud/docker/docs/sources/api/README.md: -------------------------------------------------------------------------------- 1 | This directory holds the authoritative specifications of APIs defined and implemented by Docker. Currently this includes: 2 | 3 | * The remote API by which a docker node can be queried over HTTP 4 | * The registry API by which a docker node can download and upload container images for storage and sharing 5 | * The index search API by which a docker node can search the public index for images to download 6 | -------------------------------------------------------------------------------- /src/github.com/dotcloud/docker/docs/sources/api/index.rst: -------------------------------------------------------------------------------- 1 | :title: API Documentation 2 | :description: docker documentation 3 | :keywords: docker, ipa, documentation 4 | 5 | APIs 6 | ==== 7 | 8 | Your programs and scripts can access Docker's functionality via these interfaces: 9 | 10 | .. toctree:: 11 | :maxdepth: 3 12 | 13 | registry_index_spec 14 | registry_api 15 | index_api 16 | docker_remote_api 17 | 18 | 19 | -------------------------------------------------------------------------------- /src/github.com/dotcloud/docker/docs/sources/commandline/cli.rst: -------------------------------------------------------------------------------- 1 | :title: Command Line Interface 2 | :description: Docker's CLI command description and usage 3 | :keywords: Docker, Docker documentation, CLI, command line 4 | 5 | .. _cli: 6 | 7 | Overview 8 | ====================== 9 | 10 | Docker Usage 11 | ~~~~~~~~~~~~ 12 | 13 | To list available commands, either run ``docker`` with no parameters or execute 14 | ``docker help``:: 15 | 16 | $ docker 17 | Usage: docker [OPTIONS] COMMAND [arg...] 18 | -H="127.0.0.1:4243": Host:port to bind/connect to 19 | 20 | A self-sufficient runtime for linux containers. 21 | 22 | ... 23 | 24 | Available Commands 25 | ~~~~~~~~~~~~~~~~~~ 26 | 27 | .. toctree:: 28 | :maxdepth: 2 29 | 30 | command/attach 31 | command/build 32 | command/commit 33 | command/diff 34 | command/export 35 | command/history 36 | command/images 37 | command/import 38 | command/info 39 | command/inspect 40 | command/kill 41 | command/login 42 | command/logs 43 | command/port 44 | command/ps 45 | command/pull 46 | command/push 47 | command/restart 48 | command/rm 49 | command/rmi 50 | command/run 51 | command/search 52 | command/start 53 | command/stop 54 | command/tag 55 | command/version 56 | command/wait 57 | -------------------------------------------------------------------------------- /src/github.com/dotcloud/docker/docs/sources/commandline/command/attach.rst: -------------------------------------------------------------------------------- 1 | :title: Attach Command 2 | :description: Attach to a running container 3 | :keywords: attach, container, docker, documentation 4 | 5 | =========================================== 6 | ``attach`` -- Attach to a running container 7 | =========================================== 8 | 9 | :: 10 | 11 | Usage: docker attach CONTAINER 12 | 13 | Attach to a running container 14 | -------------------------------------------------------------------------------- /src/github.com/dotcloud/docker/docs/sources/commandline/command/build.rst: -------------------------------------------------------------------------------- 1 | :title: Build Command 2 | :description: Build a new image from the Dockerfile passed via stdin 3 | :keywords: build, docker, container, documentation 4 | 5 | ================================================ 6 | ``build`` -- Build a container from a Dockerfile 7 | ================================================ 8 | 9 | :: 10 | 11 | Usage: docker build [OPTIONS] PATH | - 12 | Build a new container image from the source code at PATH 13 | -t="": Tag to be applied to the resulting image in case of success. 14 | 15 | Examples 16 | -------- 17 | 18 | .. code-block:: bash 19 | 20 | docker build . 21 | 22 | | This will read the Dockerfile from the current directory. It will also send any other files and directories found in the current directory to the docker daemon. 23 | | The contents of this directory would be used by ADD commands found within the Dockerfile. 24 | | This will send a lot of data to the docker daemon if the current directory contains a lot of data. 25 | | If the absolute path is provided instead of '.', only the files and directories required by the ADD commands from the Dockerfile will be added to the context and transferred to the docker daemon. 26 | | 27 | 28 | .. code-block:: bash 29 | 30 | docker build - 31 | 32 | | This will read a Dockerfile from Stdin without context. Due to the lack of a context, no contents of any local directory will be sent to the docker daemon. 33 | | ADD doesn't work when running in this mode due to the absence of the context, thus having no source files to copy to the container. 34 | -------------------------------------------------------------------------------- /src/github.com/dotcloud/docker/docs/sources/commandline/command/commit.rst: -------------------------------------------------------------------------------- 1 | :title: Commit Command 2 | :description: Create a new image from a container's changes 3 | :keywords: commit, docker, container, documentation 4 | 5 | =========================================================== 6 | ``commit`` -- Create a new image from a container's changes 7 | =========================================================== 8 | 9 | :: 10 | 11 | Usage: docker commit [OPTIONS] CONTAINER [REPOSITORY [TAG]] 12 | 13 | Create a new image from a container's changes 14 | 15 | -m="": Commit message 16 | -author="": Author (eg. "John Hannibal Smith " 17 | -run="": Config automatically applied when the image is run. "+`(ex: {"Cmd": ["cat", "/world"], "PortSpecs": ["22"]}') 18 | 19 | Full -run example:: 20 | 21 | {"Hostname": "", 22 | "User": "", 23 | "CpuShares": 0, 24 | "Memory": 0, 25 | "MemorySwap": 0, 26 | "PortSpecs": ["22", "80", "443"], 27 | "Tty": true, 28 | "OpenStdin": true, 29 | "StdinOnce": true, 30 | "Env": ["FOO=BAR", "FOO2=BAR2"], 31 | "Cmd": ["cat", "-e", "/etc/resolv.conf"], 32 | "Dns": ["8.8.8.8", "8.8.4.4"]} 33 | -------------------------------------------------------------------------------- /src/github.com/dotcloud/docker/docs/sources/commandline/command/diff.rst: -------------------------------------------------------------------------------- 1 | :title: Diff Command 2 | :description: Inspect changes on a container's filesystem 3 | :keywords: diff, docker, container, documentation 4 | 5 | ======================================================= 6 | ``diff`` -- Inspect changes on a container's filesystem 7 | ======================================================= 8 | 9 | :: 10 | 11 | Usage: docker diff CONTAINER [OPTIONS] 12 | 13 | Inspect changes on a container's filesystem 14 | -------------------------------------------------------------------------------- /src/github.com/dotcloud/docker/docs/sources/commandline/command/export.rst: -------------------------------------------------------------------------------- 1 | :title: Export Command 2 | :description: Export the contents of a filesystem as a tar archive 3 | :keywords: export, docker, container, documentation 4 | 5 | ================================================================= 6 | ``export`` -- Stream the contents of a container as a tar archive 7 | ================================================================= 8 | 9 | :: 10 | 11 | Usage: docker export CONTAINER 12 | 13 | Export the contents of a filesystem as a tar archive 14 | -------------------------------------------------------------------------------- /src/github.com/dotcloud/docker/docs/sources/commandline/command/history.rst: -------------------------------------------------------------------------------- 1 | :title: History Command 2 | :description: Show the history of an image 3 | :keywords: history, docker, container, documentation 4 | 5 | =========================================== 6 | ``history`` -- Show the history of an image 7 | =========================================== 8 | 9 | :: 10 | 11 | Usage: docker history [OPTIONS] IMAGE 12 | 13 | Show the history of an image 14 | -------------------------------------------------------------------------------- /src/github.com/dotcloud/docker/docs/sources/commandline/command/images.rst: -------------------------------------------------------------------------------- 1 | :title: Images Command 2 | :description: List images 3 | :keywords: images, docker, container, documentation 4 | 5 | ========================= 6 | ``images`` -- List images 7 | ========================= 8 | 9 | :: 10 | 11 | Usage: docker images [OPTIONS] [NAME] 12 | 13 | List images 14 | 15 | -a=false: show all images 16 | -q=false: only show numeric IDs 17 | -viz=false: output in graphviz format 18 | 19 | Displaying images visually 20 | -------------------------- 21 | 22 | :: 23 | 24 | docker images -viz | dot -Tpng -o docker.png 25 | 26 | .. image:: images/docker_images.gif 27 | -------------------------------------------------------------------------------- /src/github.com/dotcloud/docker/docs/sources/commandline/command/images/docker_images.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coreos/systemd-rest/1cbd0a6a5de82a36b5ca9117297d8e152a133e4f/src/github.com/dotcloud/docker/docs/sources/commandline/command/images/docker_images.gif -------------------------------------------------------------------------------- /src/github.com/dotcloud/docker/docs/sources/commandline/command/import.rst: -------------------------------------------------------------------------------- 1 | :title: Import Command 2 | :description: Create a new filesystem image from the contents of a tarball 3 | :keywords: import, tarball, docker, url, documentation 4 | 5 | ========================================================================== 6 | ``import`` -- Create a new filesystem image from the contents of a tarball 7 | ========================================================================== 8 | 9 | :: 10 | 11 | Usage: docker import [OPTIONS] URL|- [REPOSITORY [TAG]] 12 | 13 | Create a new filesystem image from the contents of a tarball 14 | -------------------------------------------------------------------------------- /src/github.com/dotcloud/docker/docs/sources/commandline/command/info.rst: -------------------------------------------------------------------------------- 1 | :title: Info Command 2 | :description: Display system-wide information. 3 | :keywords: info, docker, information, documentation 4 | 5 | =========================================== 6 | ``info`` -- Display system-wide information 7 | =========================================== 8 | 9 | :: 10 | 11 | Usage: docker info 12 | 13 | Display system-wide information. 14 | -------------------------------------------------------------------------------- /src/github.com/dotcloud/docker/docs/sources/commandline/command/inspect.rst: -------------------------------------------------------------------------------- 1 | :title: Inspect Command 2 | :description: Return low-level information on a container 3 | :keywords: inspect, container, docker, documentation 4 | 5 | ========================================================== 6 | ``inspect`` -- Return low-level information on a container 7 | ========================================================== 8 | 9 | :: 10 | 11 | Usage: docker inspect [OPTIONS] CONTAINER 12 | 13 | Return low-level information on a container 14 | -------------------------------------------------------------------------------- /src/github.com/dotcloud/docker/docs/sources/commandline/command/kill.rst: -------------------------------------------------------------------------------- 1 | :title: Kill Command 2 | :description: Kill a running container 3 | :keywords: kill, container, docker, documentation 4 | 5 | ==================================== 6 | ``kill`` -- Kill a running container 7 | ==================================== 8 | 9 | :: 10 | 11 | Usage: docker kill [OPTIONS] CONTAINER [CONTAINER...] 12 | 13 | Kill a running container 14 | -------------------------------------------------------------------------------- /src/github.com/dotcloud/docker/docs/sources/commandline/command/login.rst: -------------------------------------------------------------------------------- 1 | :title: Login Command 2 | :description: Register or Login to the docker registry server 3 | :keywords: login, docker, documentation 4 | 5 | ============================================================ 6 | ``login`` -- Register or Login to the docker registry server 7 | ============================================================ 8 | 9 | :: 10 | 11 | Usage: docker login 12 | 13 | Register or Login to the docker registry server 14 | -------------------------------------------------------------------------------- /src/github.com/dotcloud/docker/docs/sources/commandline/command/logs.rst: -------------------------------------------------------------------------------- 1 | :title: Logs Command 2 | :description: Fetch the logs of a container 3 | :keywords: logs, container, docker, documentation 4 | 5 | ========================================= 6 | ``logs`` -- Fetch the logs of a container 7 | ========================================= 8 | 9 | :: 10 | 11 | Usage: docker logs [OPTIONS] CONTAINER 12 | 13 | Fetch the logs of a container 14 | -------------------------------------------------------------------------------- /src/github.com/dotcloud/docker/docs/sources/commandline/command/port.rst: -------------------------------------------------------------------------------- 1 | :title: Port Command 2 | :description: Lookup the public-facing port which is NAT-ed to PRIVATE_PORT 3 | :keywords: port, docker, container, documentation 4 | 5 | ========================================================================= 6 | ``port`` -- Lookup the public-facing port which is NAT-ed to PRIVATE_PORT 7 | ========================================================================= 8 | 9 | :: 10 | 11 | Usage: docker port [OPTIONS] CONTAINER PRIVATE_PORT 12 | 13 | Lookup the public-facing port which is NAT-ed to PRIVATE_PORT 14 | -------------------------------------------------------------------------------- /src/github.com/dotcloud/docker/docs/sources/commandline/command/ps.rst: -------------------------------------------------------------------------------- 1 | :title: Ps Command 2 | :description: List containers 3 | :keywords: ps, docker, documentation, container 4 | 5 | ========================= 6 | ``ps`` -- List containers 7 | ========================= 8 | 9 | :: 10 | 11 | Usage: docker ps [OPTIONS] 12 | 13 | List containers 14 | 15 | -a=false: Show all containers. Only running containers are shown by default. 16 | -notrunc=false: Don't truncate output 17 | -q=false: Only display numeric IDs 18 | -------------------------------------------------------------------------------- /src/github.com/dotcloud/docker/docs/sources/commandline/command/pull.rst: -------------------------------------------------------------------------------- 1 | :title: Pull Command 2 | :description: Pull an image or a repository from the registry 3 | :keywords: pull, image, repo, repository, documentation, docker 4 | 5 | ========================================================================= 6 | ``pull`` -- Pull an image or a repository from the docker registry server 7 | ========================================================================= 8 | 9 | :: 10 | 11 | Usage: docker pull NAME 12 | 13 | Pull an image or a repository from the registry 14 | -------------------------------------------------------------------------------- /src/github.com/dotcloud/docker/docs/sources/commandline/command/push.rst: -------------------------------------------------------------------------------- 1 | :title: Push Command 2 | :description: Push an image or a repository to the registry 3 | :keywords: push, docker, image, repository, documentation, repo 4 | 5 | ======================================================================= 6 | ``push`` -- Push an image or a repository to the docker registry server 7 | ======================================================================= 8 | 9 | :: 10 | 11 | Usage: docker push NAME 12 | 13 | Push an image or a repository to the registry 14 | -------------------------------------------------------------------------------- /src/github.com/dotcloud/docker/docs/sources/commandline/command/restart.rst: -------------------------------------------------------------------------------- 1 | :title: Restart Command 2 | :description: Restart a running container 3 | :keywords: restart, container, docker, documentation 4 | 5 | ========================================== 6 | ``restart`` -- Restart a running container 7 | ========================================== 8 | 9 | :: 10 | 11 | Usage: docker restart [OPTIONS] NAME 12 | 13 | Restart a running container 14 | -------------------------------------------------------------------------------- /src/github.com/dotcloud/docker/docs/sources/commandline/command/rm.rst: -------------------------------------------------------------------------------- 1 | :title: Rm Command 2 | :description: Remove a container 3 | :keywords: remove, container, docker, documentation, rm 4 | 5 | ============================ 6 | ``rm`` -- Remove a container 7 | ============================ 8 | 9 | :: 10 | 11 | Usage: docker rm [OPTIONS] CONTAINER 12 | 13 | Remove a container 14 | -------------------------------------------------------------------------------- /src/github.com/dotcloud/docker/docs/sources/commandline/command/rmi.rst: -------------------------------------------------------------------------------- 1 | :title: Rmi Command 2 | :description: Remove an image 3 | :keywords: rmi, remove, image, docker, documentation 4 | 5 | ========================== 6 | ``rmi`` -- Remove an image 7 | ========================== 8 | 9 | :: 10 | 11 | Usage: docker rmimage [OPTIONS] IMAGE 12 | 13 | Remove an image 14 | -------------------------------------------------------------------------------- /src/github.com/dotcloud/docker/docs/sources/commandline/command/run.rst: -------------------------------------------------------------------------------- 1 | :title: Run Command 2 | :description: Run a command in a new container 3 | :keywords: run, container, docker, documentation 4 | 5 | =========================================== 6 | ``run`` -- Run a command in a new container 7 | =========================================== 8 | 9 | :: 10 | 11 | Usage: docker run [OPTIONS] IMAGE COMMAND [ARG...] 12 | 13 | Run a command in a new container 14 | 15 | -a=map[]: Attach to stdin, stdout or stderr. 16 | -c=0: CPU shares (relative weight) 17 | -d=false: Detached mode: leave the container running in the background 18 | -e=[]: Set environment variables 19 | -h="": Container host name 20 | -i=false: Keep stdin open even if not attached 21 | -m=0: Memory limit (in bytes) 22 | -p=[]: Map a network port to the container 23 | -t=false: Allocate a pseudo-tty 24 | -u="": Username or UID 25 | -d=[]: Set custom dns servers for the container 26 | -v=[]: Creates a new volume and mounts it at the specified path. 27 | -volumes-from="": Mount all volumes from the given container. 28 | -------------------------------------------------------------------------------- /src/github.com/dotcloud/docker/docs/sources/commandline/command/search.rst: -------------------------------------------------------------------------------- 1 | :title: Search Command 2 | :description: Searches for the TERM parameter on the Docker index and prints out a list of repositories that match. 3 | :keywords: search, docker, image, documentation 4 | 5 | =================================================================== 6 | ``search`` -- Search for an image in the docker index 7 | =================================================================== 8 | 9 | :: 10 | 11 | Usage: docker search TERM 12 | 13 | Searches for the TERM parameter on the Docker index and prints out a list of repositories 14 | that match. 15 | -------------------------------------------------------------------------------- /src/github.com/dotcloud/docker/docs/sources/commandline/command/start.rst: -------------------------------------------------------------------------------- 1 | :title: Start Command 2 | :description: Start a stopped container 3 | :keywords: start, docker, container, documentation 4 | 5 | ====================================== 6 | ``start`` -- Start a stopped container 7 | ====================================== 8 | 9 | :: 10 | 11 | Usage: docker start [OPTIONS] NAME 12 | 13 | Start a stopped container 14 | -------------------------------------------------------------------------------- /src/github.com/dotcloud/docker/docs/sources/commandline/command/stop.rst: -------------------------------------------------------------------------------- 1 | :title: Stop Command 2 | :description: Stop a running container 3 | :keywords: stop, container, docker, documentation 4 | 5 | ==================================== 6 | ``stop`` -- Stop a running container 7 | ==================================== 8 | 9 | :: 10 | 11 | Usage: docker stop [OPTIONS] NAME 12 | 13 | Stop a running container 14 | -------------------------------------------------------------------------------- /src/github.com/dotcloud/docker/docs/sources/commandline/command/tag.rst: -------------------------------------------------------------------------------- 1 | :title: Tag Command 2 | :description: Tag an image into a repository 3 | :keywords: tag, docker, image, repository, documentation, repo 4 | 5 | ========================================= 6 | ``tag`` -- Tag an image into a repository 7 | ========================================= 8 | 9 | :: 10 | 11 | Usage: docker tag [OPTIONS] IMAGE REPOSITORY [TAG] 12 | 13 | Tag an image into a repository 14 | 15 | -f=false: Force 16 | -------------------------------------------------------------------------------- /src/github.com/dotcloud/docker/docs/sources/commandline/command/version.rst: -------------------------------------------------------------------------------- 1 | :title: Version Command 2 | :description: 3 | :keywords: version, docker, documentation 4 | 5 | ================================================== 6 | ``version`` -- Show the docker version information 7 | ================================================== 8 | -------------------------------------------------------------------------------- /src/github.com/dotcloud/docker/docs/sources/commandline/command/wait.rst: -------------------------------------------------------------------------------- 1 | :title: Wait Command 2 | :description: Block until a container stops, then print its exit code. 3 | :keywords: wait, docker, container, documentation 4 | 5 | =================================================================== 6 | ``wait`` -- Block until a container stops, then print its exit code 7 | =================================================================== 8 | 9 | :: 10 | 11 | Usage: docker wait [OPTIONS] NAME 12 | 13 | Block until a container stops, then print its exit code. 14 | -------------------------------------------------------------------------------- /src/github.com/dotcloud/docker/docs/sources/commandline/index.rst: -------------------------------------------------------------------------------- 1 | :title: Commands 2 | :description: -- todo: change me 3 | :keywords: todo, commands, command line, help, docker, documentation 4 | 5 | 6 | Commands 7 | ======== 8 | 9 | Contents: 10 | 11 | .. toctree:: 12 | :maxdepth: 1 13 | 14 | cli 15 | attach 16 | build 17 | commit 18 | diff 19 | export 20 | history 21 | images 22 | import 23 | info 24 | inspect 25 | kill 26 | login 27 | logs 28 | port 29 | ps 30 | pull 31 | push 32 | restart 33 | rm 34 | rmi 35 | run 36 | search 37 | start 38 | stop 39 | tag 40 | version 41 | wait -------------------------------------------------------------------------------- /src/github.com/dotcloud/docker/docs/sources/concepts/containers.rst: -------------------------------------------------------------------------------- 1 | :title: Introduction 2 | :description: An introduction to docker and standard containers? 3 | :keywords: containers, lxc, concepts, explanation, docker, documentation 4 | 5 | 6 | :note: This version of the introduction is temporary, just to make sure we don't break the links from the website when the documentation is updated 7 | 8 | This document has been moved to :ref:`introduction`, please update your bookmarks. -------------------------------------------------------------------------------- /src/github.com/dotcloud/docker/docs/sources/concepts/images/lego_docker.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coreos/systemd-rest/1cbd0a6a5de82a36b5ca9117297d8e152a133e4f/src/github.com/dotcloud/docker/docs/sources/concepts/images/lego_docker.jpg -------------------------------------------------------------------------------- /src/github.com/dotcloud/docker/docs/sources/concepts/index.rst: -------------------------------------------------------------------------------- 1 | :title: Concepts 2 | :description: -- todo: change me 3 | :keywords: concepts, documentation, docker, containers 4 | 5 | 6 | 7 | Concepts 8 | ======== 9 | 10 | Contents: 11 | 12 | .. toctree:: 13 | :maxdepth: 1 14 | 15 | ../index 16 | 17 | -------------------------------------------------------------------------------- /src/github.com/dotcloud/docker/docs/sources/contributing/contributing.rst: -------------------------------------------------------------------------------- 1 | :title: Contribution Guidelines 2 | :description: Contribution guidelines: create issues, convetions, pull requests 3 | :keywords: contributing, docker, documentation, help, guideline 4 | 5 | Contributing to Docker 6 | ====================== 7 | 8 | Want to hack on Docker? Awesome! The repository includes `all the instructions you need to get started `_. 9 | 10 | -------------------------------------------------------------------------------- /src/github.com/dotcloud/docker/docs/sources/contributing/devenvironment.rst: -------------------------------------------------------------------------------- 1 | :title: Setting Up a Dev Environment 2 | :description: Guides on how to contribute to docker 3 | :keywords: Docker, documentation, developers, contributing, dev environment 4 | 5 | Setting Up a Dev Environment 6 | ============================ 7 | 8 | Instructions that have been verified to work on Ubuntu Precise 12.04 (LTS) (64-bit), 9 | 10 | 11 | Dependencies 12 | ------------ 13 | 14 | **Linux kernel 3.8** 15 | 16 | Due to a bug in LXC docker works best on the 3.8 kernel. Precise comes with a 3.2 kernel, so we need to upgrade it. The kernel we install comes with AUFS built in. 17 | 18 | 19 | .. code-block:: bash 20 | 21 | # install the backported kernel 22 | sudo apt-get update && sudo apt-get install linux-image-generic-lts-raring 23 | 24 | # reboot 25 | sudo reboot 26 | 27 | 28 | Installation 29 | ------------ 30 | 31 | .. code-block:: bash 32 | 33 | sudo apt-get install python-software-properties 34 | sudo add-apt-repository ppa:gophers/go 35 | sudo apt-get update 36 | sudo apt-get -y install lxc wget bsdtar curl golang-stable git 37 | 38 | export GOPATH=~/go/ 39 | export PATH=$GOPATH/bin:$PATH 40 | 41 | mkdir -p $GOPATH/src/github.com/dotcloud 42 | cd $GOPATH/src/github.com/dotcloud 43 | git clone git://github.com/dotcloud/docker.git 44 | cd docker 45 | 46 | go get -v github.com/dotcloud/docker/... 47 | go install -v github.com/dotcloud/docker/... 48 | 49 | 50 | Then run the docker daemon, 51 | 52 | .. code-block:: bash 53 | 54 | sudo $GOPATH/bin/docker -d 55 | 56 | 57 | Run the ``go install`` command (above) to recompile docker. 58 | -------------------------------------------------------------------------------- /src/github.com/dotcloud/docker/docs/sources/contributing/index.rst: -------------------------------------------------------------------------------- 1 | :title: Contributing to Docker 2 | :description: Guides on how to contribute to docker 3 | :keywords: Docker, documentation, developers, contributing, dev environment 4 | 5 | 6 | 7 | Contributing 8 | ============ 9 | 10 | .. toctree:: 11 | :maxdepth: 1 12 | 13 | contributing 14 | devenvironment 15 | -------------------------------------------------------------------------------- /src/github.com/dotcloud/docker/docs/sources/examples/couchdb_data_volumes.rst: -------------------------------------------------------------------------------- 1 | :title: Sharing data between 2 couchdb databases 2 | :description: Sharing data between 2 couchdb databases 3 | :keywords: docker, example, package installation, networking, couchdb, data volumes 4 | 5 | .. _running_couchdb_service: 6 | 7 | CouchDB Service 8 | =============== 9 | 10 | .. include:: example_header.inc 11 | 12 | Here's an example of using data volumes to share the same data between 2 couchdb containers. 13 | This could be used for hot upgrades, testing different versions of couchdb on the same data, etc. 14 | 15 | Create first database 16 | --------------------- 17 | 18 | Note that we're marking /var/lib/couchdb as a data volume. 19 | 20 | .. code-block:: bash 21 | 22 | COUCH1=$(docker run -d -v /var/lib/couchdb shykes/couchdb:2013-05-03) 23 | 24 | Add data to the first database 25 | ------------------------------ 26 | 27 | We're assuming your docker host is reachable at `localhost`. If not, replace `localhost` with the public IP of your docker host. 28 | 29 | .. code-block:: bash 30 | 31 | HOST=localhost 32 | URL="http://$HOST:$(docker port $COUCH1 5984)/_utils/" 33 | echo "Navigate to $URL in your browser, and use the couch interface to add data" 34 | 35 | Create second database 36 | ---------------------- 37 | 38 | This time, we're requesting shared access to $COUCH1's volumes. 39 | 40 | .. code-block:: bash 41 | 42 | COUCH2=$(docker run -d -volumes-from $COUCH1) shykes/couchdb:2013-05-03) 43 | 44 | Browse data on the second database 45 | ---------------------------------- 46 | 47 | .. code-block:: bash 48 | 49 | HOST=localhost 50 | URL="http://$HOST:$(docker port $COUCH2 5984)/_utils/" 51 | echo "Navigate to $URL in your browser. You should see the same data as in the first database!" 52 | 53 | Congratulations, you are running 2 Couchdb containers, completely isolated from each other *except* for their data. 54 | -------------------------------------------------------------------------------- /src/github.com/dotcloud/docker/docs/sources/examples/example_header.inc: -------------------------------------------------------------------------------- 1 | 2 | .. note:: 3 | 4 | This example assumes you have Docker running in daemon mode. For more information please see :ref:`running_examples` 5 | -------------------------------------------------------------------------------- /src/github.com/dotcloud/docker/docs/sources/examples/hello_world.rst: -------------------------------------------------------------------------------- 1 | :title: Hello world example 2 | :description: A simple hello world example with Docker 3 | :keywords: docker, example, hello world 4 | 5 | .. _hello_world: 6 | 7 | Hello World 8 | =========== 9 | 10 | .. include:: example_header.inc 11 | 12 | This is the most basic example available for using Docker. 13 | 14 | Download the base container 15 | 16 | .. code-block:: bash 17 | 18 | # Download a base image 19 | docker pull base 20 | 21 | The *base* image is a minimal *ubuntu* based container, alternatively you can select *busybox*, a bare 22 | minimal linux system. The images are retrieved from the docker repository. 23 | 24 | 25 | .. code-block:: bash 26 | 27 | #run a simple echo command, that will echo hello world back to the console over standard out. 28 | docker run base /bin/echo hello world 29 | 30 | **Explanation:** 31 | 32 | - **"docker run"** run a command in a new container 33 | - **"base"** is the image we want to run the command inside of. 34 | - **"/bin/echo"** is the command we want to run in the container 35 | - **"hello world"** is the input for the echo command 36 | 37 | 38 | 39 | **Video:** 40 | 41 | See the example in action 42 | 43 | .. raw:: html 44 | 45 |
46 | 47 |
48 | 49 | 50 | Continue to the :ref:`hello_world_daemon` example. -------------------------------------------------------------------------------- /src/github.com/dotcloud/docker/docs/sources/examples/hello_world_daemon.rst: -------------------------------------------------------------------------------- 1 | :title: Hello world daemon example 2 | :description: A simple hello world daemon example with Docker 3 | :keywords: docker, example, hello world, daemon 4 | 5 | .. _hello_world_daemon: 6 | 7 | Hello World Daemon 8 | ================== 9 | 10 | .. include:: example_header.inc 11 | 12 | The most boring daemon ever written. 13 | 14 | This example assumes you have Docker installed and with the base image already imported ``docker pull base``. 15 | We will use the base image to run a simple hello world daemon that will just print hello world to standard 16 | out every second. It will continue to do this until we stop it. 17 | 18 | **Steps:** 19 | 20 | .. code-block:: bash 21 | 22 | CONTAINER_ID=$(docker run -d base /bin/sh -c "while true; do echo hello world; sleep 1; done") 23 | 24 | We are going to run a simple hello world daemon in a new container made from the base image. 25 | 26 | - **"docker run -d "** run a command in a new container. We pass "-d" so it runs as a daemon. 27 | - **"base"** is the image we want to run the command inside of. 28 | - **"/bin/sh -c"** is the command we want to run in the container 29 | - **"while true; do echo hello world; sleep 1; done"** is the mini script we want to run, that will just print hello world once a second until we stop it. 30 | - **$CONTAINER_ID** the output of the run command will return a container id, we can use in future commands to see what is going on with this process. 31 | 32 | .. code-block:: bash 33 | 34 | docker logs $CONTAINER_ID 35 | 36 | Check the logs make sure it is working correctly. 37 | 38 | - **"docker logs**" This will return the logs for a container 39 | - **$CONTAINER_ID** The Id of the container we want the logs for. 40 | 41 | .. code-block:: bash 42 | 43 | docker attach $CONTAINER_ID 44 | 45 | Attach to the container to see the results in realtime. 46 | 47 | - **"docker attach**" This will allow us to attach to a background process to see what is going on. 48 | - **$CONTAINER_ID** The Id of the container we want to attach too. 49 | 50 | .. code-block:: bash 51 | 52 | docker ps 53 | 54 | Check the process list to make sure it is running. 55 | 56 | - **"docker ps"** this shows all running process managed by docker 57 | 58 | .. code-block:: bash 59 | 60 | docker stop $CONTAINER_ID 61 | 62 | Stop the container, since we don't need it anymore. 63 | 64 | - **"docker stop"** This stops a container 65 | - **$CONTAINER_ID** The Id of the container we want to stop. 66 | 67 | .. code-block:: bash 68 | 69 | docker ps 70 | 71 | Make sure it is really stopped. 72 | 73 | 74 | **Video:** 75 | 76 | See the example in action 77 | 78 | .. raw:: html 79 | 80 |
81 | 82 |
83 | 84 | Continue to the :ref:`python_web_app` example. 85 | -------------------------------------------------------------------------------- /src/github.com/dotcloud/docker/docs/sources/examples/index.rst: -------------------------------------------------------------------------------- 1 | :title: Docker Examples 2 | :description: Examples on how to use Docker 3 | :keywords: docker, hello world, node, nodejs, python, couch, couchdb, redis, ssh, sshd, examples 4 | 5 | 6 | 7 | Examples 8 | ============ 9 | 10 | Contents: 11 | 12 | .. toctree:: 13 | :maxdepth: 1 14 | 15 | running_examples 16 | hello_world 17 | hello_world_daemon 18 | python_web_app 19 | nodejs_web_app 20 | running_redis_service 21 | running_ssh_service 22 | couchdb_data_volumes 23 | -------------------------------------------------------------------------------- /src/github.com/dotcloud/docker/docs/sources/examples/running_examples.rst: -------------------------------------------------------------------------------- 1 | :title: Running the Examples 2 | :description: An overview on how to run the docker examples 3 | :keywords: docker, examples, how to 4 | 5 | .. _running_examples: 6 | 7 | Running the Examples 8 | -------------------- 9 | 10 | All the examples assume your machine is running the docker daemon. To run the docker daemon in the background, simply type: 11 | 12 | .. code-block:: bash 13 | 14 | sudo docker -d & 15 | 16 | Now you can run docker in client mode: all commands will be forwarded to the docker daemon, so the client 17 | can run from any account. 18 | 19 | .. code-block:: bash 20 | 21 | # now you can run docker commands from any account. 22 | docker help 23 | -------------------------------------------------------------------------------- /src/github.com/dotcloud/docker/docs/sources/examples/running_redis_service.rst: -------------------------------------------------------------------------------- 1 | :title: Running a Redis service 2 | :description: Installing and running an redis service 3 | :keywords: docker, example, package installation, networking, redis 4 | 5 | .. _running_redis_service: 6 | 7 | Redis Service 8 | ============= 9 | 10 | .. include:: example_header.inc 11 | 12 | Very simple, no frills, redis service. 13 | 14 | Open a docker container 15 | ----------------------- 16 | 17 | .. code-block:: bash 18 | 19 | docker run -i -t base /bin/bash 20 | 21 | Building your image 22 | ------------------- 23 | 24 | Update your docker container, install the redis server. Once installed, exit out of docker. 25 | 26 | .. code-block:: bash 27 | 28 | apt-get update 29 | apt-get install redis-server 30 | exit 31 | 32 | Snapshot the installation 33 | ------------------------- 34 | 35 | .. code-block:: bash 36 | 37 | docker ps -a # grab the container id (this will be the first one in the list) 38 | docker commit /redis 39 | 40 | Run the service 41 | --------------- 42 | 43 | Running the service with `-d` runs the container in detached mode, leaving the 44 | container running in the background. Use your snapshot. 45 | 46 | .. code-block:: bash 47 | 48 | docker run -d -p 6379 /redis /usr/bin/redis-server 49 | 50 | Test 1 51 | ++++++ 52 | 53 | Connect to the container with the redis-cli. 54 | 55 | .. code-block:: bash 56 | 57 | docker ps # grab the new container id 58 | docker inspect # grab the ipaddress of the container 59 | redis-cli -h -p 6379 60 | redis 10.0.3.32:6379> set docker awesome 61 | OK 62 | redis 10.0.3.32:6379> get docker 63 | "awesome" 64 | redis 10.0.3.32:6379> exit 65 | 66 | Test 2 67 | ++++++ 68 | 69 | Connect to the host os with the redis-cli. 70 | 71 | .. code-block:: bash 72 | 73 | docker ps # grab the new container id 74 | docker port 6379 # grab the external port 75 | ifconfig # grab the host ip address 76 | redis-cli -h -p 77 | redis 192.168.0.1:49153> set docker awesome 78 | OK 79 | redis 192.168.0.1:49153> get docker 80 | "awesome" 81 | redis 192.168.0.1:49153> exit 82 | -------------------------------------------------------------------------------- /src/github.com/dotcloud/docker/docs/sources/examples/running_ssh_service.rst: -------------------------------------------------------------------------------- 1 | :title: Running an SSH service 2 | :description: A screencast of installing and running an sshd service 3 | :keywords: docker, example, package installation, networking 4 | 5 | .. _running_ssh_service: 6 | 7 | SSH Daemon Service 8 | ================== 9 | 10 | .. include:: example_header.inc 11 | 12 | 13 | **Video:** 14 | 15 | I've create a little screencast to show how to create a sshd service and connect to it. It is something like 11 16 | minutes and not entirely smooth, but gives you a good idea. 17 | 18 | .. raw:: html 19 | 20 |
21 | 22 |
23 | 24 | You can also get this sshd container by using 25 | :: 26 | 27 | docker pull dhrp/sshd 28 | 29 | 30 | The password is 'screencast' 31 | 32 | **Video's Transcription:** 33 | 34 | .. code-block:: bash 35 | 36 | # Hello! We are going to try and install openssh on a container and run it as a servic 37 | # let's pull base to get a base ubuntu image. 38 | $ docker pull base 39 | # I had it so it was quick 40 | # now let's connect using -i for interactive and with -t for terminal 41 | # we execute /bin/bash to get a prompt. 42 | $ docker run -i -t base /bin/bash 43 | # now let's commit it 44 | # which container was it? 45 | $ docker ps -a |more 46 | $ docker commit a30a3a2f2b130749995f5902f079dc6ad31ea0621fac595128ec59c6da07feea dhrp/sshd 47 | # I gave the name dhrp/sshd for the container 48 | # now we can run it again 49 | $ docker run -d dhrp/sshd /usr/sbin/sshd -D # D for daemon mode 50 | # is it running? 51 | $ docker ps 52 | # yes! 53 | # let's stop it 54 | $ docker stop 0ebf7cec294755399d063f4b1627980d4cbff7d999f0bc82b59c300f8536a562 55 | $ docker ps 56 | # and reconnect, but now open a port to it 57 | $ docker run -d -p 22 dhrp/sshd /usr/sbin/sshd -D 58 | $ docker port b2b407cf22cf8e7fa3736fa8852713571074536b1d31def3fdfcd9fa4fd8c8c5 22 59 | # it has now given us a port to connect to 60 | # we have to connect using a public ip of our host 61 | $ hostname 62 | $ ifconfig 63 | $ ssh root@192.168.33.10 -p 49153 64 | # Ah! forgot to set root passwd 65 | $ docker commit b2b407cf22cf8e7fa3736fa8852713571074536b1d31def3fdfcd9fa4fd8c8c5 dhrp/sshd 66 | $ docker ps -a 67 | $ docker run -i -t dhrp/sshd /bin/bash 68 | $ passwd 69 | $ exit 70 | $ docker commit 9e863f0ca0af31c8b951048ba87641d67c382d08d655c2e4879c51410e0fedc1 dhrp/sshd 71 | $ docker run -d -p 22 dhrp/sshd /usr/sbin/sshd -D 72 | $ docker port a0aaa9558c90cf5c7782648df904a82365ebacce523e4acc085ac1213bfe2206 22 73 | $ ifconfig 74 | $ ssh root@192.168.33.10 -p 49154 75 | # Thanks for watching, Thatcher thatcher@dotcloud.com 76 | 77 | 78 | -------------------------------------------------------------------------------- /src/github.com/dotcloud/docker/docs/sources/faq.rst: -------------------------------------------------------------------------------- 1 | :title: FAQ 2 | :description: Most frequently asked questions. 3 | :keywords: faq, questions, documentation, docker 4 | 5 | FAQ 6 | === 7 | 8 | 9 | Most frequently asked questions. 10 | -------------------------------- 11 | 12 | 1. **How much does Docker cost?** 13 | 14 | Docker is 100% free, it is open source, so you can use it without paying. 15 | 16 | 2. **What open source license are you using?** 17 | 18 | We are using the Apache License Version 2.0, see it here: https://github.com/dotcloud/docker/blob/master/LICENSE 19 | 20 | 3. **Does Docker run on Mac OS X or Windows?** 21 | 22 | Not at this time, Docker currently only runs on Linux, but you can use VirtualBox to run Docker in a 23 | virtual machine on your box, and get the best of both worlds. Check out the :ref:`install_using_vagrant` and :ref:`windows` installation guides. 24 | 25 | 4. **How do containers compare to virtual machines?** 26 | 27 | They are complementary. VMs are best used to allocate chunks of hardware resources. Containers operate at the process level, which makes them very lightweight and perfect as a unit of software delivery. 28 | 29 | 5. **Can I help by adding some questions and answers?** 30 | 31 | Definitely! You can fork `the repo`_ and edit the documentation sources. 32 | 33 | 34 | 42. **Where can I find more answers?** 35 | 36 | You can find more answers on: 37 | 38 | * `Docker club mailinglist`_ 39 | * `IRC, docker on freenode`_ 40 | * `Github`_ 41 | * `Ask questions on Stackoverflow`_ 42 | * `Join the conversation on Twitter`_ 43 | 44 | 45 | .. _Docker club mailinglist: https://groups.google.com/d/forum/docker-club 46 | .. _the repo: http://www.github.com/dotcloud/docker 47 | .. _IRC, docker on freenode: irc://chat.freenode.net#docker 48 | .. _Github: http://www.github.com/dotcloud/docker 49 | .. _Ask questions on Stackoverflow: http://stackoverflow.com/search?q=docker 50 | .. _Join the conversation on Twitter: http://twitter.com/getdocker 51 | 52 | 53 | Looking for something else to read? Checkout the :ref:`hello_world` example. 54 | -------------------------------------------------------------------------------- /src/github.com/dotcloud/docker/docs/sources/index/variable.rst: -------------------------------------------------------------------------------- 1 | :title: Index Environment Variable 2 | :description: Setting this environment variable on the docker server will change the URL docker index. 3 | :keywords: docker, index environment variable, documentation 4 | 5 | ================================= 6 | Docker Index Environment Variable 7 | ================================= 8 | 9 | Variable 10 | -------- 11 | 12 | .. code-block:: sh 13 | 14 | DOCKER_INDEX_URL 15 | 16 | Setting this environment variable on the docker server will change the URL docker index. 17 | This address is used in commands such as ``docker login``, ``docker push`` and ``docker pull``. 18 | The docker daemon doesn't need to be restarted for this parameter to take effect. 19 | 20 | Example 21 | ------- 22 | 23 | .. code-block:: sh 24 | 25 | docker -d & 26 | export DOCKER_INDEX_URL="https://index.docker.io" 27 | 28 | -------------------------------------------------------------------------------- /src/github.com/dotcloud/docker/docs/sources/installation/amazon.rst: -------------------------------------------------------------------------------- 1 | :title: Installation on Amazon EC2 2 | :description: Docker installation on Amazon EC2 with a single vagrant command. Vagrant 1.1 or higher is required. 3 | :keywords: amazon ec2, virtualization, cloud, docker, documentation, installation 4 | 5 | Amazon EC2 6 | ========== 7 | 8 | Please note this is a community contributed installation path. The only 'official' installation is using the 9 | :ref:`ubuntu_linux` installation path. This version may sometimes be out of date. 10 | 11 | 12 | Installation 13 | ------------ 14 | 15 | Docker can now be installed on Amazon EC2 with a single vagrant command. Vagrant 1.1 or higher is required. 16 | 17 | 1. Install vagrant from http://www.vagrantup.com/ (or use your package manager) 18 | 2. Install the vagrant aws plugin 19 | 20 | :: 21 | 22 | vagrant plugin install vagrant-aws 23 | 24 | 25 | 3. Get the docker sources, this will give you the latest Vagrantfile. 26 | 27 | :: 28 | 29 | git clone https://github.com/dotcloud/docker.git 30 | 31 | 32 | 4. Check your AWS environment. 33 | 34 | Create a keypair specifically for EC2, give it a name and save it to your disk. *I usually store these in my ~/.ssh/ folder*. 35 | 36 | Check that your default security group has an inbound rule to accept SSH (port 22) connections. 37 | 38 | 39 | 40 | 5. Inform Vagrant of your settings 41 | 42 | Vagrant will read your access credentials from your environment, so we need to set them there first. Make sure 43 | you have everything on amazon aws setup so you can (manually) deploy a new image to EC2. 44 | 45 | :: 46 | 47 | export AWS_ACCESS_KEY_ID=xxx 48 | export AWS_SECRET_ACCESS_KEY=xxx 49 | export AWS_KEYPAIR_NAME=xxx 50 | export AWS_SSH_PRIVKEY=xxx 51 | 52 | The environment variables are: 53 | 54 | * ``AWS_ACCESS_KEY_ID`` - The API key used to make requests to AWS 55 | * ``AWS_SECRET_ACCESS_KEY`` - The secret key to make AWS API requests 56 | * ``AWS_KEYPAIR_NAME`` - The name of the keypair used for this EC2 instance 57 | * ``AWS_SSH_PRIVKEY`` - The path to the private key for the named keypair, for example ``~/.ssh/docker.pem`` 58 | 59 | You can check if they are set correctly by doing something like 60 | 61 | :: 62 | 63 | echo $AWS_ACCESS_KEY_ID 64 | 65 | 6. Do the magic! 66 | 67 | :: 68 | 69 | vagrant up --provider=aws 70 | 71 | 72 | If it stalls indefinitely on ``[default] Waiting for SSH to become available...``, Double check your default security 73 | zone on AWS includes rights to SSH (port 22) to your container. 74 | 75 | If you have an advanced AWS setup, you might want to have a look at https://github.com/mitchellh/vagrant-aws 76 | 77 | 7. Connect to your machine 78 | 79 | .. code-block:: bash 80 | 81 | vagrant ssh 82 | 83 | 8. Your first command 84 | 85 | Now you are in the VM, run docker 86 | 87 | .. code-block:: bash 88 | 89 | docker 90 | 91 | 92 | Continue with the :ref:`hello_world` example. -------------------------------------------------------------------------------- /src/github.com/dotcloud/docker/docs/sources/installation/archlinux.rst: -------------------------------------------------------------------------------- 1 | :title: Installation on Arch Linux 2 | :description: Docker installation on Arch Linux. 3 | :keywords: arch linux, virtualization, docker, documentation, installation 4 | 5 | .. _arch_linux: 6 | 7 | Arch Linux 8 | ========== 9 | 10 | Please note this is a community contributed installation path. The only 'official' installation is using the 11 | :ref:`ubuntu_linux` installation path. This version may sometimes be out of date. 12 | 13 | 14 | Installing on Arch Linux is not officially supported but can be handled via 15 | either of the following AUR packages: 16 | 17 | * `lxc-docker `_ 18 | * `lxc-docker-git `_ 19 | 20 | The lxc-docker package will install the latest tagged version of docker. 21 | The lxc-docker-git package will build from the current master branch. 22 | 23 | Dependencies 24 | ------------ 25 | 26 | Docker depends on several packages which are specified as dependencies in 27 | either AUR package. 28 | 29 | * aufs3 30 | * bridge-utils 31 | * go 32 | * iproute2 33 | * linux-aufs_friendly 34 | * lxc 35 | 36 | Installation 37 | ------------ 38 | 39 | The instructions here assume **yaourt** is installed. See 40 | `Arch User Repository `_ 41 | for information on building and installing packages from the AUR if you have not 42 | done so before. 43 | 44 | Keep in mind that if **linux-aufs_friendly** is not already installed that a 45 | new kernel will be compiled and this can take quite a while. 46 | 47 | :: 48 | 49 | yaourt -S lxc-docker-git 50 | 51 | 52 | Starting Docker 53 | --------------- 54 | 55 | Prior to starting docker modify your bootloader to use the 56 | **linux-aufs_friendly** kernel and reboot your system. 57 | 58 | There is a systemd service unit created for docker. To start the docker service: 59 | 60 | :: 61 | 62 | sudo systemctl start docker 63 | 64 | 65 | To start on system boot: 66 | 67 | :: 68 | 69 | sudo systemctl enable docker 70 | 71 | Network Configuration 72 | --------------------- 73 | 74 | IPv4 packet forwarding is disabled by default on Arch, so internet access from inside 75 | the container may not work. 76 | 77 | To enable the forwarding, run as root on the host system: 78 | 79 | :: 80 | 81 | sysctl net.ipv4.ip_forward=1 82 | 83 | And, to make it persistent across reboots, enable it on the host's **/etc/sysctl.conf**: 84 | 85 | :: 86 | 87 | net.ipv4.ip_forward=1 88 | -------------------------------------------------------------------------------- /src/github.com/dotcloud/docker/docs/sources/installation/binaries.rst: -------------------------------------------------------------------------------- 1 | :title: Installation from Binaries 2 | :description: This instruction set is meant for hackers who want to try out Docker on a variety of environments. 3 | :keywords: binaries, installation, docker, documentation, linux 4 | 5 | .. _binaries: 6 | 7 | Binaries 8 | ======== 9 | 10 | **Please note this project is currently under heavy development. It should not be used in production.** 11 | 12 | **This instruction set is meant for hackers who want to try out Docker on a variety of environments.** 13 | 14 | Right now, the officially supported distributions are: 15 | 16 | - :ref:`ubuntu_precise` 17 | - :ref:`ubuntu_raring` 18 | 19 | 20 | But we know people have had success running it under 21 | 22 | - Debian 23 | - Suse 24 | - :ref:`arch_linux` 25 | 26 | 27 | Dependencies: 28 | ------------- 29 | 30 | * 3.8 Kernel (read more about :ref:`kernel`) 31 | * AUFS filesystem support 32 | * lxc 33 | * bsdtar 34 | 35 | 36 | Get the docker binary: 37 | ---------------------- 38 | 39 | .. code-block:: bash 40 | 41 | wget http://get.docker.io/builds/Linux/x86_64/docker-latest.tgz 42 | tar -xf docker-latest.tgz 43 | 44 | 45 | Run the docker daemon 46 | --------------------- 47 | 48 | .. code-block:: bash 49 | 50 | # start the docker in daemon mode from the directory you unpacked 51 | sudo ./docker -d & 52 | 53 | 54 | Run your first container! 55 | ------------------------- 56 | 57 | .. code-block:: bash 58 | 59 | # check your docker version 60 | ./docker version 61 | 62 | # run a container and open an interactive shell in the container 63 | ./docker run -i -t ubuntu /bin/bash 64 | 65 | 66 | 67 | Continue with the :ref:`hello_world` example. 68 | -------------------------------------------------------------------------------- /src/github.com/dotcloud/docker/docs/sources/installation/images/win/_01.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coreos/systemd-rest/1cbd0a6a5de82a36b5ca9117297d8e152a133e4f/src/github.com/dotcloud/docker/docs/sources/installation/images/win/_01.gif -------------------------------------------------------------------------------- /src/github.com/dotcloud/docker/docs/sources/installation/images/win/_02.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coreos/systemd-rest/1cbd0a6a5de82a36b5ca9117297d8e152a133e4f/src/github.com/dotcloud/docker/docs/sources/installation/images/win/_02.gif -------------------------------------------------------------------------------- /src/github.com/dotcloud/docker/docs/sources/installation/images/win/_06.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coreos/systemd-rest/1cbd0a6a5de82a36b5ca9117297d8e152a133e4f/src/github.com/dotcloud/docker/docs/sources/installation/images/win/_06.gif -------------------------------------------------------------------------------- /src/github.com/dotcloud/docker/docs/sources/installation/images/win/cygwin.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coreos/systemd-rest/1cbd0a6a5de82a36b5ca9117297d8e152a133e4f/src/github.com/dotcloud/docker/docs/sources/installation/images/win/cygwin.gif -------------------------------------------------------------------------------- /src/github.com/dotcloud/docker/docs/sources/installation/images/win/putty.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coreos/systemd-rest/1cbd0a6a5de82a36b5ca9117297d8e152a133e4f/src/github.com/dotcloud/docker/docs/sources/installation/images/win/putty.gif -------------------------------------------------------------------------------- /src/github.com/dotcloud/docker/docs/sources/installation/images/win/putty_2.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coreos/systemd-rest/1cbd0a6a5de82a36b5ca9117297d8e152a133e4f/src/github.com/dotcloud/docker/docs/sources/installation/images/win/putty_2.gif -------------------------------------------------------------------------------- /src/github.com/dotcloud/docker/docs/sources/installation/images/win/run_02_.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coreos/systemd-rest/1cbd0a6a5de82a36b5ca9117297d8e152a133e4f/src/github.com/dotcloud/docker/docs/sources/installation/images/win/run_02_.gif -------------------------------------------------------------------------------- /src/github.com/dotcloud/docker/docs/sources/installation/images/win/run_03.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coreos/systemd-rest/1cbd0a6a5de82a36b5ca9117297d8e152a133e4f/src/github.com/dotcloud/docker/docs/sources/installation/images/win/run_03.gif -------------------------------------------------------------------------------- /src/github.com/dotcloud/docker/docs/sources/installation/images/win/run_04.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coreos/systemd-rest/1cbd0a6a5de82a36b5ca9117297d8e152a133e4f/src/github.com/dotcloud/docker/docs/sources/installation/images/win/run_04.gif -------------------------------------------------------------------------------- /src/github.com/dotcloud/docker/docs/sources/installation/images/win/ssh-config.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coreos/systemd-rest/1cbd0a6a5de82a36b5ca9117297d8e152a133e4f/src/github.com/dotcloud/docker/docs/sources/installation/images/win/ssh-config.gif -------------------------------------------------------------------------------- /src/github.com/dotcloud/docker/docs/sources/installation/index.rst: -------------------------------------------------------------------------------- 1 | :title: Documentation 2 | :description: -- todo: change me 3 | :keywords: todo, docker, documentation, installation, OS support 4 | 5 | 6 | 7 | Installation 8 | ============ 9 | 10 | Contents: 11 | 12 | .. toctree:: 13 | :maxdepth: 1 14 | 15 | ubuntulinux 16 | binaries 17 | vagrant 18 | windows 19 | amazon 20 | rackspace 21 | archlinux 22 | upgrading 23 | kernel 24 | -------------------------------------------------------------------------------- /src/github.com/dotcloud/docker/docs/sources/installation/upgrading.rst: -------------------------------------------------------------------------------- 1 | :title: Upgrading 2 | :description: These instructions are for upgrading Docker 3 | :keywords: Docker, Docker documentation, upgrading docker, upgrade 4 | 5 | .. _upgrading: 6 | 7 | Upgrading 8 | ============ 9 | 10 | **These instructions are for upgrading Docker** 11 | 12 | 13 | After normal installation 14 | ------------------------- 15 | 16 | If you installed Docker normally using apt-get or used Vagrant, use apt-get to upgrade. 17 | 18 | .. code-block:: bash 19 | 20 | # update your sources list 21 | sudo apt-get update 22 | 23 | # install the latest 24 | sudo apt-get install lxc-docker 25 | 26 | 27 | After manual installation 28 | ------------------------- 29 | 30 | If you installed the Docker binary 31 | 32 | 33 | .. code-block:: bash 34 | 35 | # kill the running docker daemon 36 | killall docker 37 | 38 | 39 | .. code-block:: bash 40 | 41 | # get the latest binary 42 | wget http://get.docker.io/builds/Linux/x86_64/docker-latest.tgz 43 | 44 | 45 | .. code-block:: bash 46 | 47 | # Unpack it to your current dir 48 | tar -xf docker-latest.tgz 49 | 50 | 51 | Start docker in daemon mode (-d) and disconnect (&) starting ./docker will start the version in your current dir rather than a version which 52 | might reside in your path. 53 | 54 | .. code-block:: bash 55 | 56 | # start the new version 57 | sudo ./docker -d & 58 | 59 | 60 | Alternatively you can replace the docker binary in ``/usr/local/bin`` 61 | -------------------------------------------------------------------------------- /src/github.com/dotcloud/docker/docs/sources/installation/vagrant.rst: -------------------------------------------------------------------------------- 1 | :title: Using Vagrant (Mac, Linux) 2 | :description: This guide will setup a new virtualbox virtual machine with docker installed on your computer. 3 | :keywords: Docker, Docker documentation, virtualbox, vagrant, git, ssh, putty, cygwin 4 | 5 | .. _install_using_vagrant: 6 | 7 | Using Vagrant (Mac, Linux) 8 | ========================== 9 | 10 | This guide will setup a new virtualbox virtual machine with docker installed on your computer. This works on most operating 11 | systems, including MacOX, Windows, Linux, FreeBSD and others. If you can install these and have at least 400Mb RAM 12 | to spare you should be good. 13 | 14 | 15 | Install Vagrant and Virtualbox 16 | ------------------------------ 17 | 18 | 1. Install virtualbox from https://www.virtualbox.org/ (or use your package manager) 19 | 2. Install vagrant from http://www.vagrantup.com/ (or use your package manager) 20 | 3. Install git if you had not installed it before, check if it is installed by running 21 | ``git`` in a terminal window 22 | 23 | 24 | Spin it up 25 | ---------- 26 | 27 | 1. Fetch the docker sources (this includes the Vagrantfile for machine setup). 28 | 29 | .. code-block:: bash 30 | 31 | git clone https://github.com/dotcloud/docker.git 32 | 33 | 2. Run vagrant from the sources directory 34 | 35 | .. code-block:: bash 36 | 37 | vagrant up 38 | 39 | Vagrant will: 40 | 41 | * Download the 'official' Precise64 base ubuntu virtual machine image from vagrantup.com 42 | * Boot this image in virtualbox 43 | * Add the `Docker PPA sources `_ to /etc/apt/sources.lst 44 | * Update your sources 45 | * Install lxc-docker 46 | 47 | You now have a Ubuntu Virtual Machine running with docker pre-installed. 48 | 49 | Connect 50 | ------- 51 | 52 | To access the VM and use Docker, Run ``vagrant ssh`` from the same directory as where you ran 53 | ``vagrant up``. Vagrant will connect you to the correct VM. 54 | 55 | .. code-block:: bash 56 | 57 | vagrant ssh 58 | 59 | Run 60 | ----- 61 | 62 | Now you are in the VM, run docker 63 | 64 | .. code-block:: bash 65 | 66 | docker 67 | 68 | 69 | Continue with the :ref:`hello_world` example. 70 | -------------------------------------------------------------------------------- /src/github.com/dotcloud/docker/docs/sources/static_files/README.md: -------------------------------------------------------------------------------- 1 | Static files dir 2 | ================ 3 | 4 | Files you put in /sources/static_files/ will be copied to the web visible /_static/ 5 | 6 | Be careful not to override pre-existing static files from the template. 7 | 8 | Generally, layout related files should go in the /theme directory. 9 | 10 | If you want to add images to your particular documentation page. Just put them next to 11 | your .rst source file and reference them relatively. -------------------------------------------------------------------------------- /src/github.com/dotcloud/docker/docs/sources/static_files/docker_pull_chart.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coreos/systemd-rest/1cbd0a6a5de82a36b5ca9117297d8e152a133e4f/src/github.com/dotcloud/docker/docs/sources/static_files/docker_pull_chart.png -------------------------------------------------------------------------------- /src/github.com/dotcloud/docker/docs/sources/static_files/docker_push_chart.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coreos/systemd-rest/1cbd0a6a5de82a36b5ca9117297d8e152a133e4f/src/github.com/dotcloud/docker/docs/sources/static_files/docker_push_chart.png -------------------------------------------------------------------------------- /src/github.com/dotcloud/docker/docs/sources/toctree.rst: -------------------------------------------------------------------------------- 1 | :title: Documentation 2 | :description: -- todo: change me 3 | :keywords: todo, docker, documentation, installation, usage, examples, contributing, faq, command line, concepts 4 | 5 | Documentation 6 | ============= 7 | 8 | This documentation has the following resources: 9 | 10 | .. toctree:: 11 | :titlesonly: 12 | 13 | concepts/index 14 | installation/index 15 | use/index 16 | examples/index 17 | commandline/index 18 | contributing/index 19 | api/index 20 | faq 21 | 22 | .. image:: concepts/images/lego_docker.jpg 23 | -------------------------------------------------------------------------------- /src/github.com/dotcloud/docker/docs/sources/use/index.rst: -------------------------------------------------------------------------------- 1 | :title: Documentation 2 | :description: -- todo: change me 3 | :keywords: todo, docker, documentation, basic, builder 4 | 5 | 6 | 7 | Use 8 | ======== 9 | 10 | Contents: 11 | 12 | .. toctree:: 13 | :maxdepth: 1 14 | 15 | basics 16 | workingwithrepository 17 | builder 18 | puppet 19 | 20 | -------------------------------------------------------------------------------- /src/github.com/dotcloud/docker/docs/sources/use/workingwithrepository.rst: -------------------------------------------------------------------------------- 1 | :title: Working With Repositories 2 | :description: Generally, there are two types of repositories: Top-level repositories which are controlled by the people behind Docker, and user repositories. 3 | :keywords: repo, repositiores, usage, pull image, push image, image, documentation 4 | 5 | .. _working_with_the_repository: 6 | 7 | Working with the Repository 8 | =========================== 9 | 10 | 11 | Top-level repositories and user repositories 12 | -------------------------------------------- 13 | 14 | Generally, there are two types of repositories: Top-level repositories which are controlled by the people behind 15 | Docker, and user repositories. 16 | 17 | * Top-level repositories can easily be recognized by not having a ``/`` (slash) in their name. These repositories can 18 | generally be trusted. 19 | * User repositories always come in the form of ``/``. This is what your published images will look like. 20 | * User images are not checked, it is therefore up to you whether or not you trust the creator of this image. 21 | 22 | 23 | Find public images available on the index 24 | ----------------------------------------- 25 | 26 | Seach by name, namespace or description 27 | 28 | .. code-block:: bash 29 | 30 | docker search 31 | 32 | 33 | Download them simply by their name 34 | 35 | .. code-block:: bash 36 | 37 | docker pull 38 | 39 | 40 | Very similarly you can search for and browse the index online on https://index.docker.io 41 | 42 | 43 | Connecting to the repository 44 | ---------------------------- 45 | 46 | You can create a user on the central docker repository online, or by running 47 | 48 | .. code-block:: bash 49 | 50 | docker login 51 | 52 | 53 | If your username does not exist it will prompt you to also enter a password and your e-mail address. It will then 54 | automatically log you in. 55 | 56 | 57 | Committing a container to a named image 58 | --------------------------------------- 59 | 60 | In order to commit to the repository it is required to have committed your container to an image with your namespace. 61 | 62 | .. code-block:: bash 63 | 64 | # for example docker commit $CONTAINER_ID dhrp/kickassapp 65 | docker commit / 66 | 67 | 68 | Pushing a container to the repository 69 | ----------------------------------------- 70 | 71 | In order to push an image to the repository you need to have committed your container to a named image (see above) 72 | 73 | Now you can commit this image to the repository 74 | 75 | .. code-block:: bash 76 | 77 | # for example docker push dhrp/kickassapp 78 | docker push 79 | 80 | -------------------------------------------------------------------------------- /src/github.com/dotcloud/docker/docs/theme/MAINTAINERS: -------------------------------------------------------------------------------- 1 | Thatcher Penskens 2 | -------------------------------------------------------------------------------- /src/github.com/dotcloud/docker/docs/theme/docker/static/css/variables.css: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coreos/systemd-rest/1cbd0a6a5de82a36b5ca9117297d8e152a133e4f/src/github.com/dotcloud/docker/docs/theme/docker/static/css/variables.css -------------------------------------------------------------------------------- /src/github.com/dotcloud/docker/docs/theme/docker/static/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coreos/systemd-rest/1cbd0a6a5de82a36b5ca9117297d8e152a133e4f/src/github.com/dotcloud/docker/docs/theme/docker/static/favicon.ico -------------------------------------------------------------------------------- /src/github.com/dotcloud/docker/docs/theme/docker/static/img/docker-letters-logo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coreos/systemd-rest/1cbd0a6a5de82a36b5ca9117297d8e152a133e4f/src/github.com/dotcloud/docker/docs/theme/docker/static/img/docker-letters-logo.gif -------------------------------------------------------------------------------- /src/github.com/dotcloud/docker/docs/theme/docker/static/img/docker_letters_500px.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coreos/systemd-rest/1cbd0a6a5de82a36b5ca9117297d8e152a133e4f/src/github.com/dotcloud/docker/docs/theme/docker/static/img/docker_letters_500px.png -------------------------------------------------------------------------------- /src/github.com/dotcloud/docker/docs/theme/docker/static/img/docs-splash-colhead320.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coreos/systemd-rest/1cbd0a6a5de82a36b5ca9117297d8e152a133e4f/src/github.com/dotcloud/docker/docs/theme/docker/static/img/docs-splash-colhead320.png -------------------------------------------------------------------------------- /src/github.com/dotcloud/docker/docs/theme/docker/static/img/footer-links.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coreos/systemd-rest/1cbd0a6a5de82a36b5ca9117297d8e152a133e4f/src/github.com/dotcloud/docker/docs/theme/docker/static/img/footer-links.png -------------------------------------------------------------------------------- /src/github.com/dotcloud/docker/docs/theme/docker/static/img/fork-us.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coreos/systemd-rest/1cbd0a6a5de82a36b5ca9117297d8e152a133e4f/src/github.com/dotcloud/docker/docs/theme/docker/static/img/fork-us.png -------------------------------------------------------------------------------- /src/github.com/dotcloud/docker/docs/theme/docker/static/img/glyphicons-halflings-white.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coreos/systemd-rest/1cbd0a6a5de82a36b5ca9117297d8e152a133e4f/src/github.com/dotcloud/docker/docs/theme/docker/static/img/glyphicons-halflings-white.png -------------------------------------------------------------------------------- /src/github.com/dotcloud/docker/docs/theme/docker/static/img/glyphicons-halflings.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coreos/systemd-rest/1cbd0a6a5de82a36b5ca9117297d8e152a133e4f/src/github.com/dotcloud/docker/docs/theme/docker/static/img/glyphicons-halflings.png -------------------------------------------------------------------------------- /src/github.com/dotcloud/docker/docs/theme/docker/static/img/hiring_graphic.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coreos/systemd-rest/1cbd0a6a5de82a36b5ca9117297d8e152a133e4f/src/github.com/dotcloud/docker/docs/theme/docker/static/img/hiring_graphic.png -------------------------------------------------------------------------------- /src/github.com/dotcloud/docker/docs/theme/docker/static/js/docs.js: -------------------------------------------------------------------------------- 1 | 2 | $(function(){ 3 | 4 | // init multi-vers stuff 5 | $('.tabswitcher').each(function(i, multi_vers){ 6 | var tabs = $('
    '); 7 | $(multi_vers).prepend(tabs); 8 | $(multi_vers).children('.tab').each(function(j, vers_content){ 9 | vers = $(vers_content).children(':first').text(); 10 | var id = 'multi_vers_' + '_' + i + '_' + j; 11 | $(vers_content).attr('id', id); 12 | $(tabs).append('
  • ' + vers + '
  • '); 13 | }); 14 | }); 15 | $( ".tabswitcher" ).tabs(); 16 | 17 | // sidebar acordian-ing 18 | // don't apply on last object (it should be the FAQ) 19 | $('nav > ul > li > a').not(':last').click(function(){ 20 | if ($(this).parent().hasClass('current')) { 21 | $(this).parent().children('ul').slideUp(200, function() { 22 | $(this).parent().removeClass('current'); // toggle after effect 23 | }); 24 | } else { 25 | $('nav > ul > li > ul').slideUp(100); 26 | var current = $(this); 27 | setTimeout(function() { 28 | $('nav > ul > li').removeClass('current'); 29 | current.parent().addClass('current'); // toggle before effect 30 | current.parent().children('ul').hide(); 31 | current.parent().children('ul').slideDown(200); 32 | }, 100); 33 | } 34 | return false; 35 | }); 36 | 37 | }); -------------------------------------------------------------------------------- /src/github.com/dotcloud/docker/docs/theme/docker/static/js/jquery.ba-urlinternal.min.js: -------------------------------------------------------------------------------- 1 | /* 2 | * urlInternal - v1.0 - 10/7/2009 3 | * http://benalman.com/projects/jquery-urlinternal-plugin/ 4 | * 5 | * Copyright (c) 2009 "Cowboy" Ben Alman 6 | * Dual licensed under the MIT and GPL licenses. 7 | * http://benalman.com/about/license/ 8 | */ 9 | (function($){var g,i=!0,r=!1,m=window.location,h=Array.prototype.slice,b=m.href.match(/^((https?:\/\/.*?\/)?[^#]*)#?.*$/),u=b[1]+"#",t=b[2],e,l,f,q,c,j,x="elemUrlAttr",k="href",y="src",p="urlInternal",d="urlExternal",n="urlFragment",a,s={};function w(A){var z=h.call(arguments,1);return function(){return A.apply(this,z.concat(h.call(arguments)))}}$.isUrlInternal=q=function(z){if(!z||j(z)){return g}if(a.test(z)){return i}if(/^(?:https?:)?\/\//i.test(z)){return r}if(/^[a-z\d.-]+:/i.test(z)){return g}return i};$.isUrlExternal=c=function(z){var A=q(z);return typeof A==="boolean"?!A:A};$.isUrlFragment=j=function(z){var A=(z||"").match(/^([^#]?)([^#]*#).*$/);return !!A&&(A[2]==="#"||z.indexOf(u)===0||(A[1]==="/"?t+A[2]===u:!/^https?:\/\//i.test(z)&&$('')[0].href.indexOf(u)===0))};function v(A,z){return this.filter(":"+A+(z?"("+z+")":""))}$.fn[p]=w(v,p);$.fn[d]=w(v,d);$.fn[n]=w(v,n);function o(D,C,B,A){var z=A[3]||e()[(C.nodeName||"").toLowerCase()]||"";return z?!!D(C.getAttribute(z)):r}$.expr[":"][p]=w(o,q);$.expr[":"][d]=w(o,c);$.expr[":"][n]=w(o,j);$[x]||($[x]=function(z){return $.extend(s,z)})({a:k,base:k,iframe:y,img:y,input:y,form:"action",link:k,script:y});e=$[x];$.urlInternalHost=l=function(B){B=B?"(?:(?:"+Array.prototype.join.call(arguments,"|")+")\\.)?":"";var A=new RegExp("^"+B+"(.*)","i"),z="^(?:"+m.protocol+")?//"+m.hostname.replace(A,B+"$1").replace(/\\?\./g,"\\.")+(m.port?":"+m.port:"")+"/";return f(z)};$.urlInternalRegExp=f=function(z){if(z){a=typeof z==="string"?new RegExp(z,"i"):z}return a};l("www")})(jQuery); -------------------------------------------------------------------------------- /src/github.com/dotcloud/docker/docs/theme/docker/static/js/main.js: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /src/github.com/dotcloud/docker/docs/theme/docker/theme.conf: -------------------------------------------------------------------------------- 1 | [theme] 2 | inherit = basic 3 | pygments_style = monokai 4 | 5 | [options] 6 | full_logo = true 7 | textcolor = #444444 8 | headingcolor = #0c3762 9 | linkcolor = #8C7B65 10 | visitedlinkcolor = #AFA599 11 | hoverlinkcolor = #4e4334 12 | -------------------------------------------------------------------------------- /src/github.com/dotcloud/docker/docs/website/MAINTAINERS: -------------------------------------------------------------------------------- 1 | Thatcher Penskens 2 | -------------------------------------------------------------------------------- /src/github.com/dotcloud/docker/docs/website/dotcloud.yml: -------------------------------------------------------------------------------- 1 | www: 2 | type: static -------------------------------------------------------------------------------- /src/github.com/dotcloud/docker/docs/website/nginx.conf: -------------------------------------------------------------------------------- 1 | 2 | # rule to redirect original links created when hosted on github pages 3 | rewrite ^/documentation/(.*).html http://docs.docker.io/en/latest/$1/ permanent; 4 | 5 | # rewrite the stuff which was on the current page 6 | rewrite ^/gettingstarted.html$ /gettingstarted/ permanent; 7 | -------------------------------------------------------------------------------- /src/github.com/dotcloud/docker/docs/website/static: -------------------------------------------------------------------------------- 1 | ../theme/docker/static -------------------------------------------------------------------------------- /src/github.com/dotcloud/docker/getKernelVersion_darwin.go: -------------------------------------------------------------------------------- 1 | package docker 2 | 3 | import ( 4 | "fmt" 5 | "github.com/dotcloud/docker/utils" 6 | ) 7 | 8 | func getKernelVersion() (*utils.KernelVersionInfo, error) { 9 | return nil, fmt.Errorf("Kernel version detection is not available on darwin") 10 | } 11 | -------------------------------------------------------------------------------- /src/github.com/dotcloud/docker/getKernelVersion_linux.go: -------------------------------------------------------------------------------- 1 | package docker 2 | 3 | import ( 4 | "bytes" 5 | "github.com/dotcloud/docker/utils" 6 | "strconv" 7 | "strings" 8 | "syscall" 9 | ) 10 | 11 | // FIXME: Move this to utils package 12 | func getKernelVersion() (*utils.KernelVersionInfo, error) { 13 | var ( 14 | uts syscall.Utsname 15 | flavor string 16 | kernel, major, minor int 17 | err error 18 | ) 19 | 20 | if err := syscall.Uname(&uts); err != nil { 21 | return nil, err 22 | } 23 | 24 | release := make([]byte, len(uts.Release)) 25 | 26 | i := 0 27 | for _, c := range uts.Release { 28 | release[i] = byte(c) 29 | i++ 30 | } 31 | 32 | // Remove the \x00 from the release for Atoi to parse correctly 33 | release = release[:bytes.IndexByte(release, 0)] 34 | 35 | tmp := strings.SplitN(string(release), "-", 2) 36 | tmp2 := strings.SplitN(tmp[0], ".", 3) 37 | 38 | if len(tmp2) > 0 { 39 | kernel, err = strconv.Atoi(tmp2[0]) 40 | if err != nil { 41 | return nil, err 42 | } 43 | } 44 | 45 | if len(tmp2) > 1 { 46 | major, err = strconv.Atoi(tmp2[1]) 47 | if err != nil { 48 | return nil, err 49 | } 50 | } 51 | 52 | if len(tmp2) > 2 { 53 | minor, err = strconv.Atoi(tmp2[2]) 54 | if err != nil { 55 | return nil, err 56 | } 57 | } 58 | 59 | if len(tmp) == 2 { 60 | flavor = tmp[1] 61 | } else { 62 | flavor = "" 63 | } 64 | 65 | return &utils.KernelVersionInfo{ 66 | Kernel: kernel, 67 | Major: major, 68 | Minor: minor, 69 | Flavor: flavor, 70 | }, nil 71 | } 72 | -------------------------------------------------------------------------------- /src/github.com/dotcloud/docker/hack/PRINCIPLES.md: -------------------------------------------------------------------------------- 1 | # Docker principles 2 | 3 | In the design and development of Docker we try to follow these principles: 4 | 5 | (Work in progress) 6 | 7 | * Don't try to replace every tool. Instead, be an ingredient to improve them. 8 | * Less code is better. 9 | * Less components is better. Do you really need to add one more class? 10 | * 50 lines of straightforward, readable code is better than 10 lines of magic that nobody can understand. 11 | * Don't do later what you can do now. "//FIXME: refactor" is not acceptable in new code. 12 | * When hesitating between 2 options, choose the one that is easier to reverse. 13 | * No is temporary, Yes is forever. If you're not sure about a new feature, say no. You can change your mind later. 14 | * Containers must be portable to the greatest possible number of machines. Be suspicious of any change which makes machines less interchangeable. 15 | * The less moving parts in a container, the better. 16 | * Don't merge it unless you document it. 17 | * Don't document it unless you can keep it up-to-date. 18 | * Don't merge it unless you test it! 19 | * Everyone's problem is slightly different. Focus on the part that is the same for everyone, and solve that. 20 | -------------------------------------------------------------------------------- /src/github.com/dotcloud/docker/hack/README.rst: -------------------------------------------------------------------------------- 1 | This directory contains material helpful for hacking on docker. 2 | 3 | make hack 4 | ========= 5 | 6 | Set up an Ubuntu 13.04 virtual machine for developers including kernel 3.8 7 | and buildbot. The environment is setup in a way that can be used through 8 | the usual go workflow and/or the root Makefile. You can either edit on 9 | your host, or inside the VM (using make ssh-dev) and run and test docker 10 | inside the VM. 11 | 12 | dependencies: vagrant, virtualbox packages and python package requests 13 | 14 | 15 | Buildbot 16 | ~~~~~~~~ 17 | 18 | Buildbot is a continuous integration system designed to automate the 19 | build/test cycle. By automatically rebuilding and testing the tree each time 20 | something has changed, build problems are pinpointed quickly, before other 21 | developers are inconvenienced by the failure. 22 | 23 | When running 'make hack' at the docker root directory, it spawns a virtual 24 | machine in the background running a buildbot instance and adds a git 25 | post-commit hook that automatically run docker tests for you. 26 | 27 | You can check your buildbot instance at http://192.168.33.21:8010/waterfall 28 | -------------------------------------------------------------------------------- /src/github.com/dotcloud/docker/hack/Vagrantfile: -------------------------------------------------------------------------------- 1 | # -*- mode: ruby -*- 2 | # vi: set ft=ruby : 3 | 4 | BOX_NAME = "ubuntu-dev" 5 | BOX_URI = "http://cloud-images.ubuntu.com/raring/current/raring-server-cloudimg-vagrant-amd64-disk1.box" 6 | VM_IP = "192.168.33.21" 7 | USER = "vagrant" 8 | GOPATH = "/data/docker" 9 | DOCKER_PATH = "#{GOPATH}/src/github.com/dotcloud/docker" 10 | CFG_PATH = "#{DOCKER_PATH}/hack/environment" 11 | BUILDBOT_PATH = "/data/buildbot" 12 | 13 | Vagrant::Config.run do |config| 14 | # Setup virtual machine box 15 | config.vm.box = BOX_NAME 16 | config.vm.box_url = BOX_URI 17 | config.vm.share_folder "v-data", DOCKER_PATH, "#{File.dirname(__FILE__)}/.." 18 | config.vm.network :hostonly, VM_IP 19 | # Stop if deployment has been done 20 | config.vm.provision :shell, :inline => "[ ! -f /usr/bin/git ]" 21 | # Touch for makefile 22 | pkg_cmd = "touch #{DOCKER_PATH}; " 23 | # Install docker dependencies 24 | pkg_cmd << "export DEBIAN_FRONTEND=noninteractive; apt-get -qq update; " \ 25 | "apt-get install -q -y lxc bsdtar git golang make linux-image-extra-3.8.0-19-generic; " \ 26 | "chown -R #{USER}.#{USER} #{GOPATH}; " \ 27 | "install -m 0664 #{CFG_PATH}/bash_profile /home/#{USER}/.bash_profile" 28 | config.vm.provision :shell, :inline => pkg_cmd 29 | # Deploy buildbot CI 30 | pkg_cmd = "apt-get install -q -y python-dev python-pip supervisor; " \ 31 | "pip install -r #{CFG_PATH}/requirements.txt; " \ 32 | "chown #{USER}.#{USER} /data; cd /data; " \ 33 | "#{CFG_PATH}/setup.sh #{USER} #{GOPATH} #{DOCKER_PATH} #{CFG_PATH} #{BUILDBOT_PATH}" 34 | config.vm.provision :shell, :inline => pkg_cmd 35 | end 36 | -------------------------------------------------------------------------------- /src/github.com/dotcloud/docker/hack/allmaintainers.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | find $1 -name MAINTAINERS -exec cat {} ';' | sed -E -e 's/^[^:]*: *(.*)$/\1/' | grep -E -v -e '^ *$' -e '^ *#.*$' | sort -u 4 | -------------------------------------------------------------------------------- /src/github.com/dotcloud/docker/hack/dockerbuilder/Dockerfile: -------------------------------------------------------------------------------- 1 | # This will build a container capable of producing an official binary build of docker and 2 | # uploading it to S3 3 | from ubuntu:12.04 4 | maintainer Solomon Hykes 5 | # Workaround the upstart issue 6 | run dpkg-divert --local --rename --add /sbin/initctl 7 | run ln -s /bin/true /sbin/initctl 8 | # Enable universe and gophers PPA 9 | run DEBIAN_FRONTEND=noninteractive apt-get install -y -q python-software-properties 10 | run add-apt-repository "deb http://archive.ubuntu.com/ubuntu $(lsb_release -sc) universe" 11 | run add-apt-repository -y ppa:gophers/go/ubuntu 12 | run apt-get update 13 | # Packages required to checkout, build and upload docker 14 | run DEBIAN_FRONTEND=noninteractive apt-get install -y -q s3cmd 15 | run DEBIAN_FRONTEND=noninteractive apt-get install -y -q curl 16 | run curl -s -o /go.tar.gz https://go.googlecode.com/files/go1.1.1.linux-amd64.tar.gz 17 | run tar -C /usr/local -xzf /go.tar.gz 18 | run echo "export PATH=/usr/local/go/bin:$PATH" > /.bashrc 19 | run echo "export PATH=/usr/local/go/bin:$PATH" > /.bash_profile 20 | run DEBIAN_FRONTEND=noninteractive apt-get install -y -q git 21 | run DEBIAN_FRONTEND=noninteractive apt-get install -y -q build-essential 22 | # Packages required to build an ubuntu package 23 | run DEBIAN_FRONTEND=noninteractive apt-get install -y -q golang-stable 24 | run DEBIAN_FRONTEND=noninteractive apt-get install -y -q debhelper 25 | run DEBIAN_FRONTEND=noninteractive apt-get install -y -q autotools-dev 26 | run apt-get install -y -q devscripts 27 | # Copy dockerbuilder files into the container 28 | add . /src 29 | run cp /src/dockerbuilder /usr/local/bin/ && chmod +x /usr/local/bin/dockerbuilder 30 | run cp /src/s3cfg /.s3cfg 31 | cmd ["dockerbuilder"] 32 | -------------------------------------------------------------------------------- /src/github.com/dotcloud/docker/hack/dockerbuilder/MAINTAINERS: -------------------------------------------------------------------------------- 1 | Daniel Mizyrycki 2 | -------------------------------------------------------------------------------- /src/github.com/dotcloud/docker/hack/dockerbuilder/dockerbuilder: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -x 3 | set -e 4 | 5 | export PATH=/usr/local/go/bin:$PATH 6 | 7 | PACKAGE=github.com/dotcloud/docker 8 | 9 | if [ $# -gt 1 ]; then 10 | echo "Usage: $0 [REVISION]" 11 | exit 1 12 | fi 13 | 14 | export REVISION=$1 15 | 16 | if [ -z "$AWS_ID" ]; then 17 | echo "Warning: environment variable AWS_ID is not set. Won't upload to S3." 18 | fi 19 | 20 | if [ -z "$AWS_KEY" ]; then 21 | echo "Warning: environment variable AWS_KEY is not set. Won't upload to S3." 22 | fi 23 | 24 | if [ -z "$GPG_KEY" ]; then 25 | echo "Warning: environment variable GPG_KEY is not set. Ubuntu package upload will not succeed." 26 | NO_UBUNTU=1 27 | fi 28 | 29 | rm -fr docker-release 30 | git clone https://github.com/dotcloud/docker docker-release 31 | cd docker-release 32 | if [ -z "$REVISION" ]; then 33 | make release 34 | else 35 | make release RELEASE_VERSION=$REVISION 36 | fi 37 | 38 | if [ -z "$NO_UBUNTU" ]; then 39 | export PATH=`echo $PATH | sed 's#/usr/local/go/bin:##g'` 40 | (cd packaging/ubuntu && make ubuntu) 41 | fi 42 | -------------------------------------------------------------------------------- /src/github.com/dotcloud/docker/hack/dockerbuilder/s3cfg: -------------------------------------------------------------------------------- 1 | [default] 2 | access_key = $AWS_ID 3 | secret_key = $AWS_KEY 4 | -------------------------------------------------------------------------------- /src/github.com/dotcloud/docker/hack/environment/README.rst: -------------------------------------------------------------------------------- 1 | Files used to setup the developer virtual machine 2 | -------------------------------------------------------------------------------- /src/github.com/dotcloud/docker/hack/environment/bash_profile: -------------------------------------------------------------------------------- 1 | # ~/.bash_profile : executed by the command interpreter for login shells. 2 | 3 | # if running bash 4 | if [ -n "$BASH_VERSION" ]; then 5 | # include .bashrc if it exists 6 | if [ -f "$HOME/.bashrc" ]; then 7 | . "$HOME/.bashrc" 8 | fi 9 | fi 10 | 11 | # set PATH so it includes user's private bin if it exists 12 | [ -d "$HOME/bin" ] && PATH="$HOME/bin:$PATH" 13 | 14 | docker=/data/docker/src/github.com/dotcloud/docker 15 | [ -d $docker ] && cd $docker 16 | 17 | export GOPATH=/data/docker 18 | export PATH=$PATH:$GOPATH/bin 19 | 20 | -------------------------------------------------------------------------------- /src/github.com/dotcloud/docker/hack/environment/buildbot.conf: -------------------------------------------------------------------------------- 1 | [program:buildmaster] 2 | command=su vagrant -c "buildbot start master" 3 | directory=/data/buildbot 4 | chown= root:root 5 | redirect_stderr=true 6 | stdout_logfile=/var/log/supervisor/buildbot-master.log 7 | stderr_logfile=/var/log/supervisor/buildbot-master.log 8 | 9 | [program:buildworker] 10 | command=buildslave start slave 11 | directory=/data/buildbot 12 | chown= root:root 13 | redirect_stderr=true 14 | stdout_logfile=/var/log/supervisor/buildbot-slave.log 15 | stderr_logfile=/var/log/supervisor/buildbot-slave.log 16 | 17 | [group:buildbot] 18 | programs=buildmaster,buildworker 19 | -------------------------------------------------------------------------------- /src/github.com/dotcloud/docker/hack/environment/master.cfg: -------------------------------------------------------------------------------- 1 | import os 2 | from buildbot.buildslave import BuildSlave 3 | from buildbot.schedulers.forcesched import ForceScheduler 4 | from buildbot.config import BuilderConfig 5 | from buildbot.process.factory import BuildFactory 6 | from buildbot.steps.shell import ShellCommand 7 | from buildbot.status import html 8 | from buildbot.status.web import authz, auth 9 | 10 | PORT_WEB = 8010 # Buildbot webserver port 11 | PORT_MASTER = 9989 # Port where buildbot master listen buildworkers 12 | TEST_USER = 'buildbot' # Credential to authenticate build triggers 13 | TEST_PWD = 'docker' # Credential to authenticate build triggers 14 | BUILDER_NAME = 'docker' 15 | BUILDPASSWORD = 'pass-docker' # Credential to authenticate buildworkers 16 | GOPATH = '/data/docker' 17 | DOCKER_PATH = '{0}/src/github.com/dotcloud/docker'.format(GOPATH) 18 | 19 | c = BuildmasterConfig = {} 20 | 21 | c['title'] = "Docker" 22 | c['titleURL'] = "waterfall" 23 | c['buildbotURL'] = "http://localhost:{0}/".format(PORT_WEB) 24 | c['db'] = {'db_url':"sqlite:///state.sqlite"} 25 | c['slaves'] = [BuildSlave('buildworker', BUILDPASSWORD)] 26 | c['slavePortnum'] = PORT_MASTER 27 | 28 | c['schedulers'] = [ForceScheduler(name='trigger',builderNames=[BUILDER_NAME])] 29 | 30 | # Docker test command 31 | test_cmd = "GOPATH={0} make -C {1} test".format(GOPATH,DOCKER_PATH) 32 | 33 | # Builder 34 | factory = BuildFactory() 35 | factory.addStep(ShellCommand(description='Docker',logEnviron=False, 36 | usePTY=True,command=test_cmd)) 37 | c['builders'] = [BuilderConfig(name=BUILDER_NAME,slavenames=['buildworker'], 38 | factory=factory)] 39 | 40 | # Status 41 | authz_cfg=authz.Authz(auth=auth.BasicAuth([(TEST_USER,TEST_PWD)]), 42 | forceBuild='auth') 43 | c['status'] = [html.WebStatus(http_port=PORT_WEB, authz=authz_cfg)] 44 | -------------------------------------------------------------------------------- /src/github.com/dotcloud/docker/hack/environment/post-commit: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | '''Trigger buildbot docker test build 4 | 5 | post-commit git hook designed to automatically trigger buildbot on 6 | the provided vagrant docker VM.''' 7 | 8 | import requests 9 | 10 | USERNAME = 'buildbot' 11 | PASSWORD = 'docker' 12 | BASE_URL = 'http://localhost:8010' 13 | path = lambda s: BASE_URL + '/' + s 14 | 15 | try: 16 | session = requests.session() 17 | session.post(path('login'),data={'username':USERNAME,'passwd':PASSWORD}) 18 | session.post(path('builders/docker/force'), 19 | data={'forcescheduler':'trigger','reason':'Test commit'}) 20 | except: 21 | pass 22 | -------------------------------------------------------------------------------- /src/github.com/dotcloud/docker/hack/environment/requirements.txt: -------------------------------------------------------------------------------- 1 | sqlalchemy<=0.7.9 2 | sqlalchemy-migrate>=0.7.2 3 | buildbot==0.8.7p1 4 | buildbot_slave==0.8.7p1 5 | nose==1.2.1 6 | requests==1.1.0 7 | -------------------------------------------------------------------------------- /src/github.com/dotcloud/docker/hack/environment/setup.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Setup of buildbot configuration. Package installation is being done by 4 | # Vagrantfile 5 | # Dependencies: buildbot, buildbot-slave, supervisor 6 | 7 | USER=$1 8 | GOPATH=$2 9 | DOCKER_PATH=$3 10 | CFG_PATH=$4 11 | BUILDBOT_PATH=$5 12 | SLAVE_NAME="buildworker" 13 | SLAVE_SOCKET="localhost:9989" 14 | BUILDBOT_PWD="pass-docker" 15 | IP=$(sed -nE 's/VM_IP = "(.+)"/\1/p' ${DOCKER_PATH}/hack/Vagrantfile) 16 | export PATH="/bin:sbin:/usr/bin:/usr/sbin:/usr/local/bin" 17 | 18 | function run { su $USER -c "$1"; } 19 | 20 | # Exit if buildbot has already been installed 21 | [ -d "$BUILDBOT_PATH" ] && exit 0 22 | 23 | # Setup buildbot 24 | run "mkdir -p $BUILDBOT_PATH" 25 | cd $BUILDBOT_PATH 26 | run "buildbot create-master master" 27 | run "cp $CFG_PATH/master.cfg master" 28 | run "sed -i 's/localhost/$IP/' master/master.cfg" 29 | run "sed -i -E 's#(GOPATH = ).+#\1\"$GOPATH\"#' master/master.cfg" 30 | run "sed -i -E 's#(DOCKER_PATH = ).+#\1\"$DOCKER_PATH\"#' master/master.cfg" 31 | run "buildslave create-slave slave $SLAVE_SOCKET $SLAVE_NAME $BUILDBOT_PWD" 32 | 33 | # Allow buildbot subprocesses (docker tests) to properly run in containers, 34 | # in particular with docker -u 35 | run "sed -i 's/^umask = None/umask = 000/' slave/buildbot.tac" 36 | 37 | # Setup supervisor 38 | cp $CFG_PATH/buildbot.conf /etc/supervisor/conf.d/buildbot.conf 39 | sed -i -E "s/^chmod=0700.+/chmod=0770\nchown=root:$USER/" /etc/supervisor/supervisord.conf 40 | kill -HUP $(pgrep -f "/usr/bin/python /usr/bin/supervisord") 41 | 42 | # Add git hook 43 | cp $CFG_PATH/post-commit $DOCKER_PATH/.git/hooks 44 | sed -i "s/localhost/$IP/" $DOCKER_PATH/.git/hooks/post-commit 45 | 46 | -------------------------------------------------------------------------------- /src/github.com/dotcloud/docker/hack/fmt-check.hook: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # This pre-commit hook will abort if a committed file doesn't pass gofmt. 4 | # By Even Shaw 5 | # http://github.com/edsrzf/gofmt-git-hook 6 | 7 | test_fmt() { 8 | hash gofmt 2>&- || { echo >&2 "gofmt not in PATH."; exit 1; } 9 | IFS=' 10 | ' 11 | for file in `git diff --cached --name-only --diff-filter=ACM | grep '\.go$'` 12 | do 13 | output=`git cat-file -p :$file | gofmt -l 2>&1` 14 | if test $? -ne 0 15 | then 16 | output=`echo "$output" | sed "s,,$file,"` 17 | syntaxerrors="${list}${output}\n" 18 | elif test -n "$output" 19 | then 20 | list="${list}${file}\n" 21 | fi 22 | done 23 | exitcode=0 24 | if test -n "$syntaxerrors" 25 | then 26 | echo >&2 "gofmt found syntax errors:" 27 | printf "$syntaxerrors" 28 | exitcode=1 29 | fi 30 | if test -n "$list" 31 | then 32 | echo >&2 "gofmt needs to format these files (run gofmt -w and git add):" 33 | printf "$list" 34 | exitcode=1 35 | fi 36 | exit $exitcode 37 | } 38 | 39 | case "$1" in 40 | --about ) 41 | echo "Check Go code formatting" 42 | ;; 43 | * ) 44 | test_fmt 45 | ;; 46 | esac 47 | -------------------------------------------------------------------------------- /src/github.com/dotcloud/docker/hack/getmaintainer.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [ $# -ne 1 ]; then 4 | echo >&2 "Usage: $0 PATH" 5 | echo >&2 "Show the primary and secondary maintainers for a given path" 6 | exit 1 7 | fi 8 | 9 | set -e 10 | 11 | DEST=$1 12 | DESTFILE="" 13 | if [ ! -d $DEST ]; then 14 | DESTFILE=$(basename $DEST) 15 | DEST=$(dirname $DEST) 16 | fi 17 | 18 | MAINTAINERS=() 19 | cd $DEST 20 | while true; do 21 | if [ -e ./MAINTAINERS ]; then 22 | { 23 | while read line; do 24 | re='^([^:]*): *(.*)$' 25 | file=$(echo $line | sed -E -n "s/$re/\1/p") 26 | if [ ! -z "$file" ]; then 27 | if [ "$file" = "$DESTFILE" ]; then 28 | echo "Override: $line" 29 | maintainer=$(echo $line | sed -E -n "s/$re/\2/p") 30 | MAINTAINERS=("$maintainer" "${MAINTAINERS[@]}") 31 | fi 32 | else 33 | MAINTAINERS+=("$line"); 34 | fi 35 | done; 36 | } < MAINTAINERS 37 | fi 38 | if [ -d .git ]; then 39 | break 40 | fi 41 | if [ "$(pwd)" = "/" ]; then 42 | break 43 | fi 44 | cd .. 45 | done 46 | 47 | PRIMARY="${MAINTAINERS[0]}" 48 | PRIMARY_FIRSTNAME=$(echo $PRIMARY | cut -d' ' -f1) 49 | 50 | firstname() { 51 | echo $1 | cut -d' ' -f1 52 | } 53 | 54 | echo "--- $PRIMARY is the PRIMARY MAINTAINER of $1. Assign pull requests to him." 55 | echo "$(firstname $PRIMARY) may assign pull requests to the following secondary maintainers:" 56 | for SECONDARY in "${MAINTAINERS[@]:1}"; do 57 | echo "--- $SECONDARY" 58 | done 59 | -------------------------------------------------------------------------------- /src/github.com/dotcloud/docker/hack/infrastructure/MAINTAINERS: -------------------------------------------------------------------------------- 1 | Ken Cochrane 2 | Jerome Petazzoni 3 | -------------------------------------------------------------------------------- /src/github.com/dotcloud/docker/hack/infrastructure/README.md: -------------------------------------------------------------------------------- 1 | # Docker project infrastructure 2 | 3 | This directory holds all information about the technical infrastructure of the docker project; servers, dns, email, and all the corresponding tools and configuration. 4 | 5 | Obviously credentials should not be stored in this repo, but how to obtain and use them should be documented here. 6 | -------------------------------------------------------------------------------- /src/github.com/dotcloud/docker/mount.go: -------------------------------------------------------------------------------- 1 | package docker 2 | 3 | import ( 4 | "fmt" 5 | "os" 6 | "path/filepath" 7 | "syscall" 8 | "time" 9 | ) 10 | 11 | func Unmount(target string) error { 12 | if err := syscall.Unmount(target, 0); err != nil { 13 | return err 14 | } 15 | // Even though we just unmounted the filesystem, AUFS will prevent deleting the mntpoint 16 | // for some time. We'll just keep retrying until it succeeds. 17 | for retries := 0; retries < 1000; retries++ { 18 | err := os.Remove(target) 19 | if err == nil { 20 | // rm mntpoint succeeded 21 | return nil 22 | } 23 | if os.IsNotExist(err) { 24 | // mntpoint doesn't exist anymore. Success. 25 | return nil 26 | } 27 | // fmt.Printf("(%v) Remove %v returned: %v\n", retries, target, err) 28 | time.Sleep(10 * time.Millisecond) 29 | } 30 | return fmt.Errorf("Umount: Failed to umount %v", target) 31 | } 32 | 33 | func Mounted(mountpoint string) (bool, error) { 34 | mntpoint, err := os.Stat(mountpoint) 35 | if err != nil { 36 | if os.IsNotExist(err) { 37 | return false, nil 38 | } 39 | return false, err 40 | } 41 | parent, err := os.Stat(filepath.Join(mountpoint, "..")) 42 | if err != nil { 43 | return false, err 44 | } 45 | mntpointSt := mntpoint.Sys().(*syscall.Stat_t) 46 | parentSt := parent.Sys().(*syscall.Stat_t) 47 | return mntpointSt.Dev != parentSt.Dev, nil 48 | } 49 | -------------------------------------------------------------------------------- /src/github.com/dotcloud/docker/mount_darwin.go: -------------------------------------------------------------------------------- 1 | package docker 2 | 3 | import "errors" 4 | 5 | func mount(source string, target string, fstype string, flags uintptr, data string) (err error) { 6 | return errors.New("mount is not implemented on darwin") 7 | } 8 | -------------------------------------------------------------------------------- /src/github.com/dotcloud/docker/mount_linux.go: -------------------------------------------------------------------------------- 1 | package docker 2 | 3 | import "syscall" 4 | 5 | func mount(source string, target string, fstype string, flags uintptr, data string) (err error) { 6 | return syscall.Mount(source, target, fstype, flags, data) 7 | } 8 | -------------------------------------------------------------------------------- /src/github.com/dotcloud/docker/packaging/MAINTAINERS: -------------------------------------------------------------------------------- 1 | Daniel Mizyrycki 2 | -------------------------------------------------------------------------------- /src/github.com/dotcloud/docker/packaging/README.rst: -------------------------------------------------------------------------------- 1 | Docker packaging 2 | ================ 3 | 4 | This directory has one subdirectory per packaging distribution. 5 | At minimum, each of these subdirectories should contain a 6 | README.$DISTRIBUTION explaining how to create the native 7 | docker package and how to install it. 8 | 9 | -------------------------------------------------------------------------------- /src/github.com/dotcloud/docker/packaging/archlinux/README.archlinux: -------------------------------------------------------------------------------- 1 | Docker on Arch 2 | ============== 3 | 4 | The AUR lxc-docker and lxc-docker-git packages handle building docker on Arch 5 | linux. The PKGBUILD specifies all dependencies, build, and packaging steps. 6 | 7 | Dependencies 8 | ============ 9 | 10 | The only buildtime dependencies are git and go which are available via pacman. 11 | The -s flag can be used on makepkg commands below to automatically install 12 | these dependencies. 13 | 14 | Building Package 15 | ================ 16 | 17 | Download the tarball for either AUR packaged to a local directory. In that 18 | directory makepkg can be run to build the package. 19 | 20 | # Build the binary package 21 | makepkg 22 | 23 | # Build an updated source tarball 24 | makepkg --source 25 | 26 | -------------------------------------------------------------------------------- /src/github.com/dotcloud/docker/packaging/debian/Makefile: -------------------------------------------------------------------------------- 1 | # Debian package Makefile 2 | # 3 | # Dependencies: git debhelper build-essential autotools-dev devscripts golang 4 | # Notes: 5 | # Use 'make debian' to create the debian package 6 | # To create a specific version, use 'VERSION_TAG=v0.2.0 make debian' 7 | # GPG_KEY environment variable needs to contain a GPG private key for package 8 | # to be signed and uploaded to debian. 9 | # If GPG_KEY is not defined, make debian will create docker package and exit 10 | # with status code 2 11 | 12 | PKG_NAME=lxc-docker 13 | ROOT_PATH=$(shell git rev-parse --show-toplevel) 14 | GITHUB_PATH=github.com/dotcloud/docker 15 | BUILD_SRC=build_src 16 | VERSION_TAG?=v$(shell sed -E 's/.+\((.+)-.+\).+/\1/;q' changelog) 17 | VERSION=$(shell echo ${VERSION_TAG} | cut -c2-) 18 | DOCKER_VERSION=${PKG_NAME}_${VERSION} 19 | 20 | all: 21 | # Compile docker. Used by debian dpkg-buildpackage. 22 | cd src/${GITHUB_PATH}/docker; GOPATH=${CURDIR} go build 23 | 24 | install: 25 | # Used by debian dpkg-buildpackage 26 | mkdir -p $(DESTDIR)/usr/bin 27 | mkdir -p $(DESTDIR)/usr/share/man/man1 28 | mkdir -p $(DESTDIR)/usr/share/doc/lxc-docker 29 | install -m 0755 src/${GITHUB_PATH}/docker/docker $(DESTDIR)/usr/bin/lxc-docker 30 | cp debian/lxc-docker.1 $(DESTDIR)/usr/share/man/man1 31 | cp debian/CHANGELOG.md $(DESTDIR)/usr/share/doc/lxc-docker/changelog 32 | 33 | debian: 34 | # Prepare docker source from revision ${VERSION_TAG} 35 | rm -rf ${BUILD_SRC} ${PKG_NAME}_[0-9]* 36 | git clone file://$(ROOT_PATH) ${BUILD_SRC}/src/${GITHUB_PATH} --branch ${VERSION_TAG} --depth 1 37 | GOPATH=${CURDIR}/${BUILD_SRC} go get -d ${GITHUB_PATH} 38 | # Add debianization 39 | mkdir ${BUILD_SRC}/debian 40 | cp Makefile ${BUILD_SRC} 41 | cp -r `ls | grep -v ${BUILD_SRC}` ${BUILD_SRC}/debian 42 | cp ${ROOT_PATH}/README.md ${BUILD_SRC} 43 | cp ${ROOT_PATH}/CHANGELOG.md ${BUILD_SRC}/debian 44 | # Cleanup 45 | rm -rf `find . -name '.git*'` 46 | rm -f ${DOCKER_VERSION}* 47 | # Create docker debian files 48 | cd ${BUILD_SRC}; tar czf ../${DOCKER_VERSION}.orig.tar.gz . 49 | cd ${BUILD_SRC}; dpkg-buildpackage -us -uc 50 | rm -rf ${BUILD_SRC} 51 | # Sign package and upload it to PPA if GPG_KEY environment variable 52 | # holds a private GPG KEY 53 | if /usr/bin/test "$${GPG_KEY}" == ""; then exit 2; fi 54 | mkdir ${BUILD_SRC} 55 | # Import gpg signing key 56 | echo "$${GPG_KEY}" | gpg --allow-secret-key-import --import 57 | # Sign the package 58 | cd ${BUILD_SRC}; dpkg-source -x ${CURDIR}/${DOCKER_VERSION}-1.dsc 59 | cd ${BUILD_SRC}/${PKG_NAME}-${VERSION}; debuild -S -sa 60 | -------------------------------------------------------------------------------- /src/github.com/dotcloud/docker/packaging/debian/README.Debian: -------------------------------------------------------------------------------- 1 | Docker on Debian 2 | ================ 3 | 4 | Docker has been built and tested on Wheezy. All docker functionality works 5 | out of the box, except for memory limitation as the stock debian kernel 6 | disables it by default. To enable docker memory limitation, the kernel needs 7 | to be loaded with boot parameters: cgroup_enable=memory swapaccount=1 8 | 9 | 10 | Building docker package 11 | ~~~~~~~~~~~~~~~~~~~~~~~ 12 | 13 | Assuming you have a wheezy system up and running 14 | 15 | # Get building dependencies 16 | sudo apt-get update 17 | sudo apt-get install -y debhelper build-essential autotools-dev golang 18 | 19 | # Make the debian package 20 | git clone https://github.com/dotcloud/docker.git 21 | cd docker/packaging/debian 22 | make debian 23 | 24 | 25 | Install docker package 26 | ~~~~~~~~~~~~~~~~~~~~~~ 27 | 28 | sudo dpkg -i lxc-docker_*-1_amd64.deb; sudo apt-get install -f -y 29 | -------------------------------------------------------------------------------- /src/github.com/dotcloud/docker/packaging/debian/Vagrantfile: -------------------------------------------------------------------------------- 1 | VM_IP = "192.168.33.31" 2 | PKG_DEP = "git debhelper build-essential autotools-dev devscripts golang" 3 | 4 | Vagrant::Config.run do |config| 5 | config.vm.box = 'debian-7.0.rc1.64' 6 | config.vm.box_url = 'http://puppet-vagrant-boxes.puppetlabs.com/debian-70rc1-x64-vbox4210-nocm.box' 7 | config.vm.share_folder 'v-data', '/data/docker', "#{File.dirname(__FILE__)}/../.." 8 | config.vm.network :hostonly,VM_IP 9 | 10 | # Add kernel cgroup memory limitation boot parameters 11 | grub_cmd="sed -i 's#DEFAULT=\"quiet\"#DEFAULT=\"cgroup_enable=memory swapaccount=1 quiet\"#' /etc/default/grub" 12 | config.vm.provision :shell, :inline => "#{grub_cmd};update-grub" 13 | 14 | # Install debian packaging dependencies and create debian packages 15 | pkg_cmd = "apt-get -qq update; DEBIAN_FRONTEND=noninteractive apt-get install -qq -y #{PKG_DEP}; " \ 16 | "export GPG_KEY='#{ENV['GPG_KEY']}'; cd /data/docker/packaging/debian; make debian" 17 | config.vm.provision :shell, :inline => pkg_cmd 18 | end 19 | -------------------------------------------------------------------------------- /src/github.com/dotcloud/docker/packaging/debian/changelog: -------------------------------------------------------------------------------- 1 | lxc-docker (0.3.4-1) UNRELEASED; urgency=low 2 | - Builder: 'docker build' builds a container, layer by layer, from a source repository containing a Dockerfile 3 | - Builder: 'docker build -t FOO' applies the tag FOO to the newly built container. 4 | - Runtime: interactive TTYs correctly handle window resize 5 | - Runtime: fix how configuration is merged between layers 6 | - Remote API: split stdout and stderr on 'docker run' 7 | - Remote API: optionally listen on a different IP and port (use at your own risk) 8 | - Documentation: improved install instructions. 9 | 10 | -- dotCloud Thu, 30 May 2013 00:00:00 -0700 11 | 12 | lxc-docker (0.3.2-1) UNRELEASED; urgency=low 13 | - Runtime: Store the actual archive on commit 14 | - Registry: Improve the checksum process 15 | - Registry: Use the size to have a good progress bar while pushing 16 | - Registry: Use the actual archive if it exists in order to speed up the push 17 | - Registry: Fix error 400 on push 18 | 19 | -- Daniel Mizyrycki Sun, 12 May 2013 00:00:00 -0700 20 | 21 | 22 | lxc-docker (0.2.0-1) UNRELEASED; urgency=low 23 | 24 | - Pre-release (Closes: #706060) 25 | 26 | -- Daniel Mizyrycki Fri, 26 Apr 2013 23:41:29 -0700 27 | 28 | -------------------------------------------------------------------------------- /src/github.com/dotcloud/docker/packaging/debian/compat: -------------------------------------------------------------------------------- 1 | 9 2 | -------------------------------------------------------------------------------- /src/github.com/dotcloud/docker/packaging/debian/control: -------------------------------------------------------------------------------- 1 | Source: lxc-docker 2 | Section: admin 3 | Priority: optional 4 | Maintainer: Daniel Mizyrycki 5 | Build-Depends: debhelper (>=9), autotools-dev, golang 6 | Standards-Version: 3.9.4 7 | Vcs-Git: git://git.debian.org/git/collab-maint/lxc-docker.git 8 | Vcs-Browser: http://anonscm.debian.org/gitweb/?p=collab-maint/lxc-docker.git;a=summary 9 | Homepage: http://github.com/dotcloud/docker 10 | 11 | Package: lxc-docker 12 | Architecture: linux-any 13 | Depends: ${shlibs:Depends}, ${misc:Depends}, lxc, bsdtar 14 | Description: Linux container runtime 15 | Docker complements LXC with a high-level API which operates at the process 16 | level. It runs unix processes with strong guarantees of isolation and 17 | repeatability across servers. 18 | Docker is a great building block for automating distributed systems: 19 | large-scale web deployments, database clusters, continuous deployment systems, 20 | private PaaS, service-oriented architectures, etc. 21 | -------------------------------------------------------------------------------- /src/github.com/dotcloud/docker/packaging/debian/copyright: -------------------------------------------------------------------------------- 1 | Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ 2 | Upstream-Name: docker 3 | Upstream-Contact: dotCloud Inc 4 | Source: http://github.com/dotcloud/docker 5 | 6 | Files: * 7 | Copyright: 2012, dotCloud Inc 8 | License: Apache-2.0 9 | Licensed under the Apache License, Version 2.0 (the "License"); 10 | you may not use this file except in compliance with the License. 11 | You may obtain a copy of the License at 12 | . 13 | http://www.apache.org/licenses/LICENSE-2.0 14 | . 15 | Unless required by applicable law or agreed to in writing, software 16 | distributed under the License is distributed on an "AS IS" BASIS, 17 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | See the License for the specific language governing permissions and 19 | limitations under the License. 20 | . 21 | On Debian systems, the complete text of the Apache version 2.0 license 22 | can be found in "/usr/share/common-licenses/Apache-2.0". 23 | -------------------------------------------------------------------------------- /src/github.com/dotcloud/docker/packaging/debian/docs: -------------------------------------------------------------------------------- 1 | README.md 2 | -------------------------------------------------------------------------------- /src/github.com/dotcloud/docker/packaging/debian/lxc-docker.init: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | ### BEGIN INIT INFO 4 | # Provides: lxc-docker 5 | # Required-Start: $syslog $remote_fs 6 | # Required-Stop: $syslog $remote_fs 7 | # Default-Start: 2 3 4 5 8 | # Default-Stop: 0 1 6 9 | # Short-Description: Linux container runtime 10 | # Description: Linux container runtime 11 | ### END INIT INFO 12 | 13 | DOCKER=/usr/bin/lxc-docker 14 | 15 | # Check lxc-docker is present 16 | [ -x $DOCKER ] || (log_failure_msg "lxc-docker not present"; exit 1) 17 | 18 | PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin 19 | 20 | # Get lsb functions 21 | . /lib/lsb/init-functions 22 | 23 | check_root_id () 24 | { 25 | if [ "$(id -u)" != "0" ]; then 26 | log_failure_msg "LXC Docker must be run as root"; exit 1 27 | fi 28 | } 29 | 30 | case "$1" in 31 | start) 32 | check_root_id || exit 1 33 | log_begin_msg "Starting LXC Docker" 34 | mount | grep cgroup >/dev/null || mount -t cgroup none /sys/fs/cgroup 35 | start-stop-daemon --start --background --exec "$DOCKER" -- -d 36 | log_end_msg $? 37 | ;; 38 | 39 | stop) 40 | check_root_id || exit 1 41 | log_begin_msg "Stopping LXC Docker" 42 | docker_pid=`pgrep -f "$DOCKER -d"` 43 | [ -n "$docker_pid" ] && kill $docker_pid 44 | log_end_msg $? 45 | ;; 46 | 47 | restart) 48 | check_root_id || exit 1 49 | docker_pid=`pgrep -f "$DOCKER -d"` 50 | [ -n "$docker_pid" ] && /etc/init.d/lxc-docker stop 51 | /etc/init.d/lxc-docker start 52 | ;; 53 | 54 | force-reload) 55 | check_root_id || exit 1 56 | /etc/init.d/lxc-docker restart 57 | ;; 58 | 59 | status) 60 | docker_pid=`pgrep -f "$DOCKER -d"` 61 | if [ -z "$docker_pid" ] ; then 62 | echo "lxc-docker not running" 63 | else 64 | echo "lxc-docker running (pid $docker_pid)" 65 | fi 66 | ;; 67 | 68 | *) 69 | echo "Usage: /etc/init.d/lxc-docker {start|stop|restart|status}" 70 | exit 1 71 | ;; 72 | esac 73 | 74 | exit 0 75 | -------------------------------------------------------------------------------- /src/github.com/dotcloud/docker/packaging/debian/maintainer.rst: -------------------------------------------------------------------------------- 1 | Maintainer duty 2 | =============== 3 | 4 | The Debian project specifies the role of a 'maintainer' which is the person 5 | making the Debian package of the program. This role requires an 'sponsor' to 6 | upload the package. As a maintainer you should follow the guide 7 | http://www.debian.org/doc/manuals/maint-guide . Your sponsor will be there 8 | helping you succeed. 9 | 10 | The most relevant information to update is the changelog file: 11 | Each new release should create a new first paragraph with new release version, 12 | changes, and the maintainer information. 13 | 14 | After this is done, follow README.debian to generate the actual source 15 | packages and talk with your sponsor to upload them into the official Debian 16 | package archive. 17 | -------------------------------------------------------------------------------- /src/github.com/dotcloud/docker/packaging/debian/rules: -------------------------------------------------------------------------------- 1 | #!/usr/bin/make -f 2 | # -*- makefile -*- 3 | 4 | #export DH_VERBOSE=1 5 | 6 | %: 7 | dh ${@} --with autotools_dev 8 | -------------------------------------------------------------------------------- /src/github.com/dotcloud/docker/packaging/debian/source/format: -------------------------------------------------------------------------------- 1 | 3.0 (quilt) 2 | -------------------------------------------------------------------------------- /src/github.com/dotcloud/docker/packaging/ubuntu/Makefile: -------------------------------------------------------------------------------- 1 | # Ubuntu package Makefile 2 | # 3 | # Dependencies: debhelper autotools-dev devscripts golang 4 | # Notes: 5 | # Use 'make ubuntu' to create the ubuntu package 6 | # GPG_KEY environment variable needs to contain a GPG private key for package to be signed 7 | # and uploaded to docker PPA. 8 | # If GPG_KEY is not defined, make ubuntu will create docker package and exit with 9 | # status code 2 10 | 11 | PKG_NAME=lxc-docker 12 | VERSION=$(shell head -1 changelog | sed 's/^.\+(\(.\+\)..).\+$$/\1/') 13 | GITHUB_PATH=github.com/dotcloud/docker 14 | DOCKER_VERSION=${PKG_NAME}_${VERSION} 15 | DOCKER_FVERSION=${PKG_NAME}_$(shell head -1 changelog | sed 's/^.\+(\(.\+\)).\+$$/\1/') 16 | BUILD_SRC=${CURDIR}/../../build_src 17 | VERSION_TAG=v$(shell head -1 changelog | sed 's/^.\+(\(.\+\)-[0-9]\+).\+$$/\1/') 18 | 19 | all: 20 | # Compile docker. Used by dpkg-buildpackage. 21 | cd src/${GITHUB_PATH}/docker; GOPATH=${CURDIR} go build 22 | 23 | install: 24 | # Used by dpkg-buildpackage 25 | mkdir -p ${DESTDIR}/usr/bin 26 | mkdir -p ${DESTDIR}/etc/init 27 | mkdir -p ${DESTDIR}/DEBIAN 28 | install -m 0755 src/${GITHUB_PATH}/docker/docker ${DESTDIR}/usr/bin 29 | install -o root -m 0755 debian/docker.upstart ${DESTDIR}/etc/init/docker.conf 30 | install debian/lxc-docker.prerm ${DESTDIR}/DEBIAN/prerm 31 | install debian/lxc-docker.postinst ${DESTDIR}/DEBIAN/postinst 32 | 33 | ubuntu: 34 | # This Makefile will compile the github master branch of dotcloud/docker 35 | # Retrieve docker project and its go structure from internet 36 | rm -rf ${BUILD_SRC} 37 | git clone $(shell git rev-parse --show-toplevel) ${BUILD_SRC}/${GITHUB_PATH} 38 | cd ${BUILD_SRC}/${GITHUB_PATH}; git checkout ${VERSION_TAG} && GOPATH=${BUILD_SRC} go get -d 39 | # Add debianization 40 | mkdir ${BUILD_SRC}/debian 41 | cp Makefile ${BUILD_SRC} 42 | cp -r * ${BUILD_SRC}/debian 43 | cp ../../README.md ${BUILD_SRC} 44 | # Cleanup 45 | for d in `find ${BUILD_SRC} -name '.git*'`; do rm -rf $$d; done 46 | rm -rf ${BUILD_SRC}/../${DOCKER_VERSION}.orig.tar.gz 47 | rm -rf ${BUILD_SRC}/pkg 48 | # Create docker debian files 49 | cd ${BUILD_SRC}; tar czf ../${DOCKER_VERSION}.orig.tar.gz . 50 | cd ${BUILD_SRC}; dpkg-buildpackage -us -uc 51 | rm -rf ${BUILD_SRC} 52 | # Sign package and upload it to PPA if GPG_KEY environment variable 53 | # holds a private GPG KEY 54 | if /usr/bin/test "$${GPG_KEY}" == ""; then exit 2; fi 55 | mkdir ${BUILD_SRC} 56 | # Import gpg signing key 57 | echo "$${GPG_KEY}" | gpg --allow-secret-key-import --import 58 | # Sign the package 59 | cd ${BUILD_SRC}; dpkg-source -x ${BUILD_SRC}/../${DOCKER_FVERSION}.dsc 60 | cd ${BUILD_SRC}/${PKG_NAME}-${VERSION}; debuild -S -sa 61 | cd ${BUILD_SRC};dput ppa:dotcloud/lxc-docker ${DOCKER_FVERSION}_source.changes 62 | rm -rf ${BUILD_SRC} 63 | -------------------------------------------------------------------------------- /src/github.com/dotcloud/docker/packaging/ubuntu/README.ubuntu: -------------------------------------------------------------------------------- 1 | Docker on Ubuntu 2 | ================ 3 | 4 | The easiest way to get docker up and running natively on Ubuntu is installing 5 | it from its official PPA:: 6 | 7 | sudo sh -c "echo 'deb http://ppa.launchpad.net/dotcloud/lxc-docker/ubuntu precise main' >>/etc/apt/sources.list" 8 | sudo apt-get update 9 | sudo apt-get install lxc-docker 10 | 11 | 12 | Building docker package 13 | ~~~~~~~~~~~~~~~~~~~~~~~ 14 | 15 | The building process is shared by both, developers and maintainers. If you are 16 | a developer, the Makefile will stop with exit status 2 right before signing 17 | the built packages. 18 | 19 | Assuming you are working on an Ubuntu 12.04 TLS system :: 20 | 21 | # Download a fresh copy of the docker project 22 | git clone https://github.com/dotcloud/docker.git 23 | cd docker 24 | 25 | # Get building dependencies 26 | sudo apt-get update; sudo apt-get install -y debhelper autotools-dev devscripts golang 27 | 28 | # Make the ubuntu package 29 | (cd packaging/ubuntu; make ubuntu) 30 | 31 | 32 | Install docker built package 33 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 34 | 35 | :: 36 | 37 | sudo dpkg -i lxc-docker_*_amd64.deb; sudo apt-get install -f -y 38 | -------------------------------------------------------------------------------- /src/github.com/dotcloud/docker/packaging/ubuntu/Vagrantfile: -------------------------------------------------------------------------------- 1 | GOPHERS_KEY = "308C15A29AD198E9" 2 | 3 | Vagrant::Config.run do |config| 4 | config.vm.box = 'precise64' 5 | config.vm.box_url = 'http://files.vagrantup.com/precise64.box' 6 | config.vm.share_folder 'v-data', '/data/docker', "#{File.dirname(__FILE__)}/../.." 7 | 8 | # Add docker PPA key to the local repository and install docker 9 | pkg_cmd = "apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys #{GOPHERS_KEY}; " \ 10 | "echo 'deb http://ppa.launchpad.net/gophers/go/ubuntu precise main' >/etc/apt/sources.list.d/gophers-go.list; " \ 11 | # Install ubuntu packaging dependencies and create ubuntu packages 12 | pkg_cmd << "export DEBIAN_FRONTEND=noninteractive; apt-get -qq update; apt-get install -qq -y git debhelper autotools-dev devscripts golang-stable; " \ 13 | "export GPG_KEY='#{ENV['GPG_KEY']}'; cd /data/docker/packaging/ubuntu; make ubuntu" 14 | config.vm.provision :shell, :inline => pkg_cmd 15 | end 16 | -------------------------------------------------------------------------------- /src/github.com/dotcloud/docker/packaging/ubuntu/compat: -------------------------------------------------------------------------------- 1 | 8 2 | -------------------------------------------------------------------------------- /src/github.com/dotcloud/docker/packaging/ubuntu/control: -------------------------------------------------------------------------------- 1 | Source: lxc-docker 2 | Section: misc 3 | Priority: extra 4 | Maintainer: Daniel Mizyrycki 5 | Build-Depends: debhelper,autotools-dev,devscripts,golang-stable 6 | Standards-Version: 3.9.3 7 | Homepage: http://github.com/dotcloud/docker 8 | 9 | Package: lxc-docker 10 | Architecture: linux-any 11 | Depends: ${misc:Depends},${shlibs:Depends},lxc,bsdtar 12 | Conflicts: docker 13 | Description: lxc-docker is a Linux container runtime 14 | Docker complements LXC with a high-level API which operates at the process 15 | level. It runs unix processes with strong guarantees of isolation and 16 | repeatability across servers. 17 | Docker is a great building block for automating distributed systems: 18 | large-scale web deployments, database clusters, continuous deployment systems, 19 | private PaaS, service-oriented architectures, etc. 20 | -------------------------------------------------------------------------------- /src/github.com/dotcloud/docker/packaging/ubuntu/docker.upstart: -------------------------------------------------------------------------------- 1 | description "Run docker" 2 | 3 | start on runlevel [2345] 4 | stop on starting rc RUNLEVEL=[016] 5 | respawn 6 | 7 | script 8 | /usr/bin/docker -d 9 | end script 10 | -------------------------------------------------------------------------------- /src/github.com/dotcloud/docker/packaging/ubuntu/docs: -------------------------------------------------------------------------------- 1 | README.md 2 | -------------------------------------------------------------------------------- /src/github.com/dotcloud/docker/packaging/ubuntu/lxc-docker.postinst: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Start docker 4 | /sbin/start docker 5 | -------------------------------------------------------------------------------- /src/github.com/dotcloud/docker/packaging/ubuntu/lxc-docker.prerm: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Stop docker 4 | /sbin/stop docker 5 | -------------------------------------------------------------------------------- /src/github.com/dotcloud/docker/packaging/ubuntu/maintainer.ubuntu: -------------------------------------------------------------------------------- 1 | Maintainer duty 2 | =============== 3 | 4 | Ubuntu allows developers to use their PPA (Personal Package Archive) 5 | repository. This is very convenient for the users as they just need to add 6 | the PPA address, update their package database and use the apt-get tool. 7 | 8 | For now, the official lxc-docker package is located on launchpad and can be 9 | accessed adding the following line to /etc/apt/sources.list :: 10 | 11 | 12 | deb http://ppa.launchpad.net/dotcloud/lxc-docker/ubuntu precise main 13 | 14 | 15 | Releasing a new package 16 | ~~~~~~~~~~~~~~~~~~~~~~~ 17 | 18 | The most relevant information to update is the packaging/ubuntu/changelog file: 19 | Each new release should create a new first paragraph with new release version, 20 | changes, and the maintainer information. The core of this paragraph is 21 | located on CHANGELOG.md. Make sure to transcribe it and translate the formats 22 | (eg: packaging/ubuntu/changelog uses 2 spaces for body change descriptions 23 | instead of 1 space from CHANGELOG.md) 24 | 25 | Assuming your PPA GPG signing key is on /media/usbdrive/docker.key, load it 26 | into the GPG_KEY environment variable with:: 27 | 28 | export GPG_KEY=`cat /media/usbdrive/docker.key` 29 | 30 | 31 | After this is done and you are ready to upload the package to the PPA, you have 32 | a couple of choices: 33 | 34 | * Follow packaging/ubuntu/README.ubuntu to generate the actual source packages 35 | and upload them to the PPA 36 | 37 | * Let vagrant do all the work for you:: 38 | 39 | ( cd docker/packaging/ubuntu; vagrant up ) 40 | -------------------------------------------------------------------------------- /src/github.com/dotcloud/docker/packaging/ubuntu/rules: -------------------------------------------------------------------------------- 1 | #!/usr/bin/make -f 2 | # -*- makefile -*- 3 | # Sample debian/rules that uses debhelper. 4 | # This file was originally written by Joey Hess and Craig Small. 5 | # As a special exception, when this file is copied by dh-make into a 6 | # dh-make output file, you may use that output file without restriction. 7 | # This special exception was added by Craig Small in version 0.37 of dh-make. 8 | 9 | # Uncomment this to turn on verbose mode. 10 | #export DH_VERBOSE=1 11 | 12 | %: 13 | dh $@ 14 | -------------------------------------------------------------------------------- /src/github.com/dotcloud/docker/packaging/ubuntu/source/format: -------------------------------------------------------------------------------- 1 | 3.0 (quilt) 2 | -------------------------------------------------------------------------------- /src/github.com/dotcloud/docker/registry/MAINTAINERS: -------------------------------------------------------------------------------- 1 | Sam Alba 2 | Joffrey Fuhrer 3 | Ken Cochrane 4 | -------------------------------------------------------------------------------- /src/github.com/dotcloud/docker/state.go: -------------------------------------------------------------------------------- 1 | package docker 2 | 3 | import ( 4 | "fmt" 5 | "github.com/dotcloud/docker/utils" 6 | "sync" 7 | "time" 8 | ) 9 | 10 | type State struct { 11 | Running bool 12 | Pid int 13 | ExitCode int 14 | StartedAt time.Time 15 | l *sync.Mutex 16 | Ghost bool 17 | } 18 | 19 | // String returns a human-readable description of the state 20 | func (s *State) String() string { 21 | if s.Running { 22 | if s.Ghost { 23 | return fmt.Sprintf("Ghost") 24 | } 25 | return fmt.Sprintf("Up %s", utils.HumanDuration(time.Now().Sub(s.StartedAt))) 26 | } 27 | return fmt.Sprintf("Exit %d", s.ExitCode) 28 | } 29 | 30 | func (s *State) setRunning(pid int) { 31 | s.Running = true 32 | s.ExitCode = 0 33 | s.Pid = pid 34 | s.StartedAt = time.Now() 35 | } 36 | 37 | func (s *State) setStopped(exitCode int) { 38 | s.Running = false 39 | s.Pid = 0 40 | s.ExitCode = exitCode 41 | } 42 | 43 | func (s *State) initLock() { 44 | s.l = &sync.Mutex{} 45 | } 46 | 47 | func (s *State) lock() { 48 | s.l.Lock() 49 | } 50 | 51 | func (s *State) unlock() { 52 | s.l.Unlock() 53 | } 54 | -------------------------------------------------------------------------------- /src/github.com/dotcloud/docker/sysinit.go: -------------------------------------------------------------------------------- 1 | package docker 2 | 3 | import ( 4 | "flag" 5 | "fmt" 6 | "log" 7 | "os" 8 | "os/exec" 9 | "os/user" 10 | "strconv" 11 | "strings" 12 | "syscall" 13 | ) 14 | 15 | // Setup networking 16 | func setupNetworking(gw string) { 17 | if gw == "" { 18 | return 19 | } 20 | if _, err := ip("route", "add", "default", "via", gw); err != nil { 21 | log.Fatalf("Unable to set up networking: %v", err) 22 | } 23 | } 24 | 25 | // Takes care of dropping privileges to the desired user 26 | func changeUser(u string) { 27 | if u == "" { 28 | return 29 | } 30 | userent, err := user.LookupId(u) 31 | if err != nil { 32 | userent, err = user.Lookup(u) 33 | } 34 | if err != nil { 35 | log.Fatalf("Unable to find user %v: %v", u, err) 36 | } 37 | 38 | uid, err := strconv.Atoi(userent.Uid) 39 | if err != nil { 40 | log.Fatalf("Invalid uid: %v", userent.Uid) 41 | } 42 | gid, err := strconv.Atoi(userent.Gid) 43 | if err != nil { 44 | log.Fatalf("Invalid gid: %v", userent.Gid) 45 | } 46 | 47 | if err := syscall.Setgid(gid); err != nil { 48 | log.Fatalf("setgid failed: %v", err) 49 | } 50 | if err := syscall.Setuid(uid); err != nil { 51 | log.Fatalf("setuid failed: %v", err) 52 | } 53 | } 54 | 55 | // Clear environment pollution introduced by lxc-start 56 | func cleanupEnv(env ListOpts) { 57 | os.Clearenv() 58 | for _, kv := range env { 59 | parts := strings.SplitN(kv, "=", 2) 60 | if len(parts) == 1 { 61 | parts = append(parts, "") 62 | } 63 | if parts[0] == "container" { 64 | continue 65 | } 66 | os.Setenv(parts[0], parts[1]) 67 | } 68 | } 69 | 70 | func executeProgram(name string, args []string) { 71 | path, err := exec.LookPath(name) 72 | if err != nil { 73 | log.Printf("Unable to locate %v", name) 74 | os.Exit(127) 75 | } 76 | 77 | if err := syscall.Exec(path, args, os.Environ()); err != nil { 78 | panic(err) 79 | } 80 | } 81 | 82 | // Sys Init code 83 | // This code is run INSIDE the container and is responsible for setting 84 | // up the environment before running the actual process 85 | func SysInit() { 86 | if len(os.Args) <= 1 { 87 | fmt.Println("You should not invoke docker-init manually") 88 | os.Exit(1) 89 | } 90 | var u = flag.String("u", "", "username or uid") 91 | var gw = flag.String("g", "", "gateway address") 92 | 93 | var flEnv ListOpts 94 | flag.Var(&flEnv, "e", "Set environment variables") 95 | 96 | flag.Parse() 97 | 98 | cleanupEnv(flEnv) 99 | setupNetworking(*gw) 100 | changeUser(*u) 101 | executeProgram(flag.Arg(0), flag.Args()) 102 | } 103 | -------------------------------------------------------------------------------- /src/github.com/dotcloud/docker/tags_test.go: -------------------------------------------------------------------------------- 1 | package docker 2 | 3 | import ( 4 | "testing" 5 | ) 6 | 7 | func TestLookupImage(t *testing.T) { 8 | runtime, err := newTestRuntime() 9 | if err != nil { 10 | t.Fatal(err) 11 | } 12 | defer nuke(runtime) 13 | 14 | if img, err := runtime.repositories.LookupImage(unitTestImageName); err != nil { 15 | t.Fatal(err) 16 | } else if img == nil { 17 | t.Errorf("Expected 1 image, none found") 18 | } 19 | 20 | if img, err := runtime.repositories.LookupImage(unitTestImageName + ":" + DEFAULTTAG); err != nil { 21 | t.Fatal(err) 22 | } else if img == nil { 23 | t.Errorf("Expected 1 image, none found") 24 | } 25 | 26 | if img, err := runtime.repositories.LookupImage(unitTestImageName + ":" + "fail"); err == nil { 27 | t.Errorf("Expected error, none found") 28 | } else if img != nil { 29 | t.Errorf("Expected 0 image, 1 found") 30 | } 31 | 32 | if img, err := runtime.repositories.LookupImage("fail:fail"); err == nil { 33 | t.Errorf("Expected error, none found") 34 | } else if img != nil { 35 | t.Errorf("Expected 0 image, 1 found") 36 | } 37 | 38 | if img, err := runtime.repositories.LookupImage(unitTestImageId); err != nil { 39 | t.Fatal(err) 40 | } else if img == nil { 41 | t.Errorf("Expected 1 image, none found") 42 | } 43 | 44 | if img, err := runtime.repositories.LookupImage(unitTestImageName + ":" + unitTestImageId); err != nil { 45 | t.Fatal(err) 46 | } else if img == nil { 47 | t.Errorf("Expected 1 image, none found") 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/github.com/dotcloud/docker/term/MAINTAINERS: -------------------------------------------------------------------------------- 1 | Guillaume Charmes 2 | Solomon Hykes 3 | -------------------------------------------------------------------------------- /src/github.com/dotcloud/docker/term/term.go: -------------------------------------------------------------------------------- 1 | package term 2 | 3 | import ( 4 | "os" 5 | "os/signal" 6 | "syscall" 7 | "unsafe" 8 | ) 9 | 10 | type State struct { 11 | termios Termios 12 | } 13 | 14 | type Winsize struct { 15 | Width uint16 16 | Height uint16 17 | x uint16 18 | y uint16 19 | } 20 | 21 | func GetWinsize(fd uintptr) (*Winsize, error) { 22 | ws := &Winsize{} 23 | _, _, err := syscall.Syscall(syscall.SYS_IOCTL, fd, uintptr(syscall.TIOCGWINSZ), uintptr(unsafe.Pointer(ws))) 24 | return ws, err 25 | } 26 | 27 | func SetWinsize(fd uintptr, ws *Winsize) error { 28 | _, _, err := syscall.Syscall(syscall.SYS_IOCTL, fd, uintptr(syscall.TIOCSWINSZ), uintptr(unsafe.Pointer(ws))) 29 | return err 30 | } 31 | 32 | // IsTerminal returns true if the given file descriptor is a terminal. 33 | func IsTerminal(fd uintptr) bool { 34 | var termios Termios 35 | _, _, err := syscall.Syscall(syscall.SYS_IOCTL, fd, uintptr(getTermios), uintptr(unsafe.Pointer(&termios))) 36 | return err == 0 37 | } 38 | 39 | // Restore restores the terminal connected to the given file descriptor to a 40 | // previous state. 41 | func Restore(fd uintptr, state *State) error { 42 | _, _, err := syscall.Syscall(syscall.SYS_IOCTL, fd, uintptr(setTermios), uintptr(unsafe.Pointer(&state.termios))) 43 | return err 44 | } 45 | 46 | func SetRawTerminal() (*State, error) { 47 | oldState, err := MakeRaw(os.Stdin.Fd()) 48 | if err != nil { 49 | return nil, err 50 | } 51 | c := make(chan os.Signal, 1) 52 | signal.Notify(c, os.Interrupt) 53 | go func() { 54 | _ = <-c 55 | Restore(os.Stdin.Fd(), oldState) 56 | os.Exit(0) 57 | }() 58 | return oldState, err 59 | } 60 | 61 | func RestoreTerminal(state *State) { 62 | Restore(os.Stdin.Fd(), state) 63 | } 64 | -------------------------------------------------------------------------------- /src/github.com/dotcloud/docker/term/termios_darwin.go: -------------------------------------------------------------------------------- 1 | package term 2 | 3 | import ( 4 | "syscall" 5 | "unsafe" 6 | ) 7 | 8 | const ( 9 | getTermios = syscall.TIOCGETA 10 | setTermios = syscall.TIOCSETA 11 | 12 | ECHO = 0x00000008 13 | ONLCR = 0x2 14 | ISTRIP = 0x20 15 | INLCR = 0x40 16 | ISIG = 0x80 17 | IGNCR = 0x80 18 | ICANON = 0x100 19 | ICRNL = 0x100 20 | IXOFF = 0x400 21 | IXON = 0x200 22 | ) 23 | 24 | type Termios struct { 25 | Iflag uint64 26 | Oflag uint64 27 | Cflag uint64 28 | Lflag uint64 29 | Cc [20]byte 30 | Ispeed uint64 31 | Ospeed uint64 32 | } 33 | 34 | // MakeRaw put the terminal connected to the given file descriptor into raw 35 | // mode and returns the previous state of the terminal so that it can be 36 | // restored. 37 | func MakeRaw(fd uintptr) (*State, error) { 38 | var oldState State 39 | if _, _, err := syscall.Syscall(syscall.SYS_IOCTL, fd, uintptr(getTermios), uintptr(unsafe.Pointer(&oldState.termios))); err != 0 { 40 | return nil, err 41 | } 42 | 43 | newState := oldState.termios 44 | newState.Iflag &^= (ISTRIP | INLCR | IGNCR | IXON | IXOFF) 45 | newState.Iflag |= ICRNL 46 | newState.Oflag |= ONLCR 47 | newState.Lflag &^= (ECHO | ICANON | ISIG) 48 | 49 | if _, _, err := syscall.Syscall(syscall.SYS_IOCTL, fd, uintptr(setTermios), uintptr(unsafe.Pointer(&newState))); err != 0 { 50 | return nil, err 51 | } 52 | 53 | return &oldState, nil 54 | } 55 | -------------------------------------------------------------------------------- /src/github.com/dotcloud/docker/term/termios_linux.go: -------------------------------------------------------------------------------- 1 | package term 2 | 3 | import ( 4 | "syscall" 5 | "unsafe" 6 | ) 7 | 8 | const ( 9 | getTermios = syscall.TCGETS 10 | setTermios = syscall.TCSETS 11 | ) 12 | 13 | type Termios struct { 14 | Iflag uint32 15 | Oflag uint32 16 | Cflag uint32 17 | Lflag uint32 18 | Cc [20]byte 19 | Ispeed uint32 20 | Ospeed uint32 21 | } 22 | 23 | // MakeRaw put the terminal connected to the given file descriptor into raw 24 | // mode and returns the previous state of the terminal so that it can be 25 | // restored. 26 | func MakeRaw(fd uintptr) (*State, error) { 27 | var oldState State 28 | if _, _, err := syscall.Syscall(syscall.SYS_IOCTL, fd, getTermios, uintptr(unsafe.Pointer(&oldState.termios))); err != 0 { 29 | return nil, err 30 | } 31 | 32 | newState := oldState.termios 33 | 34 | newState.Iflag &^= (syscall.IGNBRK | syscall.BRKINT | syscall.PARMRK | syscall.ISTRIP | syscall.INLCR | syscall.IGNCR | syscall.ICRNL | syscall.IXON) 35 | newState.Oflag &^= syscall.OPOST 36 | newState.Lflag &^= (syscall.ECHO | syscall.ECHONL | syscall.ICANON | syscall.ISIG | syscall.IEXTEN) 37 | newState.Cflag &^= (syscall.CSIZE | syscall.PARENB) 38 | newState.Cflag |= syscall.CS8 39 | 40 | if _, _, err := syscall.Syscall(syscall.SYS_IOCTL, fd, setTermios, uintptr(unsafe.Pointer(&newState))); err != 0 { 41 | return nil, err 42 | } 43 | return &oldState, nil 44 | } 45 | -------------------------------------------------------------------------------- /src/github.com/dotcloud/docker/testing/MAINTAINERS: -------------------------------------------------------------------------------- 1 | Daniel Mizyrycki 2 | -------------------------------------------------------------------------------- /src/github.com/dotcloud/docker/testing/README.rst: -------------------------------------------------------------------------------- 1 | ======= 2 | testing 3 | ======= 4 | 5 | This directory contains testing related files. 6 | 7 | 8 | Buildbot 9 | ======== 10 | 11 | Buildbot is a continuous integration system designed to automate the 12 | build/test cycle. By automatically rebuilding and testing the tree each time 13 | something has changed, build problems are pinpointed quickly, before other 14 | developers are inconvenienced by the failure. 15 | 16 | We are running buildbot in an AWS instance to verify docker passes all tests 17 | when commits get pushed to the master branch. 18 | 19 | You can check docker's buildbot instance at http://docker-ci.dotcloud.com/waterfall 20 | 21 | 22 | Deployment 23 | ~~~~~~~~~~ 24 | 25 | :: 26 | 27 | # Define AWS credential environment variables 28 | export AWS_ACCESS_KEY_ID=xxxxxxxxxxxx 29 | export AWS_SECRET_ACCESS_KEY=xxxxxxxxxxxx 30 | export AWS_KEYPAIR_NAME=xxxxxxxxxxxx 31 | export AWS_SSH_PRIVKEY=xxxxxxxxxxxx 32 | 33 | # Checkout docker 34 | git clone git://github.com/dotcloud/docker.git 35 | 36 | # Deploy docker on AWS 37 | cd docker/testing 38 | vagrant up --provider=aws 39 | 40 | 41 | Buildbot AWS dependencies 42 | ------------------------- 43 | 44 | vagrant, virtualbox packages and vagrant aws plugin 45 | -------------------------------------------------------------------------------- /src/github.com/dotcloud/docker/testing/Vagrantfile: -------------------------------------------------------------------------------- 1 | # -*- mode: ruby -*- 2 | # vi: set ft=ruby : 3 | 4 | BOX_NAME = "docker-ci" 5 | BOX_URI = "http://files.vagrantup.com/precise64.box" 6 | AWS_AMI = "ami-d0f89fb9" 7 | DOCKER_PATH = "/data/docker" 8 | CFG_PATH = "#{DOCKER_PATH}/testing/buildbot" 9 | BUILDBOT_IP = "192.168.33.41" 10 | on_vbox = File.file?("#{File.dirname(__FILE__)}/.vagrant/machines/default/virtualbox/id") | \ 11 | Dir.glob("#{File.dirname(__FILE__)}/.vagrant/machines/default/*/id").empty? & \ 12 | (on_vbox=true; ARGV.each do |arg| on_vbox &&= !arg.downcase.start_with?("--provider") end; on_vbox) 13 | USER = on_vbox ? "vagrant": "ubuntu" 14 | 15 | Vagrant::Config.run do |config| 16 | # Setup virtual machine box. This VM configuration code is always executed. 17 | config.vm.box = BOX_NAME 18 | config.vm.box_url = BOX_URI 19 | config.vm.share_folder "v-data", DOCKER_PATH, "#{File.dirname(__FILE__)}/.." 20 | config.vm.network :hostonly, BUILDBOT_IP 21 | 22 | # Deploy buildbot and its dependencies if it was not done 23 | if Dir.glob("#{File.dirname(__FILE__)}/.vagrant/machines/default/*/id").empty? 24 | pkg_cmd = "apt-get update -qq; apt-get install -q -y linux-image-3.8.0-19-generic; " 25 | # Deploy buildbot CI 26 | pkg_cmd << "apt-get install -q -y python-dev python-pip supervisor; " \ 27 | "pip install -r #{CFG_PATH}/requirements.txt; " \ 28 | "chown #{USER}.#{USER} /data; cd /data; " \ 29 | "#{CFG_PATH}/setup.sh #{USER} #{CFG_PATH}; " 30 | # Install docker dependencies 31 | pkg_cmd << "apt-get install -q -y python-software-properties; " \ 32 | "add-apt-repository -y ppa:gophers/go/ubuntu; apt-get update -qq; " \ 33 | "DEBIAN_FRONTEND=noninteractive apt-get install -q -y lxc bsdtar git golang-stable make; " 34 | # Activate new kernel 35 | pkg_cmd << "shutdown -r +1; " 36 | config.vm.provision :shell, :inline => pkg_cmd 37 | end 38 | end 39 | 40 | # Providers were added on Vagrant >= 1.1.0 41 | Vagrant::VERSION >= "1.1.0" and Vagrant.configure("2") do |config| 42 | config.vm.provider :aws do |aws, override| 43 | aws.access_key_id = ENV["AWS_ACCESS_KEY_ID"] 44 | aws.secret_access_key = ENV["AWS_SECRET_ACCESS_KEY"] 45 | aws.keypair_name = ENV["AWS_KEYPAIR_NAME"] 46 | override.ssh.private_key_path = ENV["AWS_SSH_PRIVKEY"] 47 | override.ssh.username = USER 48 | aws.ami = AWS_AMI 49 | aws.region = "us-east-1" 50 | aws.instance_type = "m1.small" 51 | aws.security_groups = "gateway" 52 | end 53 | 54 | config.vm.provider :virtualbox do |vb| 55 | end 56 | end 57 | -------------------------------------------------------------------------------- /src/github.com/dotcloud/docker/testing/buildbot/README.rst: -------------------------------------------------------------------------------- 1 | Buildbot configuration and setup files (except Vagrantfile located on ..) 2 | -------------------------------------------------------------------------------- /src/github.com/dotcloud/docker/testing/buildbot/buildbot.conf: -------------------------------------------------------------------------------- 1 | [program:buildmaster] 2 | command=twistd --nodaemon --no_save -y buildbot.tac 3 | directory=/data/buildbot/master 4 | chown= root:root 5 | redirect_stderr=true 6 | stdout_logfile=/var/log/supervisor/buildbot-master.log 7 | stderr_logfile=/var/log/supervisor/buildbot-master.log 8 | 9 | [program:buildworker] 10 | command=twistd --nodaemon --no_save -y buildbot.tac 11 | directory=/data/buildbot/slave 12 | chown= root:root 13 | redirect_stderr=true 14 | stdout_logfile=/var/log/supervisor/buildbot-slave.log 15 | stderr_logfile=/var/log/supervisor/buildbot-slave.log 16 | 17 | [group:buildbot] 18 | programs=buildmaster,buildworker 19 | -------------------------------------------------------------------------------- /src/github.com/dotcloud/docker/testing/buildbot/master.cfg: -------------------------------------------------------------------------------- 1 | import os 2 | from buildbot.buildslave import BuildSlave 3 | from buildbot.schedulers.forcesched import ForceScheduler 4 | from buildbot.schedulers.basic import SingleBranchScheduler 5 | from buildbot.changes import filter 6 | from buildbot.config import BuilderConfig 7 | from buildbot.process.factory import BuildFactory 8 | from buildbot.steps.shell import ShellCommand 9 | from buildbot.status import html 10 | from buildbot.status.web import authz, auth 11 | 12 | PORT_WEB = 80 # Buildbot webserver port 13 | PORT_GITHUB = 8011 # Buildbot github hook port 14 | PORT_MASTER = 9989 # Port where buildbot master listen buildworkers 15 | TEST_USER = 'buildbot' # Credential to authenticate build triggers 16 | TEST_PWD = 'docker' # Credential to authenticate build triggers 17 | BUILDER_NAME = 'docker' 18 | BUILDPASSWORD = 'pass-docker' # Credential to authenticate buildworkers 19 | GITHUB_DOCKER = "github.com/dotcloud/docker" 20 | DOCKER_PATH = "/data/docker" 21 | BUILDER_PATH = "/data/buildbot/slave/{0}/build".format(BUILDER_NAME) 22 | DOCKER_BUILD_PATH = BUILDER_PATH + '/src/github.com/dotcloud/docker' 23 | 24 | 25 | c = BuildmasterConfig = {} 26 | 27 | c['title'] = "Docker" 28 | c['titleURL'] = "waterfall" 29 | c['buildbotURL'] = "http://0.0.0.0:{0}/".format(PORT_WEB) 30 | c['db'] = {'db_url':"sqlite:///state.sqlite"} 31 | c['slaves'] = [BuildSlave('buildworker', BUILDPASSWORD)] 32 | c['slavePortnum'] = PORT_MASTER 33 | 34 | c['schedulers'] = [ForceScheduler(name='trigger',builderNames=[BUILDER_NAME])] 35 | c['schedulers'].append(SingleBranchScheduler(name="all", 36 | change_filter=filter.ChangeFilter(branch='master'),treeStableTimer=None, 37 | builderNames=[BUILDER_NAME])) 38 | 39 | # Docker test command 40 | test_cmd = ("cd /tmp; rm -rf {0}; export GOPATH={0}; go get -d {1}; cd {2}; " 41 | "go test").format(BUILDER_PATH,GITHUB_DOCKER,DOCKER_BUILD_PATH) 42 | 43 | # Builder 44 | factory = BuildFactory() 45 | factory.addStep(ShellCommand(description='Docker',logEnviron=False, 46 | usePTY=True,command=test_cmd)) 47 | c['builders'] = [BuilderConfig(name=BUILDER_NAME,slavenames=['buildworker'], 48 | factory=factory)] 49 | 50 | # Status 51 | authz_cfg=authz.Authz(auth=auth.BasicAuth([(TEST_USER,TEST_PWD)]), 52 | forceBuild='auth') 53 | c['status'] = [html.WebStatus(http_port=PORT_WEB, authz=authz_cfg)] 54 | c['status'].append(html.WebStatus(http_port=PORT_GITHUB,allowForce=True, 55 | change_hook_dialects={ 'github' : True })) 56 | -------------------------------------------------------------------------------- /src/github.com/dotcloud/docker/testing/buildbot/requirements.txt: -------------------------------------------------------------------------------- 1 | sqlalchemy<=0.7.9 2 | sqlalchemy-migrate>=0.7.2 3 | buildbot==0.8.7p1 4 | buildbot_slave==0.8.7p1 5 | nose==1.2.1 6 | requests==1.1.0 7 | -------------------------------------------------------------------------------- /src/github.com/dotcloud/docker/testing/buildbot/setup.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Setup of buildbot configuration. Package installation is being done by 4 | # Vagrantfile 5 | # Dependencies: buildbot, buildbot-slave, supervisor 6 | 7 | USER=$1 8 | CFG_PATH=$2 9 | BUILDBOT_PATH="/data/buildbot" 10 | DOCKER_PATH="/data/docker" 11 | SLAVE_NAME="buildworker" 12 | SLAVE_SOCKET="localhost:9989" 13 | BUILDBOT_PWD="pass-docker" 14 | export PATH="/bin:sbin:/usr/bin:/usr/sbin:/usr/local/bin" 15 | 16 | function run { su $USER -c "$1"; } 17 | 18 | # Exit if buildbot has already been installed 19 | [ -d "$BUILDBOT_PATH" ] && exit 0 20 | 21 | # Setup buildbot 22 | run "mkdir -p $BUILDBOT_PATH" 23 | cd $BUILDBOT_PATH 24 | run "buildbot create-master master" 25 | run "cp $CFG_PATH/master.cfg master" 26 | run "sed -i -E 's#(DOCKER_PATH = ).+#\1\"$DOCKER_PATH\"#' master/master.cfg" 27 | run "buildslave create-slave slave $SLAVE_SOCKET $SLAVE_NAME $BUILDBOT_PWD" 28 | 29 | # Allow buildbot subprocesses (docker tests) to properly run in containers, 30 | # in particular with docker -u 31 | run "sed -i 's/^umask = None/umask = 000/' slave/buildbot.tac" 32 | 33 | # Setup supervisor 34 | cp $CFG_PATH/buildbot.conf /etc/supervisor/conf.d/buildbot.conf 35 | sed -i -E "s/^chmod=0700.+/chmod=0770\nchown=root:$USER/" /etc/supervisor/supervisord.conf 36 | kill -HUP $(pgrep -f "/usr/bin/python /usr/bin/supervisord") 37 | -------------------------------------------------------------------------------- /src/github.com/dotcloud/docker/utils.go: -------------------------------------------------------------------------------- 1 | package docker 2 | 3 | // Compare two Config struct. Do not compare the "Image" nor "Hostname" fields 4 | // If OpenStdin is set, then it differs 5 | func CompareConfig(a, b *Config) bool { 6 | if a == nil || b == nil || 7 | a.OpenStdin || b.OpenStdin { 8 | return false 9 | } 10 | if a.AttachStdout != b.AttachStdout || 11 | a.AttachStderr != b.AttachStderr || 12 | a.User != b.User || 13 | a.Memory != b.Memory || 14 | a.MemorySwap != b.MemorySwap || 15 | a.CpuShares != b.CpuShares || 16 | a.OpenStdin != b.OpenStdin || 17 | a.Tty != b.Tty { 18 | return false 19 | } 20 | if len(a.Cmd) != len(b.Cmd) || 21 | len(a.Dns) != len(b.Dns) || 22 | len(a.Env) != len(b.Env) || 23 | len(a.PortSpecs) != len(b.PortSpecs) { 24 | return false 25 | } 26 | 27 | for i := 0; i < len(a.Cmd); i++ { 28 | if a.Cmd[i] != b.Cmd[i] { 29 | return false 30 | } 31 | } 32 | for i := 0; i < len(a.Dns); i++ { 33 | if a.Dns[i] != b.Dns[i] { 34 | return false 35 | } 36 | } 37 | for i := 0; i < len(a.Env); i++ { 38 | if a.Env[i] != b.Env[i] { 39 | return false 40 | } 41 | } 42 | for i := 0; i < len(a.PortSpecs); i++ { 43 | if a.PortSpecs[i] != b.PortSpecs[i] { 44 | return false 45 | } 46 | } 47 | 48 | return true 49 | } 50 | 51 | func MergeConfig(userConf, imageConf *Config) { 52 | if userConf.Hostname == "" { 53 | userConf.Hostname = imageConf.Hostname 54 | } 55 | if userConf.User == "" { 56 | userConf.User = imageConf.User 57 | } 58 | if userConf.Memory == 0 { 59 | userConf.Memory = imageConf.Memory 60 | } 61 | if userConf.MemorySwap == 0 { 62 | userConf.MemorySwap = imageConf.MemorySwap 63 | } 64 | if userConf.CpuShares == 0 { 65 | userConf.CpuShares = imageConf.CpuShares 66 | } 67 | if userConf.PortSpecs == nil || len(userConf.PortSpecs) == 0 { 68 | userConf.PortSpecs = imageConf.PortSpecs 69 | } 70 | if !userConf.Tty { 71 | userConf.Tty = imageConf.Tty 72 | } 73 | if !userConf.OpenStdin { 74 | userConf.OpenStdin = imageConf.OpenStdin 75 | } 76 | if !userConf.StdinOnce { 77 | userConf.StdinOnce = imageConf.StdinOnce 78 | } 79 | if userConf.Env == nil || len(userConf.Env) == 0 { 80 | userConf.Env = imageConf.Env 81 | } 82 | if userConf.Cmd == nil || len(userConf.Cmd) == 0 { 83 | userConf.Cmd = imageConf.Cmd 84 | } 85 | if userConf.Dns == nil || len(userConf.Dns) == 0 { 86 | userConf.Dns = imageConf.Dns 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /src/github.com/dotcloud/docker/utils/uname_darwin.go: -------------------------------------------------------------------------------- 1 | package utils 2 | 3 | import ( 4 | "errors" 5 | ) 6 | 7 | type Utsname struct { 8 | Release [65]byte 9 | } 10 | 11 | func uname() (*Utsname, error) { 12 | return nil, errors.New("Kernel version detection is not available on darwin") 13 | } 14 | -------------------------------------------------------------------------------- /src/github.com/dotcloud/docker/utils/uname_linux.go: -------------------------------------------------------------------------------- 1 | package utils 2 | 3 | import ( 4 | "syscall" 5 | ) 6 | 7 | type Utsname syscall.Utsname 8 | 9 | func uname() (*syscall.Utsname, error) { 10 | uts := &syscall.Utsname{} 11 | 12 | if err := syscall.Uname(uts); err != nil { 13 | return nil, err 14 | } 15 | return uts, nil 16 | } 17 | -------------------------------------------------------------------------------- /src/github.com/gorilla/context/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2012 Rodrigo Moraes. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are 5 | met: 6 | 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above 10 | copyright notice, this list of conditions and the following disclaimer 11 | in the documentation and/or other materials provided with the 12 | distribution. 13 | * Neither the name of Google Inc. nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /src/github.com/gorilla/context/README.md: -------------------------------------------------------------------------------- 1 | context 2 | ======= -------------------------------------------------------------------------------- /src/github.com/gorilla/context/context.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Gorilla Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package context 6 | 7 | import ( 8 | "net/http" 9 | "sync" 10 | "time" 11 | ) 12 | 13 | var ( 14 | mutex sync.Mutex 15 | data = make(map[*http.Request]map[interface{}]interface{}) 16 | datat = make(map[*http.Request]int64) 17 | ) 18 | 19 | // Set stores a value for a given key in a given request. 20 | func Set(r *http.Request, key, val interface{}) { 21 | mutex.Lock() 22 | defer mutex.Unlock() 23 | if data[r] == nil { 24 | data[r] = make(map[interface{}]interface{}) 25 | datat[r] = time.Now().Unix() 26 | } 27 | data[r][key] = val 28 | } 29 | 30 | // Get returns a value stored for a given key in a given request. 31 | func Get(r *http.Request, key interface{}) interface{} { 32 | mutex.Lock() 33 | defer mutex.Unlock() 34 | if data[r] != nil { 35 | return data[r][key] 36 | } 37 | return nil 38 | } 39 | 40 | // Delete removes a value stored for a given key in a given request. 41 | func Delete(r *http.Request, key interface{}) { 42 | mutex.Lock() 43 | defer mutex.Unlock() 44 | if data[r] != nil { 45 | delete(data[r], key) 46 | } 47 | } 48 | 49 | // Clear removes all values stored for a given request. 50 | // 51 | // This is usually called by a handler wrapper to clean up request 52 | // variables at the end of a request lifetime. See ClearHandler(). 53 | func Clear(r *http.Request) { 54 | mutex.Lock() 55 | defer mutex.Unlock() 56 | clear(r) 57 | } 58 | 59 | // clear is Clear without the lock. 60 | func clear(r *http.Request) { 61 | delete(data, r) 62 | delete(datat, r) 63 | } 64 | 65 | // Purge removes request data stored for longer than maxAge, in seconds. 66 | // It returns the amount of requests removed. 67 | // 68 | // If maxAge <= 0, all request data is removed. 69 | // 70 | // This is only used for sanity check: in case context cleaning was not 71 | // properly set some request data can be kept forever, consuming an increasing 72 | // amount of memory. In case this is detected, Purge() must be called 73 | // periodically until the problem is fixed. 74 | func Purge(maxAge int) int { 75 | mutex.Lock() 76 | defer mutex.Unlock() 77 | count := 0 78 | if maxAge <= 0 { 79 | count = len(data) 80 | data = make(map[*http.Request]map[interface{}]interface{}) 81 | datat = make(map[*http.Request]int64) 82 | } else { 83 | min := time.Now().Unix() - int64(maxAge) 84 | for r, _ := range data { 85 | if datat[r] < min { 86 | clear(r) 87 | count++ 88 | } 89 | } 90 | } 91 | return count 92 | } 93 | 94 | // ClearHandler wraps an http.Handler and clears request values at the end 95 | // of a request lifetime. 96 | func ClearHandler(h http.Handler) http.Handler { 97 | return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { 98 | defer Clear(r) 99 | h.ServeHTTP(w, r) 100 | }) 101 | } 102 | -------------------------------------------------------------------------------- /src/github.com/gorilla/context/context_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Gorilla Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package context 6 | 7 | import ( 8 | "net/http" 9 | "testing" 10 | ) 11 | 12 | type keyType int 13 | 14 | const ( 15 | key1 keyType = iota 16 | key2 17 | ) 18 | 19 | func TestContext(t *testing.T) { 20 | assertEqual := func(val interface{}, exp interface{}) { 21 | if val != exp { 22 | t.Errorf("Expected %v, got %v.", exp, val) 23 | } 24 | } 25 | 26 | r, _ := http.NewRequest("GET", "http://localhost:8080/", nil) 27 | 28 | // Get() 29 | assertEqual(Get(r, key1), nil) 30 | 31 | // Set() 32 | Set(r, key1, "1") 33 | assertEqual(Get(r, key1), "1") 34 | assertEqual(len(data[r]), 1) 35 | 36 | Set(r, key2, "2") 37 | assertEqual(Get(r, key2), "2") 38 | assertEqual(len(data[r]), 2) 39 | 40 | // Delete() 41 | Delete(r, key1) 42 | assertEqual(Get(r, key1), nil) 43 | assertEqual(len(data[r]), 1) 44 | 45 | Delete(r, key2) 46 | assertEqual(Get(r, key2), nil) 47 | assertEqual(len(data[r]), 0) 48 | 49 | // Clear() 50 | Clear(r) 51 | assertEqual(len(data), 0) 52 | } 53 | -------------------------------------------------------------------------------- /src/github.com/gorilla/context/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Gorilla Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | /* 6 | Package gorilla/context stores values shared during a request lifetime. 7 | 8 | For example, a router can set variables extracted from the URL and later 9 | application handlers can access those values, or it can be used to store 10 | sessions values to be saved at the end of a request. There are several 11 | others common uses. 12 | 13 | The idea was posted by Brad Fitzpatrick to the go-nuts mailing list: 14 | 15 | http://groups.google.com/group/golang-nuts/msg/e2d679d303aa5d53 16 | 17 | Here's the basic usage: first define the keys that you will need. The key 18 | type is interface{} so a key can be of any type that supports equality. 19 | Here we define a key using a custom int type to avoid name collisions: 20 | 21 | package foo 22 | 23 | import ( 24 | "github.com/gorilla/context" 25 | ) 26 | 27 | type key int 28 | 29 | const MyKey key = 0 30 | 31 | Then set a variable. Variables are bound to an http.Request object, so you 32 | need a request instance to set a value: 33 | 34 | context.Set(r, MyKey, "bar") 35 | 36 | The application can later access the variable using the same key you provided: 37 | 38 | func MyHandler(w http.ResponseWriter, r *http.Request) { 39 | // val is "bar". 40 | val = context.Get(r, foo.MyKey) 41 | 42 | // ... 43 | } 44 | 45 | And that's all about the basic usage. We discuss some other ideas below. 46 | 47 | Any type can be stored in the context. To enforce a given type, make the key 48 | private and wrap Get() and Set() to accept and return values of a specific 49 | type: 50 | 51 | type key int 52 | 53 | const mykey key = 0 54 | 55 | // GetMyKey returns a value for this package from the request values. 56 | func GetMyKey(r *http.Request) SomeType { 57 | if rv := context.Get(r, mykey); rv != nil { 58 | return rv.(SomeType) 59 | } 60 | return nil 61 | } 62 | 63 | // SetMyKey sets a value for this package in the request values. 64 | func SetMyKey(r *http.Request, val SomeType) { 65 | context.Set(r, mykey, val) 66 | } 67 | 68 | Variables must be cleared at the end of a request, to remove all values 69 | that were stored. This can be done in an http.Handler, after a request was 70 | served. Just call Clear() passing the request: 71 | 72 | context.Clear(r) 73 | 74 | ...or use ClearHandler(), which conveniently wraps an http.Handler to clear 75 | variables at the end of a request lifetime. 76 | 77 | The Router from the package gorilla/mux calls Clear(), so if you are using it 78 | you don't need to clear the context manually. 79 | */ 80 | package context 81 | -------------------------------------------------------------------------------- /src/github.com/gorilla/mux/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2012 Rodrigo Moraes. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are 5 | met: 6 | 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above 10 | copyright notice, this list of conditions and the following disclaimer 11 | in the documentation and/or other materials provided with the 12 | distribution. 13 | * Neither the name of Google Inc. nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /src/github.com/gorilla/mux/README.md: -------------------------------------------------------------------------------- 1 | mux 2 | === -------------------------------------------------------------------------------- /src/github.com/gorilla/mux/bench_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Gorilla Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package mux 6 | 7 | import ( 8 | "net/http" 9 | "testing" 10 | ) 11 | 12 | func BenchmarkMux(b *testing.B) { 13 | router := new(Router) 14 | handler := func(w http.ResponseWriter, r *http.Request) {} 15 | router.HandleFunc("/v1/{v1}", handler) 16 | 17 | request, _ := http.NewRequest("GET", "/v1/anything", nil) 18 | for i := 0; i < b.N; i++ { 19 | router.ServeHTTP(nil, request) 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/github.com/kr/pty/.gitignore: -------------------------------------------------------------------------------- 1 | [568].out 2 | _go* 3 | _test* 4 | _obj 5 | -------------------------------------------------------------------------------- /src/github.com/kr/pty/License: -------------------------------------------------------------------------------- 1 | Copyright (c) 2011 Keith Rarick 2 | 3 | Permission is hereby granted, free of charge, to any person 4 | obtaining a copy of this software and associated 5 | documentation files (the "Software"), to deal in the 6 | Software without restriction, including without limitation 7 | the rights to use, copy, modify, merge, publish, distribute, 8 | sublicense, and/or sell copies of the Software, and to 9 | permit persons to whom the Software is furnished to do so, 10 | subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall 13 | be included in all copies or substantial portions of the 14 | Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY 17 | KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE 18 | WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR 19 | PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS 20 | OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 21 | OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 22 | OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 23 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | -------------------------------------------------------------------------------- /src/github.com/kr/pty/README.md: -------------------------------------------------------------------------------- 1 | # pty 2 | 3 | Pty is a Go package for using unix pseudo-terminals. 4 | 5 | ## Install 6 | 7 | go get github.com/kr/pty 8 | 9 | ## Example 10 | 11 | ```go 12 | package main 13 | 14 | import ( 15 | "github.com/kr/pty" 16 | "io" 17 | "os" 18 | "os/exec" 19 | ) 20 | 21 | func main() { 22 | c := exec.Command("grep", "--color=auto", "bar") 23 | f, err := pty.Start(c) 24 | if err != nil { 25 | panic(err) 26 | } 27 | 28 | go func() { 29 | f.Write([]byte("foo\n")) 30 | f.Write([]byte("bar\n")) 31 | f.Write([]byte("baz\n")) 32 | f.Write([]byte{4}) // EOT 33 | }() 34 | io.Copy(os.Stdout, f) 35 | } 36 | ``` 37 | -------------------------------------------------------------------------------- /src/github.com/kr/pty/doc.go: -------------------------------------------------------------------------------- 1 | // Package pty provides functions for working with Unix terminals. 2 | package pty 3 | 4 | import ( 5 | "os" 6 | ) 7 | 8 | // Opens a pty and its corresponding tty. 9 | func Open() (pty, tty *os.File, err error) { 10 | return open() 11 | } 12 | -------------------------------------------------------------------------------- /src/github.com/kr/pty/pty_darwin.go: -------------------------------------------------------------------------------- 1 | package pty 2 | 3 | import ( 4 | "errors" 5 | "os" 6 | "syscall" 7 | "unsafe" 8 | ) 9 | 10 | // see ioccom.h 11 | const sys_IOCPARM_MASK = 0x1fff 12 | 13 | func open() (pty, tty *os.File, err error) { 14 | p, err := os.OpenFile("/dev/ptmx", os.O_RDWR, 0) 15 | if err != nil { 16 | return nil, nil, err 17 | } 18 | 19 | sname, err := ptsname(p) 20 | if err != nil { 21 | return nil, nil, err 22 | } 23 | 24 | err = grantpt(p) 25 | if err != nil { 26 | return nil, nil, err 27 | } 28 | 29 | err = unlockpt(p) 30 | if err != nil { 31 | return nil, nil, err 32 | } 33 | 34 | t, err := os.OpenFile(sname, os.O_RDWR, 0) 35 | if err != nil { 36 | return nil, nil, err 37 | } 38 | return p, t, nil 39 | } 40 | 41 | func ptsname(f *os.File) (string, error) { 42 | var n [(syscall.TIOCPTYGNAME >> 16) & sys_IOCPARM_MASK]byte 43 | 44 | ioctl(f.Fd(), syscall.TIOCPTYGNAME, uintptr(unsafe.Pointer(&n))) 45 | for i, c := range n { 46 | if c == 0 { 47 | return string(n[:i]), nil 48 | } 49 | } 50 | return "", errors.New("TIOCPTYGNAME string not NUL-terminated") 51 | } 52 | 53 | func grantpt(f *os.File) error { 54 | var u int 55 | return ioctl(f.Fd(), syscall.TIOCPTYGRANT, uintptr(unsafe.Pointer(&u))) 56 | } 57 | 58 | func unlockpt(f *os.File) error { 59 | var u int 60 | return ioctl(f.Fd(), syscall.TIOCPTYUNLK, uintptr(unsafe.Pointer(&u))) 61 | } 62 | 63 | func ioctl(fd, cmd, ptr uintptr) error { 64 | _, _, e := syscall.Syscall(syscall.SYS_IOCTL, fd, cmd, ptr) 65 | if e != 0 { 66 | return syscall.ENOTTY 67 | } 68 | return nil 69 | } 70 | -------------------------------------------------------------------------------- /src/github.com/kr/pty/pty_linux.go: -------------------------------------------------------------------------------- 1 | package pty 2 | 3 | import ( 4 | "os" 5 | "strconv" 6 | "syscall" 7 | "unsafe" 8 | ) 9 | 10 | const ( 11 | sys_TIOCGPTN = 0x80045430 12 | sys_TIOCSPTLCK = 0x40045431 13 | ) 14 | 15 | func open() (pty, tty *os.File, err error) { 16 | p, err := os.OpenFile("/dev/ptmx", os.O_RDWR, 0) 17 | if err != nil { 18 | return nil, nil, err 19 | } 20 | 21 | sname, err := ptsname(p) 22 | if err != nil { 23 | return nil, nil, err 24 | } 25 | 26 | err = unlockpt(p) 27 | if err != nil { 28 | return nil, nil, err 29 | } 30 | 31 | t, err := os.OpenFile(sname, os.O_RDWR, 0) 32 | if err != nil { 33 | return nil, nil, err 34 | } 35 | return p, t, nil 36 | } 37 | 38 | func ptsname(f *os.File) (string, error) { 39 | var n int 40 | err := ioctl(f.Fd(), sys_TIOCGPTN, &n) 41 | if err != nil { 42 | return "", err 43 | } 44 | return "/dev/pts/" + strconv.Itoa(n), nil 45 | } 46 | 47 | func unlockpt(f *os.File) error { 48 | var u int 49 | return ioctl(f.Fd(), sys_TIOCSPTLCK, &u) 50 | } 51 | 52 | func ioctl(fd uintptr, cmd uintptr, data *int) error { 53 | _, _, e := syscall.Syscall( 54 | syscall.SYS_IOCTL, 55 | fd, 56 | cmd, 57 | uintptr(unsafe.Pointer(data)), 58 | ) 59 | if e != 0 { 60 | return syscall.ENOTTY 61 | } 62 | return nil 63 | } 64 | -------------------------------------------------------------------------------- /src/github.com/kr/pty/run.go: -------------------------------------------------------------------------------- 1 | package pty 2 | 3 | import ( 4 | "os" 5 | "os/exec" 6 | "syscall" 7 | ) 8 | 9 | // Start assigns a pseudo-terminal tty os.File to c.Stdin, c.Stdout, 10 | // and c.Stderr, calls c.Start, and returns the File of the tty's 11 | // corresponding pty. 12 | func Start(c *exec.Cmd) (pty *os.File, err error) { 13 | pty, tty, err := Open() 14 | if err != nil { 15 | return nil, err 16 | } 17 | defer tty.Close() 18 | c.Stdout = tty 19 | c.Stdin = tty 20 | c.Stderr = tty 21 | c.SysProcAttr = &syscall.SysProcAttr{Setctty: true, Setsid: true} 22 | err = c.Start() 23 | if err != nil { 24 | pty.Close() 25 | return nil, err 26 | } 27 | return pty, err 28 | } 29 | -------------------------------------------------------------------------------- /src/github.com/kr/pty/util.go: -------------------------------------------------------------------------------- 1 | package pty 2 | 3 | import ( 4 | "os" 5 | "syscall" 6 | "unsafe" 7 | ) 8 | 9 | // Getsize returns the number of rows (lines) and cols (positions 10 | // in each line) in terminal t. 11 | func Getsize(t *os.File) (rows, cols int, err error) { 12 | var ws winsize 13 | err = windowrect(&ws, t.Fd()) 14 | return int(ws.ws_row), int(ws.ws_col), err 15 | } 16 | 17 | type winsize struct { 18 | ws_row uint16 19 | ws_col uint16 20 | ws_xpixel uint16 21 | ws_ypixel uint16 22 | } 23 | 24 | func windowrect(ws *winsize, fd uintptr) error { 25 | _, _, errno := syscall.Syscall( 26 | syscall.SYS_IOCTL, 27 | fd, 28 | syscall.TIOCGWINSZ, 29 | uintptr(unsafe.Pointer(ws)), 30 | ) 31 | if errno != 0 { 32 | return syscall.Errno(errno) 33 | } 34 | return nil 35 | } 36 | -------------------------------------------------------------------------------- /src/github.com/philips/go-systemd/systemd.go: -------------------------------------------------------------------------------- 1 | package systemd 2 | 3 | import "launchpad.net/go-dbus" 4 | type Systemd1 struct { 5 | conn *dbus.Connection 6 | } 7 | 8 | type Job struct { 9 | Id string `json:"job"` 10 | Error string `json:"error"` 11 | } 12 | 13 | func (s *Systemd1) Connect() (err error) { 14 | conn, err := dbus.Connect(dbus.SystemBus) 15 | if err != nil { 16 | return err 17 | } 18 | 19 | err = conn.Authenticate() 20 | 21 | s.conn = conn 22 | 23 | return err 24 | } 25 | 26 | func (s *Systemd1) StartUnit(name string, mode string) (job Job, err error) { 27 | obj := s.conn.Object("org.freedesktop.systemd1", "/org/freedesktop/systemd1") 28 | 29 | reply, err := obj.Call("org.freedesktop.systemd1.Manager", "StartUnit", 30 | name, mode) 31 | if err != nil { 32 | return Job{"", err.Error()}, err 33 | } 34 | 35 | err = reply.GetArgs(&job.Id) 36 | 37 | return job, err 38 | } 39 | 40 | func (s *Systemd1) StopUnit(name string, mode string) (job Job, err error) { 41 | obj := s.conn.Object("org.freedesktop.systemd1", "/org/freedesktop/systemd1") 42 | 43 | reply, err := obj.Call("org.freedesktop.systemd1.Manager", "StopUnit", 44 | name, mode) 45 | if err != nil { 46 | return Job{"", err.Error()}, err 47 | } 48 | 49 | err = reply.GetArgs(&job.Id) 50 | 51 | return job, err 52 | } 53 | 54 | func (s *Systemd1) ListUnits() (message string, err error) { 55 | obj := s.conn.Object("org.freedesktop.systemd1", "/org/freedesktop/systemd1") 56 | 57 | reply, err := obj.Call("org.freedesktop.systemd1.Manager", "ListUnits") 58 | if err != nil { 59 | return "", err 60 | } 61 | 62 | err = reply.GetArgs(&message) 63 | 64 | return message, err 65 | } 66 | -------------------------------------------------------------------------------- /src/github.com/shin-/cookiejar/jar.go: -------------------------------------------------------------------------------- 1 | package cookiejar 2 | 3 | import( 4 | "net/http" 5 | "net/url" 6 | "sync" 7 | ) 8 | 9 | type CookieJar struct { 10 | data map[string][]*http.Cookie 11 | lock sync.Mutex 12 | } 13 | 14 | func (jar CookieJar) SetCookies(u *url.URL, cookies []*http.Cookie) { 15 | jar.lock.Lock() 16 | jar.data[u.Host] = cookies 17 | jar.lock.Unlock() 18 | } 19 | 20 | func (jar CookieJar) Cookies(u *url.URL) []*http.Cookie { 21 | // FIXME: This is a very naive implementation 22 | return jar.data[u.Host] 23 | } 24 | 25 | func NewCookieJar() CookieJar { 26 | return CookieJar{ 27 | data: make(map[string][]*http.Cookie), 28 | lock: sync.Mutex{}, 29 | } 30 | } -------------------------------------------------------------------------------- /src/launchpad.net/go-dbus/.gitignore: -------------------------------------------------------------------------------- 1 | _* 2 | 6.out 3 | -------------------------------------------------------------------------------- /src/launchpad.net/go-dbus/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2009 papamitra 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. 20 | -------------------------------------------------------------------------------- /src/launchpad.net/go-dbus/README.markdown: -------------------------------------------------------------------------------- 1 | Documentation 2 | ============= 3 | 4 | Look at the API on [GoPkgDoc](http://gopkgdoc.appspot.com/pkg/github.com/norisatir/go-dbus). 5 | 6 | Installation 7 | ============ 8 | 9 | go get launchpad.net/~jamesh/go-dbus/trunk 10 | 11 | Usage 12 | ===== 13 | 14 | An example 15 | ---------- 16 | 17 | ```go 18 | // Issue OSD notifications according to the Desktop Notifications Specification 1.1 19 | // http://people.canonical.com/~agateau/notifications-1.1/spec/index.html 20 | // See also 21 | // https://wiki.ubuntu.com/NotifyOSD#org.freedesktop.Notifications.Notify 22 | package main 23 | 24 | import "launchpad.net/~jamesh/go-dbus/trunk" 25 | import "log" 26 | 27 | func main() { 28 | var ( 29 | err error 30 | conn *dbus.Connection 31 | ) 32 | 33 | // Connect to Session or System buses. 34 | if conn, err = dbus.Connect(dbus.SessionBus); err != nil { 35 | log.Fatal("Connection error:", err) 36 | } 37 | if err = conn.Authenticate(); err != nil { 38 | log.Fatal("Authentication error:", err) 39 | } 40 | 41 | // Create an object proxy 42 | obj := conn.Object("org.freedesktop.Notifications", "/org/freedesktop/Notifications") 43 | 44 | // Call object methods. 45 | reply, err := obj.Call("org.freedesktop.Notifications", "Notify", 46 | "dbus-tutorial", uint32(0), "", 47 | "dbus-tutorial", "You've been notified!", 48 | []string{}, map[string]dbus.Variant{}, int32(-1)) 49 | if err != nil { 50 | log.Fatal("Notification error:", err) 51 | } 52 | 53 | // Parse the reply message 54 | var notification_id uint32 55 | if err := reply.GetArgs(¬ification_id); err != nil { 56 | log.Fatal(err) 57 | } 58 | log.Print("Notification id:", notification_id) 59 | } 60 | ``` 61 | -------------------------------------------------------------------------------- /src/launchpad.net/go-dbus/auth_test.go: -------------------------------------------------------------------------------- 1 | package dbus 2 | 3 | import ( 4 | "bufio" 5 | "net" 6 | . "launchpad.net/gocheck" 7 | ) 8 | 9 | func (s *S) TestAuthenticate(c *C) { 10 | server, client := net.Pipe() 11 | clientWrites := []string{} 12 | complete := make(chan int) 13 | go func() { 14 | r := bufio.NewReader(server) 15 | // Read the nul byte that marks the start of the protocol 16 | zero := []byte{0} 17 | r.Read(zero) 18 | 19 | clientWrites = append(clientWrites, string(zero)) 20 | line, _, _ := r.ReadLine() 21 | clientWrites = append(clientWrites, string(line)) 22 | 23 | server.Write([]byte("OK\r\n")) 24 | line, _, _ = r.ReadLine() 25 | clientWrites = append(clientWrites, string(line)) 26 | 27 | complete <- 1 28 | }() 29 | 30 | c.Check(authenticate(client, nil), Equals, nil) 31 | <- complete 32 | c.Check(clientWrites[0], Equals, "\x00") 33 | c.Check(clientWrites[1][:13], Equals, "AUTH EXTERNAL") 34 | c.Check(clientWrites[2], Equals, "BEGIN") 35 | } 36 | -------------------------------------------------------------------------------- /src/launchpad.net/go-dbus/dbus_test.go: -------------------------------------------------------------------------------- 1 | package dbus 2 | 3 | import ( 4 | . "launchpad.net/gocheck" 5 | "fmt" 6 | ) 7 | 8 | type callTest struct { 9 | dest string 10 | path ObjectPath 11 | iface, method string 12 | args []interface{} 13 | validate func(*Message) error 14 | } 15 | 16 | var callTests = []callTest{ 17 | {"org.freedesktop.Notifications", "/org/freedesktop/Notifications", 18 | "org.freedesktop.Notifications", "Notify", 19 | []interface{}{ 20 | "go-dbus", uint32(0), 21 | "info", "testing go-dbus", "test_body", 22 | []string{}, map[string]Variant{}, 23 | int32(2000)}, 24 | func(*Message) error { 25 | return nil 26 | }}, 27 | } 28 | 29 | func (test callTest) Call(c *Connection) error { 30 | proxy := c.Object(test.dest, test.path) 31 | reply, err := proxy.Call(test.iface, test.method, test.args...) 32 | if err != nil { 33 | return fmt.Errorf("failed Method.Call: %v", err) 34 | } 35 | if err = test.validate(reply); err != nil { 36 | err = fmt.Errorf("failed validation: %v", err) 37 | } 38 | return err 39 | } 40 | 41 | func (s *S) TestDBus(c *C) { 42 | bus, err := Connect(SessionBus) 43 | c.Assert(err, Equals, nil) 44 | defer bus.Close() 45 | c.Assert(bus.Authenticate(), Equals, nil) 46 | 47 | for i, test := range callTests { 48 | err = test.Call(bus) 49 | if err != nil { 50 | c.Errorf("callTest %d: %v", i, err) 51 | } 52 | } 53 | } 54 | 55 | func (s *S) TestConnectionConnectSessionBus(c *C) { 56 | bus, err := Connect(SessionBus) 57 | c.Assert(err, Equals, nil) 58 | defer bus.Close() 59 | c.Check(bus.Authenticate(), Equals, nil) 60 | } 61 | 62 | func (s *S) TestConnectionConnectSystemBus(c *C) { 63 | bus, err := Connect(SystemBus) 64 | c.Assert(err, Equals, nil) 65 | defer bus.Close() 66 | c.Check(bus.Authenticate(), Equals, nil) 67 | } 68 | 69 | func (s *S) TestConnectionRegisterMessageFilter(c *C) { 70 | bus, err := Connect(SessionBus) 71 | c.Assert(err, Equals, nil) 72 | defer bus.Close() 73 | c.Assert(bus.Authenticate(), Equals, nil) 74 | 75 | filter := bus.RegisterMessageFilter(func(msg *Message) *Message { 76 | // Make a change that shows the filter ran. 77 | if msg.Type == TypeMethodReturn { 78 | if err := msg.AppendArgs("Added by filter"); err != nil { 79 | c.Error(err) 80 | } 81 | } 82 | return msg 83 | }) 84 | c.Check(filter, Not(Equals), nil) 85 | defer bus.UnregisterMessageFilter(filter) 86 | 87 | msg := NewMethodCallMessage(BUS_DAEMON_NAME, BUS_DAEMON_PATH, BUS_DAEMON_IFACE, "GetId") 88 | reply, err := bus.SendWithReply(msg) 89 | c.Assert(err, Equals, nil) 90 | 91 | var busId, extra string 92 | c.Assert(reply.GetArgs(&busId, &extra), Equals, nil) 93 | c.Assert(extra, Equals, "Added by filter") 94 | } 95 | -------------------------------------------------------------------------------- /src/launchpad.net/go-dbus/introspect_test.go: -------------------------------------------------------------------------------- 1 | package dbus 2 | 3 | import ( 4 | . "launchpad.net/gocheck" 5 | ) 6 | 7 | var introStr = ` 8 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | ` 34 | 35 | func (s *S) TestIntrospect(c *C) { 36 | intro, err := NewIntrospect(introStr) 37 | c.Assert(err, Equals, nil) 38 | c.Assert(intro, Not(Equals), nil) 39 | 40 | intf := intro.GetInterfaceData("org.freedesktop.SampleInterface") 41 | c.Assert(intf, Not(Equals), nil) 42 | c.Check(intf.GetName(), Equals, "org.freedesktop.SampleInterface") 43 | 44 | meth := intf.GetMethodData("Frobate") 45 | c.Assert(meth, Not(Equals), nil) 46 | c.Check(meth.GetOutSignature(), Equals, Signature("sa{us}")) 47 | 48 | nilmeth := intf.GetMethodData("Hoo") // unknown method name 49 | c.Check(nilmeth, Equals, nil) 50 | 51 | signal := intf.GetSignalData("Changed") 52 | c.Assert(signal, Not(Equals), nil) 53 | c.Check(signal.GetSignature(), Equals, Signature("b")) 54 | 55 | nilsignal := intf.GetSignalData("Hoo") // unknown signal name 56 | c.Check(nilsignal, Equals, nil) 57 | } 58 | -------------------------------------------------------------------------------- /src/launchpad.net/go-dbus/matchrule.go: -------------------------------------------------------------------------------- 1 | package dbus 2 | 3 | import "fmt" 4 | import "strings" 5 | 6 | // Matches all messages with equal type, interface, member, or path. 7 | // Any missing/invalid fields are not matched against. 8 | type MatchRule struct { 9 | Type MessageType 10 | Sender string 11 | Path ObjectPath 12 | Interface string 13 | Member string 14 | Arg0 string 15 | 16 | senderNameOwner string 17 | } 18 | 19 | // A string representation af the MatchRule (D-Bus variant map). 20 | func (p *MatchRule) String() string { 21 | params := make([]string, 0, 6) 22 | if p.Type != TypeInvalid { 23 | params = append(params, fmt.Sprintf("type='%s'", p.Type)) 24 | } 25 | if p.Sender != "" { 26 | params = append(params, fmt.Sprintf("sender='%s'", p.Sender)) 27 | } 28 | if p.Path != "" { 29 | params = append(params, fmt.Sprintf("path='%s'", p.Path)) 30 | } 31 | if p.Interface != "" { 32 | params = append(params, fmt.Sprintf("interface='%s'", p.Interface)) 33 | } 34 | if p.Member != "" { 35 | params = append(params, fmt.Sprintf("member='%s'", p.Member)) 36 | } 37 | if p.Arg0 != "" { 38 | params = append(params, fmt.Sprintf("arg0='%s'", p.Arg0)) 39 | } 40 | return strings.Join(params, ",") 41 | } 42 | 43 | func (p *MatchRule) _Match(msg *Message) bool { 44 | if p.Type != TypeInvalid && p.Type != msg.Type { 45 | return false 46 | } 47 | if p.Sender != "" { 48 | if !(p.Sender == msg.Sender || p.senderNameOwner == msg.Sender) { 49 | return false 50 | } 51 | } 52 | if p.Path != "" && p.Path != msg.Path { 53 | return false 54 | } 55 | if p.Interface != "" && p.Interface != msg.Iface { 56 | return false 57 | } 58 | if p.Member != "" && p.Member != msg.Member { 59 | return false 60 | } 61 | if p.Arg0 != "" { 62 | var arg0 string 63 | if err := msg.GetArgs(&arg0); err != nil || arg0 != p.Arg0 { 64 | return false 65 | } 66 | } 67 | return true 68 | } 69 | -------------------------------------------------------------------------------- /src/launchpad.net/go-dbus/matchrule_test.go: -------------------------------------------------------------------------------- 1 | package dbus 2 | 3 | import . "launchpad.net/gocheck" 4 | 5 | func (s *S) TestMatchRuleToString(c *C) { 6 | mr := MatchRule{ 7 | Type: TypeSignal, 8 | Interface: "org.freedesktop.DBus", 9 | Member: "Foo", 10 | Path: "/bar/foo"} 11 | c.Check(mr.String(), Equals, "type='signal',path='/bar/foo',interface='org.freedesktop.DBus',member='Foo'") 12 | 13 | // A rule that doesn't match the member 14 | mr = MatchRule{ 15 | Type: TypeSignal, 16 | Interface: "com.example.Foo", 17 | Member: "Bar"} 18 | c.Check(mr.String(), Equals, "type='signal',interface='com.example.Foo',member='Bar'") 19 | } 20 | 21 | func (s *S) TestMatchRuleMatch(c *C) { 22 | msg := NewSignalMessage("", "org.freedesktop.DBus", "NameOwnerChanged") 23 | _ = msg.AppendArgs("com.example.Foo", "", ":2.0") 24 | 25 | mr := MatchRule{ 26 | Type: TypeSignal, 27 | Interface: "org.freedesktop.DBus", 28 | Member: "NameOwnerChanged"} 29 | c.Check(mr._Match(msg), Equals, true) 30 | 31 | mr = MatchRule{ 32 | Type: TypeSignal, 33 | Interface: "org.freedesktop.DBus", 34 | Member: "NameAcquired"} 35 | c.Check(mr._Match(msg), Equals, false) 36 | 37 | // Check matching against first argument. 38 | mr = MatchRule{ 39 | Type: TypeSignal, 40 | Interface: "org.freedesktop.DBus", 41 | Member: "NameOwnerChanged", 42 | Arg0: "com.example.Foo"} 43 | c.Check(mr._Match(msg), Equals, true) 44 | mr.Arg0 = "com.example.Bar" 45 | c.Check(mr._Match(msg), Equals, false) 46 | } 47 | -------------------------------------------------------------------------------- /src/launchpad.net/go-dbus/suite_test.go: -------------------------------------------------------------------------------- 1 | package dbus 2 | 3 | import ( 4 | . "launchpad.net/gocheck" 5 | "testing" 6 | ) 7 | 8 | func TestAll(t *testing.T) { 9 | TestingT(t) 10 | } 11 | 12 | type S struct {} 13 | 14 | var _ = Suite(&S{}) 15 | -------------------------------------------------------------------------------- /src/launchpad.net/go-dbus/transport.go: -------------------------------------------------------------------------------- 1 | package dbus 2 | 3 | import ( 4 | "errors" 5 | "net" 6 | "net/url" 7 | "strings" 8 | ) 9 | 10 | 11 | type transport interface { 12 | Dial() (net.Conn, error) 13 | } 14 | 15 | func newTransport(address string) (transport, error) { 16 | if len(address) == 0 { 17 | return nil, errors.New("Unknown address type") 18 | } 19 | // Split the address into transport type and options. 20 | transportType := address[:strings.Index(address, ":")] 21 | options := make(map[string]string) 22 | for _, option := range strings.Split(address[len(transportType) + 1:], ",") { 23 | pair := strings.SplitN(option, "=", 2) 24 | key, err := url.QueryUnescape(pair[0]) 25 | if err != nil { 26 | return nil, err 27 | } 28 | value, err := url.QueryUnescape(pair[1]) 29 | if err != nil { 30 | return nil, err 31 | } 32 | options[key] = value 33 | } 34 | 35 | switch transportType { 36 | case "unix": 37 | if abstract, ok := options["abstract"]; ok { 38 | return &unixTransport{"@" + abstract}, nil 39 | } else if path, ok := options["path"]; ok { 40 | return &unixTransport{path}, nil 41 | } else { 42 | return nil, errors.New("unix transport requires 'path' or 'abstract' options") 43 | } 44 | case "tcp": 45 | address := options["host"] + ":" + options["port"] 46 | var family string 47 | switch options["family"] { 48 | case "", "ipv4": 49 | family = "tcp4" 50 | case "ipv6": 51 | family = "tcp6" 52 | default: 53 | return nil, errors.New("Unknown family for tcp transport: " + options["family"]) 54 | } 55 | return &tcpTransport{address, family}, nil 56 | // These can be implemented later as needed 57 | case "nonce-tcp": 58 | // Like above, but with noncefile 59 | case "launchd": 60 | // Perform newTransport() on contents of 61 | // options["env"] environment variable 62 | case "systemd": 63 | // Socket Activation via LISTEN_PID/LISTEN_FDS 64 | case "unixexec": 65 | // exec a process with a socket hooked to stdin/stdout 66 | } 67 | 68 | return nil, errors.New("Unhandled transport type " + transportType) 69 | } 70 | 71 | type unixTransport struct { 72 | Address string 73 | } 74 | 75 | func (trans *unixTransport) Dial() (net.Conn, error) { 76 | return net.Dial("unix", trans.Address) 77 | } 78 | 79 | type tcpTransport struct { 80 | Address, Family string 81 | } 82 | 83 | func (trans *tcpTransport) Dial() (net.Conn, error) { 84 | return net.Dial(trans.Family, trans.Address) 85 | } 86 | 87 | -------------------------------------------------------------------------------- /src/launchpad.net/go-dbus/transport_test.go: -------------------------------------------------------------------------------- 1 | package dbus 2 | 3 | import . "launchpad.net/gocheck" 4 | 5 | func (s *S) TestNewTransportUnix(c *C) { 6 | trans, err := newTransport("unix:path=/tmp/dbus%3dsock") 7 | c.Check(err, Equals, nil) 8 | unixTrans, ok := trans.(*unixTransport) 9 | c.Check(ok, Equals, true) 10 | c.Check(unixTrans.Address, Equals, "/tmp/dbus=sock") 11 | 12 | // And for abstract namespace sockets: 13 | trans, err = newTransport("unix:abstract=/tmp/dbus%3dsock") 14 | c.Check(err, Equals, nil) 15 | unixTrans, ok = trans.(*unixTransport) 16 | c.Check(ok, Equals, true) 17 | c.Check(unixTrans.Address, Equals, "@/tmp/dbus=sock") 18 | } 19 | 20 | func (s *S) TestNewTransportTcp(c *C) { 21 | trans, err := newTransport("tcp:host=localhost,port=4444") 22 | c.Check(err, Equals, nil) 23 | tcpTrans, ok := trans.(*tcpTransport) 24 | c.Check(ok, Equals, true) 25 | c.Check(tcpTrans.Address, Equals, "localhost:4444") 26 | c.Check(tcpTrans.Family, Equals, "tcp4") 27 | 28 | // And with explicit family: 29 | trans, err = newTransport("tcp:host=localhost,port=4444,family=ipv4") 30 | c.Check(err, Equals, nil) 31 | tcpTrans, ok = trans.(*tcpTransport) 32 | c.Check(ok, Equals, true) 33 | c.Check(tcpTrans.Address, Equals, "localhost:4444") 34 | c.Check(tcpTrans.Family, Equals, "tcp4") 35 | 36 | trans, err = newTransport("tcp:host=localhost,port=4444,family=ipv6") 37 | c.Check(err, Equals, nil) 38 | tcpTrans, ok = trans.(*tcpTransport) 39 | c.Check(ok, Equals, true) 40 | c.Check(tcpTrans.Address, Equals, "localhost:4444") 41 | c.Check(tcpTrans.Family, Equals, "tcp6") 42 | } 43 | -------------------------------------------------------------------------------- /src/launchpad.net/go-dbus/types_test.go: -------------------------------------------------------------------------------- 1 | package dbus 2 | 3 | import . "launchpad.net/gocheck" 4 | 5 | func (s *S) TestSignatureNextType(c *C) { 6 | // NextType() works for basic types 7 | for _, sig := range []Signature{"y", "b", "n", "q", "i", "u", "x", "t", "d", "s", "o", "g", "v", "h"} { 8 | next, err := sig.NextType(0) 9 | c.Check(next, Equals, 1) 10 | c.Check(err, Equals, nil) 11 | } 12 | 13 | // Unknown type code gives error 14 | next, err := Signature("_").NextType(0) 15 | c.Check(err, Not(Equals), nil) 16 | 17 | // Offset inside signature 18 | next, err = Signature("ii").NextType(1) 19 | c.Check(next, Equals, 2) 20 | c.Check(err, Equals, nil) 21 | 22 | // Error if there is no more type codes in signature 23 | next, err = Signature("i").NextType(1) 24 | c.Check(err, Not(Equals), nil) 25 | 26 | // Arrays consume their element type code 27 | next, err = Signature("ai").NextType(0) 28 | c.Check(next, Equals, 2) 29 | c.Check(err, Equals, nil) 30 | 31 | // Array without element type code gives error 32 | next, err = Signature("a").NextType(0) 33 | c.Check(err, Not(Equals), nil) 34 | 35 | // Structs are consumed entirely 36 | next, err = Signature("(isv)").NextType(0) 37 | c.Check(next, Equals, 5) 38 | c.Check(err, Equals, nil) 39 | 40 | // Incomplete struct gives error 41 | next, err = Signature("(isv").NextType(0) 42 | c.Check(err, Not(Equals), nil) 43 | 44 | // Dict entries have two contained type codes 45 | next, err = Signature("{ii}").NextType(0) 46 | c.Check(next, Equals, 4) 47 | c.Check(err, Equals, nil) 48 | 49 | next, err = Signature("{}").NextType(0) 50 | c.Check(err, Not(Equals), nil) 51 | next, err = Signature("{i}").NextType(0) 52 | c.Check(err, Not(Equals), nil) 53 | next, err = Signature("{iii}").NextType(0) 54 | c.Check(err, Not(Equals), nil) 55 | next, err = Signature("{ii").NextType(0) 56 | c.Check(err, Not(Equals), nil) 57 | 58 | // Now a recursive type combining the above. 59 | next, err = Signature("a{s(saax)}").NextType(0) 60 | c.Check(next, Equals, 10) 61 | c.Check(err, Equals, nil) 62 | } 63 | 64 | func (s *S) TestSignatureValidate(c *C) { 65 | c.Check(Signature("a{s(sax)}aav").Validate(), Equals, nil) 66 | c.Check(Signature("a").Validate(), Not(Equals), nil) 67 | c.Check(Signature("a(ii").Validate(), Not(Equals), nil) 68 | } 69 | -------------------------------------------------------------------------------- /units.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013 CoreOS, Inc 3 | * Copyright 2013 Docker Authors 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package main 19 | 20 | import ( 21 | "encoding/json" 22 | "fmt" 23 | "github.com/gorilla/mux" 24 | "github.com/philips/go-systemd" 25 | "net/http" 26 | ) 27 | 28 | func listHandler(w http.ResponseWriter, r *http.Request) { 29 | var ( 30 | out interface{} 31 | ) 32 | 33 | s := new(systemd.Systemd1) 34 | err := s.Connect() 35 | if err != nil { 36 | // TODO: Return 40* code 37 | fmt.Fprint(w, err) 38 | } 39 | 40 | out, err = s.ListUnits() 41 | 42 | if err != nil { 43 | // TODO: Return 40* code 44 | fmt.Fprint(w, err) 45 | } 46 | 47 | outJson, _ := json.Marshal(out) 48 | fmt.Println("%s\n", outJson) 49 | fmt.Fprint(w, "%s\n", outJson) 50 | } 51 | 52 | func unitHandler(w http.ResponseWriter, r *http.Request) { 53 | var ( 54 | out interface{} 55 | ) 56 | 57 | vars := mux.Vars(r) 58 | s := new(systemd.Systemd1) 59 | err := s.Connect() 60 | if err != nil { 61 | // TODO: Return 40* code 62 | w.WriteHeader(404) 63 | fmt.Fprint(w, err) 64 | } 65 | 66 | switch vars["method"] { 67 | case "start": 68 | out, err = s.StartUnit(vars["unit"], vars["mode"]) 69 | case "stop": 70 | out, err = s.StopUnit(vars["unit"], vars["mode"]) 71 | } 72 | 73 | if err != nil { 74 | w.WriteHeader(404) 75 | } 76 | 77 | outJson, _ := json.Marshal(out) 78 | fmt.Fprintf(w, "%s\n", outJson) 79 | } 80 | 81 | func setupUnits(r *mux.Router, o Options) { 82 | r.HandleFunc("", listHandler) 83 | r.HandleFunc("/", listHandler) 84 | r.HandleFunc("/{unit}/{method}/{mode}", unitHandler) 85 | 86 | return 87 | } 88 | -------------------------------------------------------------------------------- /update.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013 CoreOS, Inc 3 | * Copyright 2013 Docker Authors 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package main 19 | 20 | import ( 21 | "github.com/gorilla/mux" 22 | "net/http" 23 | "os/exec" 24 | "io" 25 | "fmt" 26 | ) 27 | 28 | // TODO(bp): Use DBUS endpoints and make this JSON! 29 | func updateHandler(w http.ResponseWriter, r *http.Request) { 30 | cmd := exec.Command("update_engine_client", "-update", "-omaha_url=http://update.core-os.net") 31 | stdout, err := cmd.StdoutPipe() 32 | if err != nil { 33 | w.WriteHeader(400) 34 | fmt.Fprint(w, err) 35 | return 36 | } 37 | if err := cmd.Start(); err != nil { 38 | w.WriteHeader(400) 39 | fmt.Fprint(w, err) 40 | return 41 | } 42 | io.Copy(w, stdout) 43 | if err := cmd.Wait(); err != nil { 44 | w.WriteHeader(400) 45 | fmt.Fprint(w, err) 46 | return 47 | } 48 | return 49 | } 50 | 51 | func setupUpdate(r *mux.Router, o Options) { 52 | r.HandleFunc("", updateHandler) 53 | r.HandleFunc("/", updateHandler) 54 | 55 | return 56 | } 57 | --------------------------------------------------------------------------------