diff --git a/components/engine/.gitignore b/components/engine/.gitignore index 15841891c7..512e4f2cd9 100644 --- a/components/engine/.gitignore +++ b/components/engine/.gitignore @@ -15,3 +15,4 @@ docs/_build docs/_static docs/_templates .gopath/ +.dotcloud diff --git a/components/engine/api.go b/components/engine/api.go index 8772994e47..c4a5222dc6 100644 --- a/components/engine/api.go +++ b/components/engine/api.go @@ -170,7 +170,7 @@ func getContainersExport(srv *Server, version float64, w http.ResponseWriter, r name := vars["name"] if err := srv.ContainerExport(name, w); err != nil { - utils.Debugf("%s", err.Error()) + utils.Debugf("%s", err) return err } return nil @@ -306,7 +306,7 @@ func postCommit(srv *Server, version float64, w http.ResponseWriter, r *http.Req } config := &Config{} if err := json.NewDecoder(r.Body).Decode(config); err != nil { - utils.Debugf("%s", err.Error()) + utils.Debugf("%s", err) } repo := r.Form.Get("repo") tag := r.Form.Get("tag") @@ -342,8 +342,7 @@ func postImagesCreate(srv *Server, version float64, w http.ResponseWriter, r *ht } sf := utils.NewStreamFormatter(version > 1.0) if image != "" { //pull - registry := r.Form.Get("registry") - if err := srv.ImagePull(image, tag, registry, w, sf, &auth.AuthConfig{}); err != nil { + if err := srv.ImagePull(image, tag, w, sf, &auth.AuthConfig{}); err != nil { if sf.Used() { w.Write(sf.FormatError(err)) return nil @@ -426,7 +425,6 @@ func postImagesPush(srv *Server, version float64, w http.ResponseWriter, r *http if err := parseForm(r); err != nil { return err } - registry := r.Form.Get("registry") if vars == nil { return fmt.Errorf("Missing parameter") @@ -436,7 +434,7 @@ func postImagesPush(srv *Server, version float64, w http.ResponseWriter, r *http w.Header().Set("Content-Type", "application/json") } sf := utils.NewStreamFormatter(version > 1.0) - if err := srv.ImagePush(name, registry, w, sf, authConfig); err != nil { + if err := srv.ImagePush(name, w, sf, authConfig); err != nil { if sf.Used() { w.Write(sf.FormatError(err)) return nil @@ -880,7 +878,7 @@ func createRouter(srv *Server, logging bool) (*mux.Router, error) { localMethod := method localFct := fct f := func(w http.ResponseWriter, r *http.Request) { - utils.Debugf("Calling %s %s", localMethod, localRoute) + utils.Debugf("Calling %s %s from %s", localMethod, localRoute, r.RemoteAddr) if logging { log.Println(r.Method, r.RequestURI) diff --git a/components/engine/api_test.go b/components/engine/api_test.go index 487394a549..6eb2584b01 100644 --- a/components/engine/api_test.go +++ b/components/engine/api_test.go @@ -99,7 +99,7 @@ func TestGetVersion(t *testing.T) { t.Fatal(err) } if v.Version != VERSION { - t.Errorf("Excepted version %s, %s found", VERSION, v.Version) + t.Errorf("Expected version %s, %s found", VERSION, v.Version) } } @@ -129,7 +129,7 @@ func TestGetInfo(t *testing.T) { t.Fatal(err) } if infos.Images != len(initialImages) { - t.Errorf("Excepted images: %d, %d found", len(initialImages), infos.Images) + t.Errorf("Expected images: %d, %d found", len(initialImages), infos.Images) } } @@ -166,7 +166,7 @@ func TestGetImagesJSON(t *testing.T) { } if len(images) != len(initialImages) { - t.Errorf("Excepted %d image, %d found", len(initialImages), len(images)) + t.Errorf("Expected %d image, %d found", len(initialImages), len(images)) } found := false @@ -177,7 +177,7 @@ func TestGetImagesJSON(t *testing.T) { } } if !found { - t.Errorf("Excepted image %s, %+v found", unitTestImageName, images) + t.Errorf("Expected image %s, %+v found", unitTestImageName, images) } r2 := httptest.NewRecorder() @@ -204,7 +204,7 @@ func TestGetImagesJSON(t *testing.T) { } if len(images2) != len(initialImages) { - t.Errorf("Excepted %d image, %d found", len(initialImages), len(images2)) + t.Errorf("Expected %d image, %d found", len(initialImages), len(images2)) } found = false @@ -236,7 +236,7 @@ func TestGetImagesJSON(t *testing.T) { } if len(images3) != 0 { - t.Errorf("Excepted 0 image, %d found", len(images3)) + t.Errorf("Expected 0 image, %d found", len(images3)) } r4 := httptest.NewRecorder() @@ -282,7 +282,7 @@ func TestGetImagesViz(t *testing.T) { t.Fatal(err) } if line != "digraph docker {\n" { - t.Errorf("Excepted digraph docker {\n, %s found", line) + t.Errorf("Expected digraph docker {\n, %s found", line) } } @@ -313,7 +313,7 @@ func TestGetImagesSearch(t *testing.T) { t.Fatal(err) } if len(results) < 2 { - t.Errorf("Excepted at least 2 lines, %d found", len(results)) + t.Errorf("Expected at least 2 lines, %d found", len(results)) } } @@ -337,7 +337,7 @@ func TestGetImagesHistory(t *testing.T) { t.Fatal(err) } if len(history) != 1 { - t.Errorf("Excepted 1 line, %d found", len(history)) + t.Errorf("Expected 1 line, %d found", len(history)) } } @@ -359,7 +359,7 @@ func TestGetImagesByName(t *testing.T) { if err := json.Unmarshal(r.Body.Bytes(), img); err != nil { t.Fatal(err) } - if img.ID != unitTestImageId { + if img.ID != unitTestImageID { t.Errorf("Error inspecting image") } } @@ -396,7 +396,7 @@ func TestGetContainersJSON(t *testing.T) { t.Fatal(err) } if len(containers) != 1 { - t.Fatalf("Excepted %d container, %d found", 1, len(containers)) + t.Fatalf("Expected %d container, %d found", 1, len(containers)) } if containers[0].ID != container.ID { t.Fatalf("Container ID mismatch. Expected: %s, received: %s\n", container.ID, containers[0].ID) @@ -1356,24 +1356,34 @@ func TestDeleteImages(t *testing.T) { } if len(images) != len(initialImages)+1 { - t.Errorf("Excepted %d images, %d found", len(initialImages)+1, len(images)) + t.Errorf("Expected %d images, %d found", len(initialImages)+1, len(images)) } - req, err := http.NewRequest("DELETE", "/images/test:test", nil) + req, err := http.NewRequest("DELETE", "/images/"+unitTestImageID, nil) if err != nil { t.Fatal(err) } r := httptest.NewRecorder() - if err := deleteImages(srv, APIVERSION, r, req, map[string]string{"name": "test:test"}); err != nil { + if err := deleteImages(srv, APIVERSION, r, req, map[string]string{"name": unitTestImageID}); err == nil { + t.Fatalf("Expected conflict error, got none") + } + + req2, err := http.NewRequest("DELETE", "/images/test:test", nil) + if err != nil { t.Fatal(err) } - if r.Code != http.StatusOK { + + r2 := httptest.NewRecorder() + if err := deleteImages(srv, APIVERSION, r2, req2, map[string]string{"name": "test:test"}); err != nil { + t.Fatal(err) + } + if r2.Code != http.StatusOK { t.Fatalf("%d OK expected, received %d\n", http.StatusOK, r.Code) } var outs []APIRmi - if err := json.Unmarshal(r.Body.Bytes(), &outs); err != nil { + if err := json.Unmarshal(r2.Body.Bytes(), &outs); err != nil { t.Fatal(err) } if len(outs) != 1 { @@ -1385,7 +1395,7 @@ func TestDeleteImages(t *testing.T) { } if len(images) != len(initialImages) { - t.Errorf("Excepted %d image, %d found", len(initialImages), len(images)) + t.Errorf("Expected %d image, %d found", len(initialImages), len(images)) } /* if c := runtime.Get(container.Id); c != nil { diff --git a/components/engine/archive.go b/components/engine/archive.go index 357fdd9a71..c9a650cb8d 100644 --- a/components/engine/archive.go +++ b/components/engine/archive.go @@ -4,7 +4,6 @@ import ( "archive/tar" "bufio" "bytes" - "errors" "fmt" "github.com/dotcloud/docker/utils" "io" @@ -251,7 +250,7 @@ func CmdStream(cmd *exec.Cmd) (io.Reader, error) { } errText := <-errChan if err := cmd.Wait(); err != nil { - pipeW.CloseWithError(errors.New(err.Error() + ": " + string(errText))) + pipeW.CloseWithError(fmt.Errorf("%s: %s", err, errText)) } else { pipeW.Close() } diff --git a/components/engine/archive_test.go b/components/engine/archive_test.go index bb4235ad5b..9a0a8e1b9e 100644 --- a/components/engine/archive_test.go +++ b/components/engine/archive_test.go @@ -16,7 +16,7 @@ func TestCmdStreamLargeStderr(t *testing.T) { cmd := exec.Command("/bin/sh", "-c", "dd if=/dev/zero bs=1k count=1000 of=/dev/stderr; echo hello") out, err := CmdStream(cmd) if err != nil { - t.Fatalf("Failed to start command: " + err.Error()) + t.Fatalf("Failed to start command: %s", err) } errCh := make(chan error) go func() { @@ -26,7 +26,7 @@ func TestCmdStreamLargeStderr(t *testing.T) { select { case err := <-errCh: if err != nil { - t.Fatalf("Command should not have failed (err=%s...)", err.Error()[:100]) + t.Fatalf("Command should not have failed (err=%.100s...)", err) } case <-time.After(5 * time.Second): t.Fatalf("Command did not complete in 5 seconds; probable deadlock") @@ -37,12 +37,12 @@ func TestCmdStreamBad(t *testing.T) { badCmd := exec.Command("/bin/sh", "-c", "echo hello; echo >&2 error couldn\\'t reverse the phase pulser; exit 1") out, err := CmdStream(badCmd) if err != nil { - t.Fatalf("Failed to start command: " + err.Error()) + t.Fatalf("Failed to start command: %s", err) } if output, err := ioutil.ReadAll(out); err == nil { t.Fatalf("Command should have failed") } else if err.Error() != "exit status 1: error couldn't reverse the phase pulser\n" { - t.Fatalf("Wrong error value (%s)", err.Error()) + t.Fatalf("Wrong error value (%s)", err) } else if s := string(output); s != "hello\n" { t.Fatalf("Command output should be '%s', not '%s'", "hello\\n", output) } diff --git a/components/engine/auth/auth.go b/components/engine/auth/auth.go index 205b9479f5..2e52af88de 100644 --- a/components/engine/auth/auth.go +++ b/components/engine/auth/auth.go @@ -15,8 +15,8 @@ import ( // Where we store the config file const CONFIGFILE = ".dockercfg" -// the registry server we want to login against -const INDEXSERVER = "https://index.docker.io/v1" +// Only used for user auth + account creation +const INDEXSERVER = "https://index.docker.io/v1/" //const INDEXSERVER = "http://indexstaging-docker.dotcloud.com/" @@ -42,7 +42,7 @@ func NewAuthConfig(username, password, email, rootPath string) *AuthConfig { func IndexServerAddress() string { if os.Getenv("DOCKER_INDEX_URL") != "" { - return os.Getenv("DOCKER_INDEX_URL") + "/v1" + return os.Getenv("DOCKER_INDEX_URL") + "/v1/" } return INDEXSERVER } @@ -132,7 +132,7 @@ func Login(authConfig *AuthConfig, store bool) (string, error) { // using `bytes.NewReader(jsonBody)` here causes the server to respond with a 411 status. b := strings.NewReader(string(jsonBody)) - req1, err := http.Post(IndexServerAddress()+"/users/", "application/json; charset=utf-8", b) + req1, err := http.Post(IndexServerAddress()+"users/", "application/json; charset=utf-8", b) if err != nil { return "", fmt.Errorf("Server Error: %s", err) } @@ -152,7 +152,7 @@ func Login(authConfig *AuthConfig, store bool) (string, error) { "Please check your e-mail for a confirmation link.") } else if reqStatusCode == 400 { if string(reqBody) == "\"Username or email already exists\"" { - req, err := http.NewRequest("GET", IndexServerAddress()+"/users/", nil) + req, err := http.NewRequest("GET", IndexServerAddress()+"users/", nil) req.SetBasicAuth(authConfig.Username, authConfig.Password) resp, err := client.Do(req) if err != nil { diff --git a/components/engine/auth/auth_test.go b/components/engine/auth/auth_test.go index 8e7adaef8d..d036de7364 100644 --- a/components/engine/auth/auth_test.go +++ b/components/engine/auth/auth_test.go @@ -68,6 +68,6 @@ func TestCreateAccount(t *testing.T) { expectedError := "Login: Account is not Active" if !strings.Contains(err.Error(), expectedError) { - t.Fatalf("Expected message \"%s\" but found \"%s\" instead", expectedError, err.Error()) + t.Fatalf("Expected message \"%s\" but found \"%s\" instead", expectedError, err) } } diff --git a/components/engine/buildfile.go b/components/engine/buildfile.go index cdc2a6b041..570a4eb72c 100644 --- a/components/engine/buildfile.go +++ b/components/engine/buildfile.go @@ -61,7 +61,7 @@ func (b *buildFile) CmdFrom(name string) error { remote = name } - if err := b.srv.ImagePull(remote, tag, "", b.out, utils.NewStreamFormatter(false), nil); err != nil { + if err := b.srv.ImagePull(remote, tag, b.out, utils.NewStreamFormatter(false), nil); err != nil { return err } diff --git a/components/engine/buildfile_test.go b/components/engine/buildfile_test.go index 8dc0410623..b7cc7be8ec 100644 --- a/components/engine/buildfile_test.go +++ b/components/engine/buildfile_test.go @@ -3,14 +3,13 @@ package docker import ( "fmt" "io/ioutil" - "sync" "testing" ) // mkTestContext generates a build context from the contents of the provided dockerfile. // This context is suitable for use as an argument to BuildFile.Build() func mkTestContext(dockerfile string, files [][2]string, t *testing.T) Archive { - context, err := mkBuildContext(fmt.Sprintf(dockerfile, unitTestImageId), files) + context, err := mkBuildContext(fmt.Sprintf(dockerfile, unitTestImageID), files) if err != nil { t.Fatal(err) } @@ -27,7 +26,7 @@ type testContextTemplate struct { // A table of all the contexts to build and test. // A new docker runtime will be created and torn down for each context. -var testContexts []testContextTemplate = []testContextTemplate{ +var testContexts = []testContextTemplate{ { ` from %s @@ -105,7 +104,6 @@ func TestBuild(t *testing.T) { srv := &Server{ runtime: runtime, - lock: &sync.Mutex{}, pullingPool: make(map[string]struct{}), pushingPool: make(map[string]struct{}), } diff --git a/components/engine/commands.go b/components/engine/commands.go index 6e1e5e88c2..35f41e13ce 100644 --- a/components/engine/commands.go +++ b/components/engine/commands.go @@ -19,7 +19,6 @@ import ( "os/signal" "path/filepath" "reflect" - "regexp" "strconv" "strings" "syscall" @@ -721,7 +720,6 @@ func (cli *DockerCli) CmdImport(args ...string) error { func (cli *DockerCli) CmdPush(args ...string) error { cmd := Subcmd("push", "[OPTION] NAME", "Push an image or a repository to the registry") - registry := cmd.String("registry", "", "Registry host to push the image to") if err := cmd.Parse(args); err != nil { return nil } @@ -732,28 +730,16 @@ func (cli *DockerCli) CmdPush(args ...string) error { return nil } - if err := cli.checkIfLogged(*registry == "", "push"); err != nil { + if err := cli.checkIfLogged("push"); err != nil { return err } - if *registry == "" { - // If we're not using a custom registry, we know the restrictions - // applied to repository names and can warn the user in advance. - // Custom repositories can have different rules, and we must also - // allow pushing by image ID. - if len(strings.SplitN(name, "/", 2)) == 1 { - return fmt.Errorf("Impossible to push a \"root\" repository. Please rename your repository in / (ex: %s/%s)", cli.authConfig.Username, name) - } - - nameParts := strings.SplitN(name, "/", 2) - validNamespace := regexp.MustCompile(`^([a-z0-9_]{4,30})$`) - if !validNamespace.MatchString(nameParts[0]) { - return fmt.Errorf("Invalid namespace name (%s), only [a-z0-9_] are allowed, size between 4 and 30", nameParts[0]) - } - validRepo := regexp.MustCompile(`^([a-zA-Z0-9-_.]+)$`) - if !validRepo.MatchString(nameParts[1]) { - return fmt.Errorf("Invalid repository name (%s), only [a-zA-Z0-9-_.] are allowed", nameParts[1]) - } + // If we're not using a custom registry, we know the restrictions + // applied to repository names and can warn the user in advance. + // Custom repositories can have different rules, and we must also + // allow pushing by image ID. + if len(strings.SplitN(name, "/", 2)) == 1 { + return fmt.Errorf("Impossible to push a \"root\" repository. Please rename your repository in / (ex: %s/%s)", cli.authConfig.Username, name) } buf, err := json.Marshal(cli.authConfig) @@ -762,7 +748,6 @@ func (cli *DockerCli) CmdPush(args ...string) error { } v := url.Values{} - v.Set("registry", *registry) if err := cli.stream("POST", "/images/"+name+"/push?"+v.Encode(), bytes.NewBuffer(buf), cli.out); err != nil { return err } @@ -772,7 +757,6 @@ func (cli *DockerCli) CmdPush(args ...string) error { func (cli *DockerCli) CmdPull(args ...string) error { cmd := Subcmd("pull", "NAME", "Pull an image or a repository from the registry") tag := cmd.String("t", "", "Download tagged image in repository") - registry := cmd.String("registry", "", "Registry to download from. Necessary if image is pulled by ID") if err := cmd.Parse(args); err != nil { return nil } @@ -792,7 +776,6 @@ func (cli *DockerCli) CmdPull(args ...string) error { v := url.Values{} v.Set("fromImage", remote) v.Set("tag", *tag) - v.Set("registry", *registry) if err := cli.stream("POST", "/images/create?"+v.Encode(), nil, cli.out); err != nil { return err @@ -1329,9 +1312,9 @@ func (cli *DockerCli) CmdRun(args ...string) error { return nil } -func (cli *DockerCli) checkIfLogged(condition bool, action string) error { +func (cli *DockerCli) checkIfLogged(action string) error { // If condition AND the login failed - if condition && cli.authConfig.Username == "" { + if cli.authConfig.Username == "" { if err := cli.CmdLogin(""); err != nil { return err } @@ -1565,7 +1548,7 @@ func Subcmd(name, signature, description string) *flag.FlagSet { func NewDockerCli(in io.ReadCloser, out, err io.Writer, proto, addr string) *DockerCli { var ( - isTerminal bool = false + isTerminal = false terminalFd uintptr ) diff --git a/components/engine/commands_test.go b/components/engine/commands_test.go index 87c4c02a52..31cd014e3b 100644 --- a/components/engine/commands_test.go +++ b/components/engine/commands_test.go @@ -142,7 +142,7 @@ func TestRunHostname(t *testing.T) { c := make(chan struct{}) go func() { defer close(c) - if err := cli.CmdRun("-h", "foobar", unitTestImageId, "hostname"); err != nil { + if err := cli.CmdRun("-h", "foobar", unitTestImageID, "hostname"); err != nil { t.Fatal(err) } }() @@ -335,7 +335,7 @@ func TestRunAttachStdin(t *testing.T) { ch := make(chan struct{}) go func() { defer close(ch) - cli.CmdRun("-i", "-a", "stdin", unitTestImageId, "sh", "-c", "echo hello && cat") + cli.CmdRun("-i", "-a", "stdin", unitTestImageID, "sh", "-c", "echo hello && cat") }() // Send input to the command, close stdin diff --git a/components/engine/container.go b/components/engine/container.go index 7acbc7ba69..fa3ccdd78b 100644 --- a/components/engine/container.go +++ b/components/engine/container.go @@ -486,8 +486,8 @@ func (container *Container) Attach(stdin io.ReadCloser, stdinCloser io.Closer, s } func (container *Container) Start(hostConfig *HostConfig) error { - container.State.lock() - defer container.State.unlock() + container.State.Lock() + defer container.State.Unlock() if len(hostConfig.Binds) == 0 { hostConfig, _ = container.ReadHostConfig() } @@ -517,7 +517,7 @@ func (container *Container) Start(hostConfig *HostConfig) error { // Create the requested bind mounts binds := make(map[string]BindMap) // Define illegal container destinations - illegal_dsts := []string{"/", "."} + illegalDsts := []string{"/", "."} for _, bind := range hostConfig.Binds { // FIXME: factorize bind parsing in parseBind @@ -536,7 +536,7 @@ func (container *Container) Start(hostConfig *HostConfig) error { } // Bail if trying to mount to an illegal destination - for _, illegal := range illegal_dsts { + for _, illegal := range illegalDsts { if dst == illegal { return fmt.Errorf("Illegal bind destination: %s", dst) } @@ -845,8 +845,8 @@ func (container *Container) kill() error { } func (container *Container) Kill() error { - container.State.lock() - defer container.State.unlock() + container.State.Lock() + defer container.State.Unlock() if !container.State.Running { return nil } @@ -854,8 +854,8 @@ func (container *Container) Kill() error { } func (container *Container) Stop(seconds int) error { - container.State.lock() - defer container.State.unlock() + container.State.Lock() + defer container.State.Unlock() if !container.State.Running { return nil } diff --git a/components/engine/docker/docker.go b/components/engine/docker/docker.go index c508d8905e..fb7c465369 100644 --- a/components/engine/docker/docker.go +++ b/components/engine/docker/docker.go @@ -37,7 +37,7 @@ func main() { flag.Var(&flHosts, "H", "tcp://host:port to bind/connect to or unix://path/to/socket to use") flag.Parse() if len(flHosts) > 1 { - flHosts = flHosts[1:len(flHosts)] //trick to display a nice defaul value in the usage + flHosts = flHosts[1:] //trick to display a nice defaul value in the usage } for i, flHost := range flHosts { flHosts[i] = utils.ParseHost(docker.DEFAULTHTTPHOST, docker.DEFAULTHTTPPORT, flHost) diff --git a/components/engine/docs/sources/concepts/images/dockerlogo-h.png b/components/engine/docs/sources/concepts/images/dockerlogo-h.png new file mode 100644 index 0000000000..d0e37e548b Binary files /dev/null and b/components/engine/docs/sources/concepts/images/dockerlogo-h.png differ diff --git a/components/engine/docs/sources/concepts/images/dockerlogo-v.png b/components/engine/docs/sources/concepts/images/dockerlogo-v.png new file mode 100644 index 0000000000..591e770d27 Binary files /dev/null and b/components/engine/docs/sources/concepts/images/dockerlogo-v.png differ diff --git a/components/engine/docs/sources/concepts/index.rst b/components/engine/docs/sources/concepts/index.rst index 8b02d15d33..e1cb8cd1a9 100644 --- a/components/engine/docs/sources/concepts/index.rst +++ b/components/engine/docs/sources/concepts/index.rst @@ -1,10 +1,10 @@ -:title: Concepts -:description: -- todo: change me +:title: Overview +:description: Docker documentation summary :keywords: concepts, documentation, docker, containers -Concepts +Overview ======== Contents: @@ -13,4 +13,4 @@ Contents: :maxdepth: 1 ../index - + manifesto diff --git a/components/engine/docs/sources/concepts/manifesto.rst b/components/engine/docs/sources/concepts/manifesto.rst new file mode 100644 index 0000000000..ae09647094 --- /dev/null +++ b/components/engine/docs/sources/concepts/manifesto.rst @@ -0,0 +1,190 @@ +:title: Manifesto +:description: An overview of Docker and standard containers +:keywords: containers, lxc, concepts, explanation + +.. _dockermanifesto: + +*(This was our original Welcome page, but it is a bit forward-looking +for docs, and maybe not enough vision for a true manifesto. We'll +reveal more vision in the future to make it more Manifesto-y.)* + +Docker Manifesto +---------------- + +Docker complements LXC with a high-level API which operates at the +process level. It runs unix processes with strong guarantees of +isolation and repeatability across servers. + +Docker is a great building block for automating distributed systems: +large-scale web deployments, database clusters, continuous deployment +systems, private PaaS, service-oriented architectures, etc. + +- **Heterogeneous payloads** Any combination of binaries, libraries, + configuration files, scripts, virtualenvs, jars, gems, tarballs, you + name it. No more juggling between domain-specific tools. Docker can + deploy and run them all. +- **Any server** Docker can run on any x64 machine with a modern linux + kernel - whether it's a laptop, a bare metal server or a VM. This + makes it perfect for multi-cloud deployments. +- **Isolation** docker isolates processes from each other and from the + underlying host, using lightweight containers. +- **Repeatability** Because containers are isolated in their own + filesystem, they behave the same regardless of where, when, and + alongside what they run. + +.. image:: images/lego_docker.jpg + :target: http://bricks.argz.com/ins/7823-1/12 + +What is a Standard Container? +............................. + +Docker defines a unit of software delivery called a Standard +Container. The goal of a Standard Container is to encapsulate a +software component and all its dependencies in a format that is +self-describing and portable, so that any compliant runtime can run it +without extra dependency, regardless of the underlying machine and the +contents of the container. + +The spec for Standard Containers is currently work in progress, but it +is very straightforward. It mostly defines 1) an image format, 2) a +set of standard operations, and 3) an execution environment. + +A great analogy for this is the shipping container. Just like Standard +Containers are a fundamental unit of software delivery, shipping +containers are a fundamental unit of physical delivery. + +Standard operations +~~~~~~~~~~~~~~~~~~~ + +Just like shipping containers, Standard Containers define a set of +STANDARD OPERATIONS. Shipping containers can be lifted, stacked, +locked, loaded, unloaded and labelled. Similarly, standard containers +can be started, stopped, copied, snapshotted, downloaded, uploaded and +tagged. + + +Content-agnostic +~~~~~~~~~~~~~~~~~~~ + +Just like shipping containers, Standard Containers are +CONTENT-AGNOSTIC: all standard operations have the same effect +regardless of the contents. A shipping container will be stacked in +exactly the same way whether it contains Vietnamese powder coffee or +spare Maserati parts. Similarly, Standard Containers are started or +uploaded in the same way whether they contain a postgres database, a +php application with its dependencies and application server, or Java +build artifacts. + +Infrastructure-agnostic +~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Both types of containers are INFRASTRUCTURE-AGNOSTIC: they can be +transported to thousands of facilities around the world, and +manipulated by a wide variety of equipment. A shipping container can +be packed in a factory in Ukraine, transported by truck to the nearest +routing center, stacked onto a train, loaded into a German boat by an +Australian-built crane, stored in a warehouse at a US facility, +etc. Similarly, a standard container can be bundled on my laptop, +uploaded to S3, downloaded, run and snapshotted by a build server at +Equinix in Virginia, uploaded to 10 staging servers in a home-made +Openstack cluster, then sent to 30 production instances across 3 EC2 +regions. + + +Designed for automation +~~~~~~~~~~~~~~~~~~~~~~~ + +Because they offer the same standard operations regardless of content +and infrastructure, Standard Containers, just like their physical +counterpart, are extremely well-suited for automation. In fact, you +could say automation is their secret weapon. + +Many things that once required time-consuming and error-prone human +effort can now be programmed. Before shipping containers, a bag of +powder coffee was hauled, dragged, dropped, rolled and stacked by 10 +different people in 10 different locations by the time it reached its +destination. 1 out of 50 disappeared. 1 out of 20 was damaged. The +process was slow, inefficient and cost a fortune - and was entirely +different depending on the facility and the type of goods. + +Similarly, before Standard Containers, by the time a software +component ran in production, it had been individually built, +configured, bundled, documented, patched, vendored, templated, tweaked +and instrumented by 10 different people on 10 different +computers. Builds failed, libraries conflicted, mirrors crashed, +post-it notes were lost, logs were misplaced, cluster updates were +half-broken. The process was slow, inefficient and cost a fortune - +and was entirely different depending on the language and +infrastructure provider. + +Industrial-grade delivery +~~~~~~~~~~~~~~~~~~~~~~~~~ + +There are 17 million shipping containers in existence, packed with +every physical good imaginable. Every single one of them can be loaded +on the same boats, by the same cranes, in the same facilities, and +sent anywhere in the World with incredible efficiency. It is +embarrassing to think that a 30 ton shipment of coffee can safely +travel half-way across the World in *less time* than it takes a +software team to deliver its code from one datacenter to another +sitting 10 miles away. + +With Standard Containers we can put an end to that embarrassment, by +making INDUSTRIAL-GRADE DELIVERY of software a reality. + +Standard Container Specification +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +(TODO) + +Image format +~~~~~~~~~~~~ + +Standard operations +~~~~~~~~~~~~~~~~~~~ + +- Copy +- Run +- Stop +- Wait +- Commit +- Attach standard streams +- List filesystem changes +- ... + +Execution environment +~~~~~~~~~~~~~~~~~~~~~ + +Root filesystem +^^^^^^^^^^^^^^^ + +Environment variables +^^^^^^^^^^^^^^^^^^^^^ + +Process arguments +^^^^^^^^^^^^^^^^^ + +Networking +^^^^^^^^^^ + +Process namespacing +^^^^^^^^^^^^^^^^^^^ + +Resource limits +^^^^^^^^^^^^^^^ + +Process monitoring +^^^^^^^^^^^^^^^^^^ + +Logging +^^^^^^^ + +Signals +^^^^^^^ + +Pseudo-terminal allocation +^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Security +^^^^^^^^ + diff --git a/components/engine/docs/sources/index.rst b/components/engine/docs/sources/index.rst index 3e66fde1fb..05e69dd8e5 100644 --- a/components/engine/docs/sources/index.rst +++ b/components/engine/docs/sources/index.rst @@ -1,127 +1,38 @@ -:title: Introduction -:description: An introduction to docker and standard containers? +:title: Welcome to the Docker Documentation +:description: An overview of the Docker Documentation :keywords: containers, lxc, concepts, explanation .. _introduction: -Introduction -============ +Welcome +======= -Docker -- The Linux container runtime -------------------------------------- +.. image:: concepts/images/dockerlogo-h.png -Docker complements LXC with a high-level API which operates at the process level. It runs unix processes with strong guarantees of isolation and repeatability across servers. +``docker``, the Linux Container Runtime, runs Unix processes with +strong guarantees of isolation across servers. Your software runs +repeatably everywhere because its :ref:`container_def` includes any +dependencies. -Docker is a great building block for automating distributed systems: large-scale web deployments, database clusters, continuous deployment systems, private PaaS, service-oriented architectures, etc. +``docker`` runs three ways: +* as a daemon to manage LXC containers on your :ref:`Linux host + ` (``sudo docker -d``) +* as a :ref:`CLI ` which talks to the daemon's `REST API + `_ (``docker run ...``) +* as a client of :ref:`Repositories ` + that let you share what you've built (``docker pull, docker + commit``). -- **Heterogeneous payloads** Any combination of binaries, libraries, configuration files, scripts, virtualenvs, jars, gems, tarballs, you name it. No more juggling between domain-specific tools. Docker can deploy and run them all. -- **Any server** Docker can run on any x64 machine with a modern linux kernel - whether it's a laptop, a bare metal server or a VM. This makes it perfect for multi-cloud deployments. -- **Isolation** docker isolates processes from each other and from the underlying host, using lightweight containers. -- **Repeatability** Because containers are isolated in their own filesystem, they behave the same regardless of where, when, and alongside what they run. +Each use of ``docker`` is documented here. The features of Docker are +currently in active development, so this documention will change +frequently. -.. image:: concepts/images/lego_docker.jpg - - -What is a Standard Container? ------------------------------ - -Docker defines a unit of software delivery called a Standard Container. The goal of a Standard Container is to encapsulate a software component and all its dependencies in -a format that is self-describing and portable, so that any compliant runtime can run it without extra dependency, regardless of the underlying machine and the contents of the container. - -The spec for Standard Containers is currently work in progress, but it is very straightforward. It mostly defines 1) an image format, 2) a set of standard operations, and 3) an execution environment. - -A great analogy for this is the shipping container. Just like Standard Containers are a fundamental unit of software delivery, shipping containers (http://bricks.argz.com/ins/7823-1/12) are a fundamental unit of physical delivery. - -Standard operations -~~~~~~~~~~~~~~~~~~~ - -Just like shipping containers, Standard Containers define a set of STANDARD OPERATIONS. Shipping containers can be lifted, stacked, locked, loaded, unloaded and labelled. Similarly, standard containers can be started, stopped, copied, snapshotted, downloaded, uploaded and tagged. - - -Content-agnostic -~~~~~~~~~~~~~~~~~~~ - -Just like shipping containers, Standard Containers are CONTENT-AGNOSTIC: all standard operations have the same effect regardless of the contents. A shipping container will be stacked in exactly the same way whether it contains Vietnamese powder coffee or spare Maserati parts. Similarly, Standard Containers are started or uploaded in the same way whether they contain a postgres database, a php application with its dependencies and application server, or Java build artifacts. - - -Infrastructure-agnostic -~~~~~~~~~~~~~~~~~~~~~~~~~~ - -Both types of containers are INFRASTRUCTURE-AGNOSTIC: they can be transported to thousands of facilities around the world, and manipulated by a wide variety of equipment. A shipping container can be packed in a factory in Ukraine, transported by truck to the nearest routing center, stacked onto a train, loaded into a German boat by an Australian-built crane, stored in a warehouse at a US facility, etc. Similarly, a standard container can be bundled on my laptop, uploaded to S3, downloaded, run and snapshotted by a build server at Equinix in Virginia, uploaded to 10 staging servers in a home-made Openstack cluster, then sent to 30 production instances across 3 EC2 regions. - - -Designed for automation -~~~~~~~~~~~~~~~~~~~~~~~~~~ - -Because they offer the same standard operations regardless of content and infrastructure, Standard Containers, just like their physical counterpart, are extremely well-suited for automation. In fact, you could say automation is their secret weapon. - -Many things that once required time-consuming and error-prone human effort can now be programmed. Before shipping containers, a bag of powder coffee was hauled, dragged, dropped, rolled and stacked by 10 different people in 10 different locations by the time it reached its destination. 1 out of 50 disappeared. 1 out of 20 was damaged. The process was slow, inefficient and cost a fortune - and was entirely different depending on the facility and the type of goods. - -Similarly, before Standard Containers, by the time a software component ran in production, it had been individually built, configured, bundled, documented, patched, vendored, templated, tweaked and instrumented by 10 different people on 10 different computers. Builds failed, libraries conflicted, mirrors crashed, post-it notes were lost, logs were misplaced, cluster updates were half-broken. The process was slow, inefficient and cost a fortune - and was entirely different depending on the language and infrastructure provider. - - -Industrial-grade delivery -~~~~~~~~~~~~~~~~~~~~~~~~~~ - -There are 17 million shipping containers in existence, packed with every physical good imaginable. Every single one of them can be loaded on the same boats, by the same cranes, in the same facilities, and sent anywhere in the World with incredible efficiency. It is embarrassing to think that a 30 ton shipment of coffee can safely travel half-way across the World in *less time* than it takes a software team to deliver its code from one datacenter to another sitting 10 miles away. - -With Standard Containers we can put an end to that embarrassment, by making INDUSTRIAL-GRADE DELIVERY of software a reality. - - -Standard Container Specification -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -(TODO) - -Image format -~~~~~~~~~~~~ - -Standard operations -~~~~~~~~~~~~~~~~~~~ - -- Copy -- Run -- Stop -- Wait -- Commit -- Attach standard streams -- List filesystem changes -- ... - -Execution environment -~~~~~~~~~~~~~~~~~~~~~ - -Root filesystem -^^^^^^^^^^^^^^^ - -Environment variables -^^^^^^^^^^^^^^^^^^^^^ - -Process arguments -^^^^^^^^^^^^^^^^^ - -Networking -^^^^^^^^^^ - -Process namespacing -^^^^^^^^^^^^^^^^^^^ - -Resource limits -^^^^^^^^^^^^^^^ - -Process monitoring -^^^^^^^^^^^^^^^^^^ - -Logging -^^^^^^^ - -Signals -^^^^^^^ - -Pseudo-terminal allocation -^^^^^^^^^^^^^^^^^^^^^^^^^^ - -Security -^^^^^^^^ +For an overview of Docker, please see the `Introduction +`_. When you're ready to start working with +Docker, we have a `quick start `_ +and a more in-depth guide to :ref:`ubuntu_linux` and other +:ref:`installation_list` paths including prebuilt binaries, +Vagrant-created VMs, Rackspace and Amazon instances. +Enough reading! :ref:`Try it out! ` diff --git a/components/engine/docs/sources/installation/index.rst b/components/engine/docs/sources/installation/index.rst index 9f831091cf..c2a93f5a01 100644 --- a/components/engine/docs/sources/installation/index.rst +++ b/components/engine/docs/sources/installation/index.rst @@ -1,12 +1,17 @@ -:title: Documentation -:description: -- todo: change me -:keywords: todo, docker, documentation, installation, OS support - +:title: Docker Installation +:description: many ways to install Docker +:keywords: docker, installation +.. _installation_list: Installation ============ +There are a number of ways to install Docker, depending on where you +want to run the daemon. The :ref:`ubuntu_linux` installation is the +officially-tested version, and the community adds more techniques for +installing Docker all the time. + Contents: .. toctree:: diff --git a/components/engine/docs/sources/terms/container.rst b/components/engine/docs/sources/terms/container.rst new file mode 100644 index 0000000000..aeb7b1c3a9 --- /dev/null +++ b/components/engine/docs/sources/terms/container.rst @@ -0,0 +1,40 @@ +:title: Container +:description: Definitions of a container +:keywords: containers, lxc, concepts, explanation, image, container + +.. _container_def: + +Container +========= + +.. image:: images/docker-filesystems-busyboxrw.png + +Once you start a process in Docker from an :ref:`image_def`, Docker +fetches the image and its :ref:`parent_image_def`, and repeats the +process until it reaches the :ref:`base_image_def`. Then the +:ref:`ufs_def` adds a read-write layer on top. That read-write layer, +plus the information about its :ref:`parent_image_def` and some +additional information like its unique id, networking configuration, +and resource limits is called a **container**. + +.. _container_state_def: + +Container State +............... + +Containers can change, and so they have state. A container may be +**running** or **exited**. + +When a container is running, the idea of a "container" also includes a +tree of processes running on the CPU, isolated from the other +processes running on the host. + +When the container is exited, the state of the file system and +its exit value is preserved. You can start, stop, and restart a +container. The processes restart from scratch (their memory state is +**not** preserved in a container), but the file system is just as it +was when the container was stopped. + +You can promote a container to an :ref:`image_def` with ``docker +commit``. Once a container is an image, you can use it as a parent for +new containers. diff --git a/components/engine/docs/sources/terms/filesystem.rst b/components/engine/docs/sources/terms/filesystem.rst new file mode 100644 index 0000000000..0af893f198 --- /dev/null +++ b/components/engine/docs/sources/terms/filesystem.rst @@ -0,0 +1,38 @@ +:title: File Systems +:description: How Linux organizes its persistent storage +:keywords: containers, files, linux + +.. _filesystem_def: + +File System +=========== + +.. image:: images/docker-filesystems-generic.png + +In order for a Linux system to run, it typically needs two `file +systems `_: + +1. boot file system (bootfs) +2. root file system (rootfs) + +The **boot file system** contains the bootloader and the kernel. The +user never makes any changes to the boot file system. In fact, soon +after the boot process is complete, the entire kernel is in memory, +and the boot file system is unmounted to free up the RAM associated +with the initrd disk image. + + +The **root file system** includes the typical directory structure we +associate with Unix-like operating systems: ``/dev, /proc, /bin, /etc, +/lib, /usr,`` and ``/tmp`` plus all the configuration files, binaries +and libraries required to run user applications (like bash, ls, and so +forth). + +While there can be important kernel differences between different +Linux distributions, the contents and organization of the root file +system are usually what make your software packages dependent on one +distribution versus another. Docker can help solve this problem by +running multiple distributions at the same time. + +.. image:: images/docker-filesystems-multiroot.png + diff --git a/components/engine/docs/sources/terms/fundamentals.rst b/components/engine/docs/sources/terms/fundamentals.rst deleted file mode 100644 index fed3decb08..0000000000 --- a/components/engine/docs/sources/terms/fundamentals.rst +++ /dev/null @@ -1,97 +0,0 @@ -:title: Image & Container -:description: Definitions of an image and container -:keywords: containers, lxc, concepts, explanation, image, container - -File Systems -============ - -.. image:: images/docker-filesystems-generic.png - -In order for a Linux system to run, it typically needs two `file -systems `_: - -1. boot file system (bootfs) -2. root file system (rootfs) - -The **boot file system** contains the bootloader and the kernel. The -user never makes any changes to the boot file system. In fact, soon -after the boot process is complete, the entire kernel is in memory, -and the boot file system is unmounted to free up the RAM associated -with the initrd disk image. - -The **root file system** includes the typical directory structure we -associate with Unix-like operating systems: ``/dev, /proc, /bin, /etc, -/lib, /usr,`` and ``/tmp`` plus all the configuration files, binaries -and libraries required to run user applications (like bash, ls, and so -forth). - -While there can be important kernal differences between different -Linux distributions, the contents and organization of the root file -system are usually what make your software packages dependent on one -distribution versus another. Docker can help solve this problem by -running multiple distributions at the same time. - -.. image:: images/docker-filesystems-multiroot.png - -Layers and Union Mounts -======================= - -In a traditional Linux boot, the kernel first mounts the root file -system as read-only, checks its integrity, and then switches the whole -rootfs volume to read-write mode. Docker does something similar, -*except* that instead of changing the file system to read-write mode, -it takes advantage of a `union mount -`_ to add a read-write file -system *over* the read-only file system. In fact there may be multiple -read-only file systems stacked on top of each other. - -.. image:: images/docker-filesystems-multilayer.png - -At first, the top layer has nothing in it, but any time a process -creates a file, this happens in the top layer. And if something needs -to update an existing file in a lower layer, then the file gets copied -to the upper layer and changes go into the copy. The version of the -file on the lower layer cannot be seen by the applications anymore, -but it is there, unchanged. - -We call the union of the read-write layer and all the read-only layers -a **union file system**. - -Image -===== - -In Docker terminology, a read-only layer is called an **image**. An -image never changes. Because Docker uses a union file system, the -applications think the whole file system is mounted read-write, -because any file can be changed. But all the changes go to the -top-most layer, and underneath, the image is unchanged. Since they -don't change, images do not have state. - -Each image may depend on one more image which forms the layer beneath -it. We sometimes say that the lower image is the **parent** of the -upper image. - -Base Image -========== - -An image that has no parent is a **base image**. - -Container -========= - -Once you start a process in Docker from an image, Docker fetches the -image and its parent, and repeats the process until it reaches the -base image. Then the union file system adds a read-write layer on -top. That read-write layer, plus the information about its parent and -some additional information like its unique id, is called a -**container**. - -Containers can change, and so they have state. A container may be -running or exited. In either case, the state of the file system and -its exit value is preserved. You can start, stop, and restart a -container. The processes restart from scratch (their memory state is -**not** preserved in a container), but the file system is just as it -was when the container was stopped. - -You can promote a container to an image with ``docker commit``. Once a -container is an image, you can use it as a parent for new containers. diff --git a/components/engine/docs/sources/terms/image.rst b/components/engine/docs/sources/terms/image.rst new file mode 100644 index 0000000000..dafda1f3fc --- /dev/null +++ b/components/engine/docs/sources/terms/image.rst @@ -0,0 +1,38 @@ +:title: Images +:description: Definition of an image +:keywords: containers, lxc, concepts, explanation, image, container + +.. _image_def: + +Image +===== + +.. image:: images/docker-filesystems-debian.png + +In Docker terminology, a read-only :ref:`layer_def` is called an +**image**. An image never changes. + +Since Docker uses a :ref:`ufs_def`, the processes think the whole file +system is mounted read-write. But all the changes go to the top-most +writeable layer, and underneath, the original file in the read-only +image is unchanged. Since images don't change, images do not have state. + +.. image:: images/docker-filesystems-debianrw.png + +.. _parent_image_def: + +Parent Image +............ + +.. image:: images/docker-filesystems-multilayer.png + +Each image may depend on one more image which forms the layer beneath +it. We sometimes say that the lower image is the **parent** of the +upper image. + +.. _base_image_def: + +Base Image +.......... + +An image that has no parent is a **base image**. diff --git a/components/engine/docs/sources/terms/images/docker-filesystems-busyboxrw.png b/components/engine/docs/sources/terms/images/docker-filesystems-busyboxrw.png index b99a58242a..24277dc1f4 100644 Binary files a/components/engine/docs/sources/terms/images/docker-filesystems-busyboxrw.png and b/components/engine/docs/sources/terms/images/docker-filesystems-busyboxrw.png differ diff --git a/components/engine/docs/sources/terms/images/docker-filesystems-debian.png b/components/engine/docs/sources/terms/images/docker-filesystems-debian.png index 0a6468a472..8411733a5f 100644 Binary files a/components/engine/docs/sources/terms/images/docker-filesystems-debian.png and b/components/engine/docs/sources/terms/images/docker-filesystems-debian.png differ diff --git a/components/engine/docs/sources/terms/images/docker-filesystems-debianrw.png b/components/engine/docs/sources/terms/images/docker-filesystems-debianrw.png index 68537f2f51..b7b16c1cc2 100644 Binary files a/components/engine/docs/sources/terms/images/docker-filesystems-debianrw.png and b/components/engine/docs/sources/terms/images/docker-filesystems-debianrw.png differ diff --git a/components/engine/docs/sources/terms/images/docker-filesystems-generic.png b/components/engine/docs/sources/terms/images/docker-filesystems-generic.png index 3866b95609..a6710680a9 100644 Binary files a/components/engine/docs/sources/terms/images/docker-filesystems-generic.png and b/components/engine/docs/sources/terms/images/docker-filesystems-generic.png differ diff --git a/components/engine/docs/sources/terms/images/docker-filesystems-multilayer.png b/components/engine/docs/sources/terms/images/docker-filesystems-multilayer.png index 2fdb236551..025a9d47bd 100644 Binary files a/components/engine/docs/sources/terms/images/docker-filesystems-multilayer.png and b/components/engine/docs/sources/terms/images/docker-filesystems-multilayer.png differ diff --git a/components/engine/docs/sources/terms/images/docker-filesystems-multiroot.png b/components/engine/docs/sources/terms/images/docker-filesystems-multiroot.png index d575b3a4c1..42a710cc82 100644 Binary files a/components/engine/docs/sources/terms/images/docker-filesystems-multiroot.png and b/components/engine/docs/sources/terms/images/docker-filesystems-multiroot.png differ diff --git a/components/engine/docs/sources/terms/images/docker-filesystems.svg b/components/engine/docs/sources/terms/images/docker-filesystems.svg index c0e7b5ba12..13d61dc1eb 100644 --- a/components/engine/docs/sources/terms/images/docker-filesystems.svg +++ b/components/engine/docs/sources/terms/images/docker-filesystems.svg @@ -9,15 +9,15 @@ xmlns="http://www.w3.org/2000/svg" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" - inkscape:version="0.48.2 r9819" - version="1.1" - id="svg2" - height="600" - width="800" - sodipodi:docname="docker-filesystems.svg" - inkscape:export-filename="/Users/arothfusz/src/metalivedev/docker/docs/sources/terms/images/docker-filesystems-multilayer.png" + inkscape:export-ydpi="90" inkscape:export-xdpi="90" - inkscape:export-ydpi="90"> + inkscape:export-filename="/Users/arothfusz/src/metalivedev/docker/docs/sources/terms/images/docker-filesystems-multiroot.png" + sodipodi:docname="docker-filesystems.svg" + width="800" + height="600" + id="svg2" + version="1.1" + inkscape:version="0.48.2 r9819"> + id="guide5235" + position="400.40322,131.85484" + orientation="1,0" /> + + + + - - - - - - - - + + id="text7447" + style="font-size:40px;font-style:italic;font-variant:normal;font-weight:500;font-stretch:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;font-family:Futura;-inkscape-font-specification:Futura Medium Italic"> + + + + + + + + + + + + + + + + + d="m 405.68539,517.2315 c 0,0 -0.0193,16.2617 -0.0193,16.2617 0,0 3.17768,-2.015 3.17768,-2.015 0.42104,-0.26699 0.71912,-0.28408 0.89461,-0.0515 0.17538,0.20367 0.26245,0.57777 0.26128,1.12234 -0.001,0.51582 -0.0901,1.00179 -0.26671,1.45807 -0.1768,0.45653 -0.47536,0.81943 -0.89606,1.08884 0,0 -7.2615,4.65021 -7.2615,4.65021 -0.4181,0.26775 -0.71809,0.2856 -0.89962,0.053 -0.18168,-0.23276 -0.27256,-0.61101 -0.27256,-1.13472 0,-0.55292 0.0909,-1.0473 0.27272,-1.48298 0.18171,-0.4645 0.48198,-0.82951 0.90042,-1.09484 0,0 2.35294,-1.49203 2.35294,-1.49203 0,0 0.0349,-43.95921 0.0349,-43.95921 0,0 -2.3762,1.32682 -2.3762,1.32682 -0.4226,0.23601 -0.72583,0.24206 -0.90932,0.0178 -0.18363,-0.25407 -0.2755,-0.66358 -0.2755,-1.22844 0,-0.56489 0.0919,-1.06185 0.27567,-1.49066 0.18367,-0.45823 0.48718,-0.80413 0.91014,-1.03765 0,0 7.3447,-4.05398 7.3447,-4.05398 0.42546,-0.23477 0.72666,-0.22523 0.90398,0.0279 0.17721,0.22388 0.26518,0.61389 0.26399,1.17006 -0.001,0.55615 -0.0911,1.05925 -0.26963,1.50941 -0.1786,0.42125 -0.48025,0.7505 -0.90536,0.98782 0,0 -3.20861,1.79162 -3.20861,1.79162 0,0 -0.027,22.7262 -0.027,22.7262 0,0 11.85347,-29.32986 11.85347,-29.32986 0,0 -1.84356,1.0294 -1.84356,1.0294 -0.4158,0.23222 -0.71071,0.23758 -0.8844,0.0157 -0.17376,-0.25093 -0.25981,-0.65252 -0.25806,-1.20465 0.002,-0.55216 0.0906,-1.03662 0.2666,-1.4532 0.17596,-0.44532 0.4722,-0.78288 0.88832,-1.01263 0,0 4.9265,-2.71923 4.9265,-2.71923 0.39516,-0.21804 0.67722,-0.2015 0.84652,0.049 0.16926,0.22176 0.25255,0.60547 0.24997,1.15114 -0.003,0.54567 -0.0901,1.03822 -0.26231,1.47778 -0.17228,0.41121 -0.45565,0.72699 -0.8505,0.94742 0,0 -0.67254,0.37553 -0.67254,0.37553 0,0 -9.34163,23.22298 -9.34163,23.22298 1.39299,0.391 2.54214,1.22247 3.45037,2.49219 0.90456,1.26471 1.76961,3.30318 2.59512,6.10986 0.47018,1.56163 1.32542,5.36141 2.55962,11.3683 0,0 2.05678,-1.30423 2.05678,-1.30423 0.40304,-0.25557 0.68792,-0.26799 0.85497,-0.0375 0.16702,0.20219 0.24918,0.57016 0.24656,1.10393 -0.003,0.5056 -0.0889,0.98066 -0.25892,1.42533 -0.17022,0.44492 -0.45652,0.79627 -0.85925,1.05417 0,0 -3.17718,2.03464 -3.17718,2.03464 -1.70416,-9.14138 -3.15817,-14.85521 -4.35315,-17.0766 -1.2016,-2.2625 -2.71697,-3.45967 -4.55059,-3.58265 0,0 -3.48846,8.71251 -3.48846,8.71251" + id="path6891" /> + d="m 443.47158,496.16573 c 0,0 -15.92023,9.70195 -15.92023,9.70195 0.25261,4.3947 1.09424,7.53188 2.51855,9.41247 1.42789,1.83288 3.19316,2.07344 5.2907,0.7382 1.15976,-0.73828 2.37336,-1.93312 3.64044,-3.58163 1.2617,-1.64151 2.29067,-3.40363 3.08952,-5.2883 0.23317,-0.55259 0.43412,-0.88169 0.60291,-0.98752 0.19273,-0.12084 0.35959,-0.0498 0.50059,0.2133 0.14113,0.23564 0.20944,0.58439 0.20501,1.04631 -0.004,0.46186 -0.1049,0.97075 -0.30138,1.52697 -0.59063,1.72481 -1.63435,3.65941 -3.13604,5.80979 -1.49675,2.12595 -3.03903,3.70146 -4.62822,4.72308 -2.68176,1.72399 -4.92977,1.22514 -6.73564,-1.52638 -1.80812,-2.81062 -2.70176,-7.0448 -2.66946,-12.69552 0.0295,-5.15711 0.92218,-10.10229 2.67206,-14.81044 1.75462,-4.69402 3.89166,-7.75636 6.39992,-9.19327 2.55976,-1.46633 4.63179,-0.79081 6.22479,2.00024 1.58113,2.74246 2.3269,7.04454 2.24648,12.91075 m -1.50759,-2.55533 c -0.26805,-3.63428 -1.04266,-6.26807 -2.32893,-7.90085 -1.28159,-1.6495 -2.8345,-1.95112 -4.66221,-0.89235 -1.83997,1.06596 -3.44162,3.19609 -4.79954,6.39411 -1.36305,3.21016 -2.22473,6.90224 -2.58104,11.06526 0,0 14.37172,-8.66617 14.37172,-8.66617" + id="path6893" /> + d="m 455.58667,470.66722 c 0,0 -0.10498,8.56019 -0.10498,8.56019 1.93651,-5.08183 3.37081,-8.44336 4.30858,-10.1013 0.94661,-1.68612 1.80908,-2.7511 2.58784,-3.19777 0.84383,-0.48395 1.61379,-0.25336 2.31017,0.68823 0.70553,0.90558 1.05243,1.70098 1.04247,2.38832 -0.007,0.50226 -0.0857,0.96734 -0.23511,1.3954 -0.13804,0.39541 -0.31278,0.65513 -0.52432,0.77918 -0.11142,0.0654 -0.20559,0.0813 -0.28249,0.0476 -0.0766,-0.0601 -0.21729,-0.27954 -0.42229,-0.65871 -0.37824,-0.6994 -0.71083,-1.13744 -0.99754,-1.31325 -0.2871,-0.17598 -0.57132,-0.18255 -0.85261,-0.0195 -0.61996,0.35957 -1.37941,1.38224 -2.27917,3.07105 -0.89096,1.68702 -2.45801,5.46216 -4.70984,11.34948 0,0 -0.22596,18.42612 -0.22596,18.42612 0,0 6.33459,-4.01684 6.33459,-4.01684 0.34746,-0.22033 0.59161,-0.21895 0.7327,0.004 0.14133,0.1965 0.2085,0.54399 0.2016,1.04251 -0.007,0.47221 -0.0847,0.91205 -0.23427,1.31965 -0.14973,0.40781 -0.39805,0.72284 -0.74529,0.94521 0,0 -11.32013,7.24932 -11.32013,7.24932 -0.35123,0.22493 -0.6016,0.23885 -0.75084,0.0414 -0.14907,-0.22443 -0.22099,-0.57831 -0.21571,-1.0616 0.005,-0.45652 0.0796,-0.87735 0.22375,-1.26235 0.15613,-0.41912 0.41594,-0.74392 0.77913,-0.97432 0,0 3.54132,-2.24639 3.54132,-2.24639 0,0 0.33638,-28.17047 0.33638,-28.17047 0,0 -2.71509,1.57907 -2.71509,1.57907 -0.35236,0.20495 -0.60335,0.18908 -0.75268,-0.0481 -0.14946,-0.2372 -0.22135,-0.61416 -0.2156,-1.13086 0.005,-0.48951 0.0807,-0.93834 0.22572,-1.34628 0.15673,-0.41449 0.41745,-0.72656 0.78182,-0.93616 0,0 4.17785,-2.40283 4.17785,-2.40283" + id="path6895" /> + d="m 473.30415,460.47729 c 0,0 -0.0804,4.97133 -0.0804,4.97133 0.98569,-2.87136 1.86574,-4.96674 2.64065,-6.28932 0.77288,-1.31909 1.63191,-2.24853 2.57593,-2.78936 1.01432,-0.58102 1.92593,-0.57975 2.7356,4.3e-4 0.57165,0.43409 1.07517,1.41355 1.51085,2.93619 0.44533,1.487 0.6504,3.16172 0.61612,5.02597 0,0 -0.37098,20.16552 -0.37098,20.16552 0,0 1.09632,-0.69519 1.09632,-0.69519 0.30795,-0.19527 0.52558,-0.18379 0.65312,0.0343 0.1279,0.19274 0.18732,0.5284 0.17832,1.00704 -0.009,0.4534 -0.0822,0.87365 -0.22092,1.26091 -0.13883,0.38745 -0.362,0.67967 -0.66977,0.87676 0,0 -3.48879,2.2342 -3.48879,2.2342 -0.32291,0.20678 -0.54961,0.20133 -0.67985,-0.0168 -0.13035,-0.21825 -0.19152,-0.55628 -0.18341,-1.01409 0.009,-0.48331 0.0832,-0.90811 0.22395,-1.27426 0.14113,-0.39138 0.37338,-0.68956 0.69648,-0.89444 0,0 1.09126,-0.69198 1.09126,-0.69198 0,0 0.35635,-19.67714 0.35635,-19.67714 0.0412,-2.27809 -0.26274,-4.00074 -0.9136,-5.16921 -0.65266,-1.19813 -1.55322,-1.46656 -2.70395,-0.79997 -0.87978,0.50971 -1.6529,1.39411 -2.31814,2.65394 -0.66627,1.2367 -1.63439,3.93929 -2.90635,8.11592 0,0 -0.33083,20.46711 -0.33083,20.46711 0,0 1.52554,-0.96736 1.52554,-0.96736 0.32,-0.20291 0.54652,-0.19417 0.67982,0.026 0.13361,0.19441 0.19632,0.5352 0.1882,1.02244 -0.008,0.46152 -0.0833,0.89021 -0.22665,1.28621 -0.14347,0.39619 -0.37497,0.69664 -0.69477,0.90144 0,0 -4.42215,2.83191 -4.42215,2.83191 -0.3258,0.20863 -0.55714,0.20298 -0.6938,-0.0174 -0.13675,-0.22051 -0.20159,-0.56416 -0.19444,-1.03091 0.008,-0.49277 0.0843,-0.92686 0.23029,-1.30217 0.1463,-0.40101 0.38259,-0.70494 0.70859,-0.91166 0,0 1.54286,-0.97835 1.54286,-0.97835 0,0 0.43113,-27.17649 0.43113,-27.17649 0,0 -1.15824,0.67362 -1.15824,0.67362 -0.32722,0.19033 -0.55954,0.16948 -0.69672,-0.0629 -0.13729,-0.23247 -0.20212,-0.59828 -0.19443,-1.09741 0.007,-0.47286 0.0845,-0.90805 0.23156,-1.30535 0.14701,-0.39707 0.38436,-0.6898 0.71179,-0.87815 0,0 2.52342,-1.45131 2.52342,-1.45131" + id="path6897" /> + d="m 502.73274,460.0514 c 0,0 -12.58078,7.66685 -12.58078,7.66685 0.13943,3.95275 0.75486,6.81973 1.84191,8.60127 1.09127,1.74028 2.46782,2.07625 4.12588,1.02077 0.91736,-0.58398 1.88324,-1.57454 2.89733,-2.9694 1.01026,-1.38958 1.83995,-2.9037 2.49094,-4.54374 0.19007,-0.48101 0.352,-0.76339 0.48584,-0.84731 0.15283,-0.0958 0.2829,-0.0209 0.39022,0.22483 0.10778,0.2211 0.15695,0.53905 0.14755,0.95388 -0.009,0.41479 -0.0948,0.86546 -0.25619,1.35225 -0.48577,1.51058 -1.32969,3.17888 -2.53523,5.00941 -1.20067,1.80791 -2.42926,3.11745 -3.68662,3.92576 -2.11999,1.36285 -3.86995,0.76072 -5.24366,-1.82965 -1.37343,-2.64104 -2.01438,-6.49315 -1.91501,-11.55003 0.0906,-4.61389 0.85108,-8.9821 2.27681,-13.08506 1.42996,-4.0921 3.13808,-6.70212 5.11668,-7.83561 2.02129,-1.15786 3.63504,-0.42605 4.84758,2.17494 1.20485,2.55883 1.735,6.46775 1.59675,11.73084 m -1.15024,-2.39108 c -0.1636,-3.27931 -0.73716,-5.69144 -1.72424,-7.23625 -0.98254,-1.55853 -2.19418,-1.92464 -3.63745,-1.08857 -1.45189,0.84113 -2.73048,2.64931 -3.83206,5.42777 -1.10528,2.78784 -1.82554,6.03803 -2.15785,9.74209 0,0 11.3516,-6.84504 11.3516,-6.84504" + id="path6899" /> - - + d="m 514.91047,422.62215 c 0,0 -1.06434,42.27288 -1.06434,42.27288 0,0 4.45362,-2.8241 4.45362,-2.8241 0.2761,-0.17507 0.46813,-0.15759 0.57629,0.0523 0.10868,0.18619 0.15712,0.50328 0.14534,0.95133 -0.0112,0.42443 -0.0782,0.81493 -0.20113,1.17164 -0.12299,0.35687 -0.32235,0.62363 -0.59831,0.80035 0,0 -10.15763,6.50487 -10.15763,6.50487 -0.27917,0.17878 -0.476,0.16246 -0.5903,-0.0494 -0.11437,-0.21191 -0.16642,-0.53506 -0.15609,-0.96944 0.0109,-0.45857 0.0801,-0.85922 0.20776,-1.20182 0.12814,-0.36656 0.33197,-0.63844 0.61129,-0.81556 0,0 4.56188,-2.89274 4.56188,-2.89274 0,0 0.97884,-39.26779 0.97884,-39.26779 0,0 -3.35907,1.85407 -3.35907,1.85407 -0.27977,0.15447 -0.48159,0.1208 -0.60529,-0.10124 -0.11445,-0.22726 -0.16609,-0.57399 -0.15489,-1.04015 0.0106,-0.44163 0.0802,-0.843 0.20889,-1.204 0.12859,-0.36073 0.33761,-0.62003 0.62686,-0.77784 0,0 4.51628,-2.46343 4.51628,-2.46343" + id="path6901" /> @@ -684,31 +729,6 @@ id="path4004" sodipodi:type="inkscape:box3dside" /> - - - - - - - + transform="matrix(0.74694175,0,0,0.74694175,45.485062,44.593966)"> + id="text5788"> + d="m 292.16734,221.79451 c 0,0 0.079,32.92107 0.079,32.92107 0,0 6.83396,-1.8594 6.83396,-1.8594 0.46993,-0.12786 0.80691,-0.0884 1.01132,0.11827 0.20419,0.18473 0.30715,0.48443 0.30895,0.89923 0.002,0.39306 -0.0986,0.7486 -0.30066,1.06669 -0.20232,0.31832 -0.53842,0.54236 -1.00864,0.67204 0,0 -15.85959,4.37404 -15.85959,4.37404 -0.49118,0.13546 -0.8436,0.0983 -1.05684,-0.11192 -0.21335,-0.21022 -0.32005,-0.51707 -0.32005,-0.92043 0,-0.42568 0.10663,-0.79078 0.31991,-1.09527 0.21307,-0.32663 0.56522,-0.55672 1.05608,-0.69027 0,0 6.99856,-1.90419 6.99856,-1.90419 0,0 -0.0639,-33.01316 -0.0639,-33.01316 0,0 -6.94528,1.58452 -6.94528,1.58452 -0.48709,0.11116 -0.83656,0.0697 -1.04802,-0.12452 -0.21157,-0.21626 -0.31738,-0.53384 -0.31738,-0.95255 0,-0.41857 0.10573,-0.77281 0.31723,-1.06267 0.2113,-0.3116 0.56052,-0.52201 1.04729,-0.63134 0,0 15.72034,-3.52906 15.72034,-3.52906 0.46618,-0.1046 0.80048,-0.0507 1.00326,0.16175 0.20255,0.1909 0.30468,0.4903 0.30646,0.89834 0.002,0.40818 -0.0977,0.76414 -0.29818,1.06788 -0.2008,0.28254 -0.53427,0.47704 -1.00074,0.58343 0,0 -6.78316,1.54752 -6.78316,1.54752" + id="path5793" /> + d="m 310.82617,224.548 c 0,0 0.0183,2.71052 0.0183,2.71052 1.59486,-2.82856 3.1975,-4.42813 4.80917,-4.80918 0.96652,-0.22849 1.81505,-0.0602 2.54657,0.50362 0.73011,0.54196 1.34443,1.48928 1.84362,2.84195 0.81039,-1.66756 1.62919,-2.95534 2.45658,-3.86518 0.83957,-0.93171 1.68046,-1.49641 2.52294,-1.6956 1.31778,-0.31154 2.3707,0.0529 3.16143,1.09107 1.03734,1.32998 1.56558,2.9259 1.58639,4.79109 0,0 0.20434,18.33386 0.20434,18.33386 0,0 1.53013,-0.41632 1.53013,-0.41632 0.42981,-0.11694 0.739,-0.0757 0.92789,0.12381 0.18853,0.17852 0.2851,0.46568 0.2898,0.86158 0.004,0.37517 -0.0849,0.71339 -0.26782,1.01476 -0.18312,0.30159 -0.48957,0.51171 -0.91962,0.63032 0,0 -3.35086,0.92415 -3.35086,0.92415 0,0 -0.22279,-20.77656 -0.22279,-20.77656 -0.0143,-1.33018 -0.30714,-2.3628 -0.87909,-3.0991 -0.57267,-0.73709 -1.22837,-1.01732 -1.9678,-0.8398 -0.66827,0.16051 -1.37063,0.69532 -2.10748,1.60588 -0.73886,0.89188 -1.5757,2.51342 -2.51176,4.86946 0,0 0.15842,17.6379 0.15842,17.6379 0,0 1.54833,-0.42128 1.54833,-0.42128 0.44115,-0.12002 0.75819,-0.0792 0.95147,0.12232 0.19296,0.18032 0.29136,0.47108 0.29523,0.8724 0.004,0.38029 -0.0887,0.72347 -0.27704,1.02961 -0.18854,0.30636 -0.50335,0.52043 -0.94475,0.64217 0,0 -3.43946,0.94859 -3.43946,0.94859 0,0 -0.17831,-20.87173 -0.17831,-20.87173 -0.0121,-1.41164 -0.31784,-2.49778 -0.91785,-3.25983 -0.5861,-0.78757 -1.24345,-1.09429 -1.97265,-0.91922 -0.67099,0.16116 -1.3334,0.62756 -1.98734,1.40021 -0.90879,1.0908 -1.86103,2.82298 -2.85755,5.20088 0,0 0.12057,17.88402 0.12057,17.88402 0,0 1.61271,-0.43879 1.61271,-0.43879 0.45299,-0.12325 0.77823,-0.083 0.97608,0.1207 0.1976,0.18215 0.29787,0.47663 0.3009,0.88354 0.003,0.38558 -0.0926,0.73385 -0.28674,1.04496 -0.19419,0.31131 -0.51774,0.52949 -0.971,0.6545 0,0 -5.16143,1.42351 -5.16143,1.42351 -0.46029,0.12695 -0.79127,0.0881 -0.99256,-0.11674 -0.20137,-0.20491 -0.30318,-0.50235 -0.30537,-0.89222 -0.002,-0.41142 0.0958,-0.76345 0.29429,-1.05603 0.19822,-0.314 0.5275,-0.53357 0.98751,-0.65873 0,0 1.62837,-0.44305 1.62837,-0.44305 0,0 -0.14116,-22.4169 -0.14116,-22.4169 0,0 -1.62022,0.3912 -1.62022,0.3912 -0.4577,0.11052 -0.78681,0.0614 -0.98695,-0.14757 -0.20023,-0.209 -0.30151,-0.51693 -0.3038,-0.92368 -0.002,-0.38522 0.0954,-0.72992 0.29266,-1.034 0.19711,-0.30384 0.52454,-0.51011 0.98197,-0.61888 0,0 3.52575,-0.83819 3.52575,-0.83819" + id="path5795" /> + d="m 350.89656,241.32467 c 0,0 -0.0589,-3.6804 -0.0589,-3.6804 -2.44263,3.80778 -5.10211,6.12062 -7.98027,6.91861 -2.10441,0.58347 -3.76815,0.25666 -4.98415,-0.98555 -1.21953,-1.26623 -1.84495,-3.04991 -1.87379,-5.34667 -0.0317,-2.52154 0.73085,-4.92487 2.28129,-7.20305 1.54219,-2.26605 3.8038,-3.77126 6.77195,-4.51991 0.7964,-0.20085 1.66062,-0.33746 2.59222,-0.41005 0.92884,-0.0925 1.93136,-0.11301 3.00698,-0.0616 0,0 -0.0657,-4.10694 -0.0657,-4.10694 -0.0222,-1.38732 -0.47413,-2.48748 -1.3571,-3.30238 -0.88479,-0.81652 -2.19971,-1.01605 -3.95,-0.59577 -1.34605,0.32326 -3.2353,1.35808 -5.67763,3.11343 -0.44361,0.31258 -0.72851,0.48429 -0.85424,0.51483 -0.22367,0.0544 -0.4211,-0.0207 -0.59224,-0.22543 -0.1572,-0.2081 -0.23822,-0.49632 -0.24303,-0.86451 -0.005,-0.34763 0.0618,-0.6405 0.19913,-0.87854 0.1918,-0.35344 0.97539,-0.96079 2.34657,-1.81956 2.14879,-1.36681 3.76798,-2.17692 4.86556,-2.43642 2.17117,-0.5133 3.8675,-0.11811 5.09661,1.18044 1.22539,1.27503 1.8531,2.9031 1.88568,4.88818 0,0 0.27554,16.79617 0.27554,16.79617 0,0 2.26031,-0.61499 2.26031,-0.61499 0.41544,-0.11304 0.71203,-0.0724 0.89013,0.12173 0.17763,0.17395 0.26972,0.45203 0.27631,0.83437 0.006,0.36231 -0.0756,0.68817 -0.24525,0.97765 -0.1699,0.28969 -0.46252,0.49188 -0.87818,0.60651 0,0 -3.98778,1.09982 -3.98778,1.09982 m -0.20304,-12.6875 c -0.80507,-0.13756 -1.65804,-0.17224 -2.55931,-0.10371 -0.90358,0.0688 -1.85617,0.23114 -2.85824,0.48756 -2.52482,0.64614 -4.49945,1.96292 -5.91531,3.95406 -1.07701,1.49735 -1.60605,3.09291 -1.58411,4.78359 0.0203,1.56816 0.45251,2.77768 1.29533,3.62647 0.85525,0.84341 2.07851,1.0467 3.66561,0.61257 1.51075,-0.41325 2.89832,-1.234 4.16372,-2.45986 1.27358,-1.2449 2.56786,-3.01121 3.88202,-5.29462 0,0 -0.0897,-5.60606 -0.0897,-5.60606" + id="path5797" /> + d="m 375.34938,213.69585 c 0,0 -0.0974,-4.46393 -0.0974,-4.46393 0,0 3.68773,-0.87669 3.68773,-0.87669 0.37208,-0.0884 0.64113,-0.0368 0.8074,0.15502 0.16617,0.1917 0.25341,0.46963 0.26178,0.83387 0.008,0.34517 -0.066,0.6522 -0.22166,0.92112 -0.15581,0.26917 -0.41973,0.44869 -0.792,0.53856 0,0 -2.11132,0.50977 -2.11132,0.50977 0,0 0.54123,24.40071 0.54123,24.40071 0.0363,1.63856 -0.15744,3.16664 -0.58194,4.58541 -0.2835,0.94739 -0.76869,1.98351 -1.45663,3.10962 -0.68973,1.12896 -1.32331,1.97649 -1.90026,2.54121 -0.57809,0.56581 -1.35962,0.99328 -2.34591,1.28221 0,0 -4.61112,1.35073 -4.61112,1.35073 -0.39039,0.11434 -0.67276,0.0767 -0.84684,-0.11314 -0.17377,-0.16995 -0.26435,-0.44453 -0.27168,-0.82361 -0.007,-0.37906 0.0714,-0.71279 0.23628,-1.00117 0.16471,-0.28821 0.4423,-0.4887 0.83248,-0.60152 0,0 4.66707,-1.3197 4.66707,-1.3197 0.94729,-0.27395 1.78841,-0.89388 2.52391,-1.85846 0.74626,-0.96574 1.35024,-2.23429 1.81265,-3.80502 0.26003,-0.90063 0.37608,-1.98619 0.34838,-3.25697 0,0 -0.16086,-7.37517 -0.16086,-7.37517 -1.62758,4.07072 -3.80169,6.48925 -6.53059,7.23934 -2.23287,0.61374 -4.19888,-0.12311 -5.89159,-2.21938 -1.68617,-2.12737 -2.56457,-4.99526 -2.6305,-8.59335 -0.0658,-3.59204 0.69765,-6.85485 2.28324,-9.77979 1.5891,-2.91055 3.49618,-4.62319 5.71739,-5.14835 2.71476,-0.64182 4.95439,0.6184 6.73072,3.76863 m 0.16039,7.3538 c -0.0626,-2.87086 -0.7569,-5.1338 -2.0858,-6.79534 -1.32015,-1.66944 -2.87807,-2.29072 -4.67812,-1.8585 -1.80975,0.43462 -3.35087,1.81991 -4.62062,4.16259 -1.27628,2.33429 -1.88951,4.95932 -1.83504,7.86963 0.0549,2.93412 0.76232,5.25114 2.11916,6.94432 1.35246,1.66842 2.93958,2.25345 4.75697,1.76072 1.80761,-0.49005 3.33004,-1.90799 4.57015,-4.24741 1.2464,-2.3511 1.83598,-4.96126 1.7733,-7.83601" + id="path5799" /> + d="m 400.95375,215.84309 c 0,0 -15.30351,3.94188 -15.30351,3.94188 0.34391,3.04783 1.23396,5.34503 2.66637,6.88627 1.43922,1.51372 3.17433,1.99038 5.19951,1.43641 1.12095,-0.30662 2.28367,-0.91984 3.48738,-1.83766 1.19883,-0.91409 2.16489,-1.95211 2.90025,-3.11439 0.2145,-0.34084 0.40349,-0.53306 0.56706,-0.57689 0.1868,-0.05 0.35355,0.0278 0.50028,0.23369 0.14614,0.18703 0.22361,0.43961 0.23247,0.75782 0.009,0.31828 -0.0759,0.65247 -0.25418,1.00277 -0.53474,1.08992 -1.51174,2.24633 -2.93533,3.4719 -1.41926,1.20943 -2.89777,2.0288 -4.43582,2.45524 -2.59183,0.71861 -4.80714,-0.0257 -6.63604,-2.24415 -1.8247,-2.25008 -2.7858,-5.3079 -2.87757,-9.16136 -0.0834,-3.50233 0.67052,-6.70553 2.2543,-9.60045 1.58612,-2.87997 3.57782,-4.59755 5.9692,-5.16295 2.44485,-0.578 4.47658,0.20903 6.10451,2.35191 1.62144,2.1165 2.47361,5.16594 2.56112,9.15996 m -1.55297,-1.99958 c -0.36339,-2.52164 -1.19348,-4.43925 -2.49343,-5.75652 -1.29227,-1.32421 -2.81005,-1.77891 -4.55736,-1.35935 -1.75678,0.42189 -3.25581,1.59979 -4.49431,3.53879 -1.24433,1.94813 -1.99432,4.30819 -2.24605,7.0779 0,0 13.79115,-3.50082 13.79115,-3.50082" + id="path5801" /> + + + + + + + + - - - - - - - - - - - - - - - + + + + + + + + + + - - - - - - - - - + style="display:none" + inkscape:label="Base Image" + id="layer10" + inkscape:groupmode="layer"> + + + + + + + + + + + + + + + + + + + + `_ to add a read-write file +system *over* the read-only file system. In fact there may be multiple +read-only file systems stacked on top of each other. We think of each +one of these file systems as a **layer**. + +.. image:: images/docker-filesystems-multilayer.png + +At first, the top read-write layer has nothing in it, but any time a +process creates a file, this happens in the top layer. And if +something needs to update an existing file in a lower layer, then the +file gets copied to the upper layer and changes go into the copy. The +version of the file on the lower layer cannot be seen by the +applications anymore, but it is there, unchanged. + +.. _ufs_def: + +Union File System +................. + +We call the union of the read-write layer and all the read-only layers +a **union file system**. diff --git a/components/engine/docs/sources/toctree.rst b/components/engine/docs/sources/toctree.rst index 6226e155f3..3c319863e2 100644 --- a/components/engine/docs/sources/toctree.rst +++ b/components/engine/docs/sources/toctree.rst @@ -17,7 +17,8 @@ This documentation has the following resources: commandline/index contributing/index api/index - faq terms/index + faq + + -.. image:: concepts/images/lego_docker.jpg diff --git a/components/engine/docs/sources/use/workingwithrepository.rst b/components/engine/docs/sources/use/workingwithrepository.rst index 45702597ab..243c99afdf 100644 --- a/components/engine/docs/sources/use/workingwithrepository.rst +++ b/components/engine/docs/sources/use/workingwithrepository.rst @@ -1,21 +1,21 @@ :title: Working With Repositories -:description: Generally, there are two types of repositories: Top-level repositories which are controlled by the people behind Docker, and user repositories. +:description: Repositories allow users to share images. :keywords: repo, repositiores, usage, pull image, push image, image, documentation .. _working_with_the_repository: -Working with the Repository -=========================== +Working with Repositories +========================= Top-level repositories and user repositories -------------------------------------------- -Generally, there are two types of repositories: Top-level repositories which are controlled by the people behind -Docker, and user repositories. +Generally, there are two types of repositories: Top-level repositories +which are controlled by the people behind Docker, and user +repositories. -* Top-level repositories can easily be recognized by not having a ``/`` (slash) in their name. These repositories can - generally be trusted. +* Top-level repositories can easily be recognized by not having a ``/`` (slash) in their name. These repositories can generally be trusted. * User repositories always come in the form of ``/``. This is what your published images will look like. * User images are not checked, it is therefore up to you whether or not you trust the creator of this image. diff --git a/components/engine/network.go b/components/engine/network.go index 37037dd14a..dd79e60595 100644 --- a/components/engine/network.go +++ b/components/engine/network.go @@ -301,9 +301,9 @@ func newPortMapper() (*PortMapper, error) { // Port allocator: Atomatically allocate and release networking ports type PortAllocator struct { + sync.Mutex inUse map[int]struct{} fountain chan (int) - lock sync.Mutex } func (alloc *PortAllocator) runFountain() { @@ -317,9 +317,9 @@ func (alloc *PortAllocator) runFountain() { // FIXME: Release can no longer fail, change its prototype to reflect that. func (alloc *PortAllocator) Release(port int) error { utils.Debugf("Releasing %d", port) - alloc.lock.Lock() + alloc.Lock() delete(alloc.inUse, port) - alloc.lock.Unlock() + alloc.Unlock() return nil } @@ -334,8 +334,8 @@ func (alloc *PortAllocator) Acquire(port int) (int, error) { } return -1, fmt.Errorf("Port generator ended unexpectedly") } - alloc.lock.Lock() - defer alloc.lock.Unlock() + alloc.Lock() + defer alloc.Unlock() if _, inUse := alloc.inUse[port]; inUse { return -1, fmt.Errorf("Port already in use: %d", port) } diff --git a/components/engine/packaging/ubuntu/lxc-docker.prerm b/components/engine/packaging/ubuntu/lxc-docker.prerm index 824f15cff0..aed7d97eea 100644 --- a/components/engine/packaging/ubuntu/lxc-docker.prerm +++ b/components/engine/packaging/ubuntu/lxc-docker.prerm @@ -1,4 +1,4 @@ #!/bin/sh # Stop docker -/sbin/stop docker +if [ "`pgrep -f '/usr/bin/docker -d'`" != "" ]; then /sbin/stop docker; fi diff --git a/components/engine/registry/registry.go b/components/engine/registry/registry.go index 622c09b3f3..c458f616f8 100644 --- a/components/engine/registry/registry.go +++ b/components/engine/registry/registry.go @@ -12,18 +12,74 @@ import ( "net/http" "net/http/cookiejar" "net/url" + "regexp" "strconv" "strings" ) var ErrAlreadyExists = errors.New("Image already exists") -func UrlScheme() string { - u, err := url.Parse(auth.IndexServerAddress()) +func pingRegistryEndpoint(endpoint string) error { + resp, err := http.Get(endpoint + "_ping") if err != nil { - return "https" + return err } - return u.Scheme + if resp.Header.Get("X-Docker-Registry-Version") == "" { + return errors.New("This does not look like a Registry server (\"X-Docker-Registry-Version\" header not found in the response)") + } + return nil +} + +func validateRepositoryName(repositoryName string) error { + var ( + namespace string + name string + ) + nameParts := strings.SplitN(repositoryName, "/", 2) + if len(nameParts) < 2 { + namespace = "library" + name = nameParts[0] + } else { + namespace = nameParts[0] + name = nameParts[1] + } + validNamespace := regexp.MustCompile(`^([a-z0-9_]{4,30})$`) + if !validNamespace.MatchString(namespace) { + return fmt.Errorf("Invalid namespace name (%s), only [a-z0-9_] are allowed, size between 4 and 30", namespace) + } + validRepo := regexp.MustCompile(`^([a-zA-Z0-9-_.]+)$`) + if !validRepo.MatchString(name) { + return fmt.Errorf("Invalid repository name (%s), only [a-zA-Z0-9-_.] are allowed", name) + } + return nil +} + +// Resolves a repository name to a endpoint + name +func ResolveRepositoryName(reposName string) (string, string, error) { + nameParts := strings.SplitN(reposName, "/", 2) + if !strings.Contains(nameParts[0], ".") { + // This is a Docker Index repos (ex: samalba/hipache or ubuntu) + err := validateRepositoryName(reposName) + return "https://index.docker.io/v1/", reposName, err + } + if len(nameParts) < 2 { + // There is a dot in repos name (and no registry address) + // Is it a Registry address without repos name? + return "", "", fmt.Errorf("Invalid repository name (ex: \"registry.domain.tld/myrepos\")") + } + hostname := nameParts[0] + reposName = nameParts[1] + endpoint := fmt.Sprintf("https://%s/v1/", hostname) + if err := pingRegistryEndpoint(endpoint); err != nil { + utils.Debugf("Registry %s does not work (%s), falling back to http", endpoint, err) + endpoint = fmt.Sprintf("http://%s/v1/", hostname) + if err = pingRegistryEndpoint(endpoint); err != nil { + //TODO: triggering highland build can be done there without "failing" + return "", "", errors.New("Invalid Registry endpoint: " + err.Error()) + } + } + err := validateRepositoryName(reposName) + return endpoint, reposName, err } func doWithCookies(c *http.Client, req *http.Request) (*http.Response, error) { @@ -35,8 +91,8 @@ func doWithCookies(c *http.Client, req *http.Request) (*http.Response, error) { // Retrieve the history of a given image from the Registry. // Return a list of the parent's json (requested image included) -func (r *Registry) GetRemoteHistory(imgId, registry string, token []string) ([]string, error) { - req, err := http.NewRequest("GET", registry+"/images/"+imgId+"/ancestry", nil) +func (r *Registry) GetRemoteHistory(imgID, registry string, token []string) ([]string, error) { + req, err := http.NewRequest("GET", registry+"images/"+imgID+"/ancestry", nil) if err != nil { return nil, err } @@ -44,7 +100,7 @@ func (r *Registry) GetRemoteHistory(imgId, registry string, token []string) ([]s res, err := r.client.Do(req) if err != nil || res.StatusCode != 200 { if res != nil { - return nil, fmt.Errorf("Internal server error: %d trying to fetch remote history for %s", res.StatusCode, imgId) + return nil, fmt.Errorf("Internal server error: %d trying to fetch remote history for %s", res.StatusCode, imgID) } return nil, err } @@ -64,10 +120,10 @@ func (r *Registry) GetRemoteHistory(imgId, registry string, token []string) ([]s } // Check if an image exists in the Registry -func (r *Registry) LookupRemoteImage(imgId, registry string, token []string) bool { +func (r *Registry) LookupRemoteImage(imgID, registry string, token []string) bool { rt := &http.Transport{Proxy: http.ProxyFromEnvironment} - req, err := http.NewRequest("GET", registry+"/images/"+imgId+"/json", nil) + req, err := http.NewRequest("GET", registry+"images/"+imgID+"/json", nil) if err != nil { return false } @@ -79,44 +135,10 @@ func (r *Registry) LookupRemoteImage(imgId, registry string, token []string) boo return res.StatusCode == 200 } -func (r *Registry) getImagesInRepository(repository string, authConfig *auth.AuthConfig) ([]map[string]string, error) { - u := auth.IndexServerAddress() + "/repositories/" + repository + "/images" - req, err := http.NewRequest("GET", u, nil) - if err != nil { - return nil, err - } - if authConfig != nil && len(authConfig.Username) > 0 { - req.SetBasicAuth(authConfig.Username, authConfig.Password) - } - res, err := r.client.Do(req) - if err != nil { - return nil, err - } - defer res.Body.Close() - - // Repository doesn't exist yet - if res.StatusCode == 404 { - return nil, nil - } - - jsonData, err := ioutil.ReadAll(res.Body) - if err != nil { - return nil, err - } - - imageList := []map[string]string{} - if err := json.Unmarshal(jsonData, &imageList); err != nil { - utils.Debugf("Body: %s (%s)\n", res.Body, u) - return nil, err - } - - return imageList, nil -} - // Retrieve an image from the Registry. -func (r *Registry) GetRemoteImageJSON(imgId, registry string, token []string) ([]byte, int, error) { +func (r *Registry) GetRemoteImageJSON(imgID, registry string, token []string) ([]byte, int, error) { // Get the JSON - req, err := http.NewRequest("GET", registry+"/images/"+imgId+"/json", nil) + req, err := http.NewRequest("GET", registry+"images/"+imgID+"/json", nil) if err != nil { return nil, -1, fmt.Errorf("Failed to download json: %s", err) } @@ -142,8 +164,8 @@ func (r *Registry) GetRemoteImageJSON(imgId, registry string, token []string) ([ return jsonString, imageSize, nil } -func (r *Registry) GetRemoteImageLayer(imgId, registry string, token []string) (io.ReadCloser, error) { - req, err := http.NewRequest("GET", registry+"/images/"+imgId+"/layer", nil) +func (r *Registry) GetRemoteImageLayer(imgID, registry string, token []string) (io.ReadCloser, error) { + req, err := http.NewRequest("GET", registry+"images/"+imgID+"/layer", nil) if err != nil { return nil, fmt.Errorf("Error while getting from the server: %s\n", err) } @@ -162,10 +184,7 @@ func (r *Registry) GetRemoteTags(registries []string, repository string, token [ repository = "library/" + repository } for _, host := range registries { - endpoint := fmt.Sprintf("%s/v1/repositories/%s/tags", host, repository) - if !(strings.HasPrefix(endpoint, "http://") || strings.HasPrefix(endpoint, "https://")) { - endpoint = fmt.Sprintf("%s://%s", UrlScheme(), endpoint) - } + endpoint := fmt.Sprintf("%srepositories/%s/tags", host, repository) req, err := r.opaqueRequest("GET", endpoint, nil) if err != nil { return nil, err @@ -198,8 +217,8 @@ func (r *Registry) GetRemoteTags(registries []string, repository string, token [ return nil, fmt.Errorf("Could not reach any registry endpoint") } -func (r *Registry) GetRepositoryData(remote string) (*RepositoryData, error) { - repositoryTarget := auth.IndexServerAddress() + "/repositories/" + remote + "/images" +func (r *Registry) GetRepositoryData(indexEp, remote string) (*RepositoryData, error) { + repositoryTarget := fmt.Sprintf("%srepositories/%s/images", indexEp, remote) req, err := r.opaqueRequest("GET", repositoryTarget, nil) if err != nil { @@ -230,8 +249,12 @@ func (r *Registry) GetRepositoryData(remote string) (*RepositoryData, error) { } var endpoints []string + var urlScheme = indexEp[:strings.Index(indexEp, ":")] if res.Header.Get("X-Docker-Endpoints") != "" { - endpoints = res.Header["X-Docker-Endpoints"] + // The Registry's URL scheme has to match the Index' + for _, ep := range res.Header["X-Docker-Endpoints"] { + endpoints = append(endpoints, fmt.Sprintf("%s://%s/v1/", urlScheme, ep)) + } } else { return nil, fmt.Errorf("Index response didn't contain any endpoints") } @@ -260,9 +283,8 @@ func (r *Registry) GetRepositoryData(remote string) (*RepositoryData, error) { // Push a local image to the registry func (r *Registry) PushImageJSONRegistry(imgData *ImgData, jsonRaw []byte, registry string, token []string) error { - registry = registry + "/v1" // FIXME: try json with UTF8 - req, err := http.NewRequest("PUT", registry+"/images/"+imgData.ID+"/json", strings.NewReader(string(jsonRaw))) + req, err := http.NewRequest("PUT", registry+"images/"+imgData.ID+"/json", strings.NewReader(string(jsonRaw))) if err != nil { return err } @@ -295,9 +317,8 @@ func (r *Registry) PushImageJSONRegistry(imgData *ImgData, jsonRaw []byte, regis return nil } -func (r *Registry) PushImageLayerRegistry(imgId string, layer io.Reader, registry string, token []string) error { - registry = registry + "/v1" - req, err := http.NewRequest("PUT", registry+"/images/"+imgId+"/layer", layer) +func (r *Registry) PushImageLayerRegistry(imgID string, layer io.Reader, registry string, token []string) error { + req, err := http.NewRequest("PUT", registry+"images/"+imgID+"/layer", layer) if err != nil { return err } @@ -334,9 +355,8 @@ func (r *Registry) opaqueRequest(method, urlStr string, body io.Reader) (*http.R func (r *Registry) PushRegistryTag(remote, revision, tag, registry string, token []string) error { // "jsonify" the string revision = "\"" + revision + "\"" - registry = registry + "/v1" - req, err := r.opaqueRequest("PUT", registry+"/repositories/"+remote+"/tags/"+tag, strings.NewReader(revision)) + req, err := r.opaqueRequest("PUT", registry+"repositories/"+remote+"/tags/"+tag, strings.NewReader(revision)) if err != nil { return err } @@ -354,7 +374,7 @@ func (r *Registry) PushRegistryTag(remote, revision, tag, registry string, token return nil } -func (r *Registry) PushImageJSONIndex(remote string, imgList []*ImgData, validate bool, regs []string) (*RepositoryData, error) { +func (r *Registry) PushImageJSONIndex(indexEp, remote string, imgList []*ImgData, validate bool, regs []string) (*RepositoryData, error) { imgListJSON, err := json.Marshal(imgList) if err != nil { return nil, err @@ -364,9 +384,10 @@ func (r *Registry) PushImageJSONIndex(remote string, imgList []*ImgData, validat suffix = "images" } + u := fmt.Sprintf("%srepositories/%s/%s", indexEp, remote, suffix) + utils.Debugf("PUT %s", u) utils.Debugf("Image list pushed to index:\n%s\n", imgListJSON) - - req, err := r.opaqueRequest("PUT", auth.IndexServerAddress()+"/repositories/"+remote+"/"+suffix, bytes.NewReader(imgListJSON)) + req, err := r.opaqueRequest("PUT", u, bytes.NewReader(imgListJSON)) if err != nil { return nil, err } @@ -404,6 +425,7 @@ func (r *Registry) PushImageJSONIndex(remote string, imgList []*ImgData, validat } var tokens, endpoints []string + var urlScheme = indexEp[:strings.Index(indexEp, ":")] if !validate { if res.StatusCode != 200 && res.StatusCode != 201 { errBody, err := ioutil.ReadAll(res.Body) @@ -420,7 +442,10 @@ func (r *Registry) PushImageJSONIndex(remote string, imgList []*ImgData, validat } if res.Header.Get("X-Docker-Endpoints") != "" { - endpoints = res.Header["X-Docker-Endpoints"] + // The Registry's URL scheme has to match the Index' + for _, ep := range res.Header["X-Docker-Endpoints"] { + endpoints = append(endpoints, fmt.Sprintf("%s://%s/v1/", urlScheme, ep)) + } } else { return nil, fmt.Errorf("Index response didn't contain any endpoints") } @@ -442,7 +467,7 @@ func (r *Registry) PushImageJSONIndex(remote string, imgList []*ImgData, validat } func (r *Registry) SearchRepositories(term string) (*SearchResults, error) { - u := auth.IndexServerAddress() + "/search?q=" + url.QueryEscape(term) + u := auth.IndexServerAddress() + "search?q=" + url.QueryEscape(term) req, err := http.NewRequest("GET", u, nil) if err != nil { return nil, err diff --git a/components/engine/runtime.go b/components/engine/runtime.go index d283540abb..a3abbc3b50 100644 --- a/components/engine/runtime.go +++ b/components/engine/runtime.go @@ -108,9 +108,6 @@ func (runtime *Runtime) Register(container *Container) error { // init the wait lock container.waitLock = make(chan struct{}) - // Even if not running, we init the lock (prevents races in start/stop/kill) - container.State.initLock() - container.runtime = runtime // Attach to stdout and stderr diff --git a/components/engine/runtime_test.go b/components/engine/runtime_test.go index c367ecd4c5..d003426f25 100644 --- a/components/engine/runtime_test.go +++ b/components/engine/runtime_test.go @@ -18,7 +18,7 @@ import ( const ( unitTestImageName = "docker-unit-tests" - unitTestImageId = "e9aa60c60128cad1" + unitTestImageID = "e9aa60c60128cad1" unitTestStoreBase = "/var/lib/docker/unit-tests" testDaemonAddr = "127.0.0.1:4270" testDaemonProto = "tcp" @@ -49,7 +49,7 @@ func cleanup(runtime *Runtime) error { return err } for _, image := range images { - if image.ID != unitTestImageId { + if image.ID != unitTestImageID { runtime.graph.Delete(image.ID) } } @@ -73,7 +73,7 @@ func init() { } if uid := syscall.Geteuid(); uid != 0 { - log.Fatal("docker tests needs to be run as root") + log.Fatal("docker tests need to be run as root") } NetworkBridgeIface = "testdockbr0" @@ -89,12 +89,11 @@ func init() { srv := &Server{ runtime: runtime, enableCors: false, - lock: &sync.Mutex{}, pullingPool: make(map[string]struct{}), pushingPool: make(map[string]struct{}), } // Retrieve the Image - if err := srv.ImagePull(unitTestImageName, "", "", os.Stdout, utils.NewStreamFormatter(false), nil); err != nil { + if err := srv.ImagePull(unitTestImageName, "", os.Stdout, utils.NewStreamFormatter(false), nil); err != nil { panic(err) } // Spawn a Daemon @@ -136,11 +135,11 @@ func GetTestImage(runtime *Runtime) *Image { panic(err) } for i := range imgs { - if imgs[i].ID == unitTestImageId { + if imgs[i].ID == unitTestImageID { return imgs[i] } } - panic(fmt.Errorf("Test image %v not found", unitTestImageId)) + panic(fmt.Errorf("Test image %v not found", unitTestImageID)) } func TestRuntimeCreate(t *testing.T) { diff --git a/components/engine/server.go b/components/engine/server.go index 78915585af..938c74f452 100644 --- a/components/engine/server.go +++ b/components/engine/server.go @@ -29,7 +29,7 @@ func (srv *Server) DockerVersion() APIVersion { func (srv *Server) ContainerKill(name string) error { if container := srv.runtime.Get(name); container != nil { if err := container.Kill(); err != nil { - return fmt.Errorf("Error restarting container %s: %s", name, err.Error()) + return fmt.Errorf("Error restarting container %s: %s", name, err) } } else { return fmt.Errorf("No such container: %s", name) @@ -315,8 +315,8 @@ func (srv *Server) ContainerTag(name, repo, tag string, force bool) error { return nil } -func (srv *Server) pullImage(r *registry.Registry, out io.Writer, imgId, endpoint string, token []string, sf *utils.StreamFormatter) error { - history, err := r.GetRemoteHistory(imgId, endpoint, token) +func (srv *Server) pullImage(r *registry.Registry, out io.Writer, imgID, endpoint string, token []string, sf *utils.StreamFormatter) error { + history, err := r.GetRemoteHistory(imgID, endpoint, token) if err != nil { return err } @@ -351,44 +351,32 @@ func (srv *Server) pullImage(r *registry.Registry, out io.Writer, imgId, endpoin return nil } -func (srv *Server) pullRepository(r *registry.Registry, out io.Writer, local, remote, askedTag, registryEp string, sf *utils.StreamFormatter) error { - out.Write(sf.FormatStatus("Pulling repository %s from %s", local, auth.IndexServerAddress())) +func (srv *Server) pullRepository(r *registry.Registry, out io.Writer, name, askedTag, indexEp string, sf *utils.StreamFormatter) error { + out.Write(sf.FormatStatus("Pulling repository %s from %s", name, indexEp)) - var repoData *registry.RepositoryData - var err error - if registryEp == "" { - repoData, err = r.GetRepositoryData(remote) - if err != nil { - return err - } + repoData, err := r.GetRepositoryData(indexEp, name) + if err != nil { + return err + } - utils.Debugf("Updating checksums") - // Reload the json file to make sure not to overwrite faster sums - if err := srv.runtime.graph.UpdateChecksums(repoData.ImgList); err != nil { - return err - } - } else { - repoData = ®istry.RepositoryData{ - Tokens: []string{}, - ImgList: make(map[string]*registry.ImgData), - Endpoints: []string{registryEp}, - } + utils.Debugf("Updating checksums") + // Reload the json file to make sure not to overwrite faster sums + if err := srv.runtime.graph.UpdateChecksums(repoData.ImgList); err != nil { + return err } utils.Debugf("Retrieving the tag list") - tagsList, err := r.GetRemoteTags(repoData.Endpoints, remote, repoData.Tokens) + tagsList, err := r.GetRemoteTags(repoData.Endpoints, name, repoData.Tokens) if err != nil { utils.Debugf("%v", err) return err } - if registryEp != "" { - for tag, id := range tagsList { - repoData.ImgList[id] = ®istry.ImgData{ - ID: id, - Tag: tag, - Checksum: "", - } + for tag, id := range tagsList { + repoData.ImgList[id] = ®istry.ImgData{ + ID: id, + Tag: tag, + Checksum: "", } } @@ -402,7 +390,7 @@ func (srv *Server) pullRepository(r *registry.Registry, out io.Writer, local, re // Otherwise, check that the tag exists and use only that one id, exists := tagsList[askedTag] if !exists { - return fmt.Errorf("Tag %s not found in repositoy %s", askedTag, local) + return fmt.Errorf("Tag %s not found in repository %s", askedTag, name) } repoData.ImgList[id].Tag = askedTag } @@ -412,13 +400,15 @@ func (srv *Server) pullRepository(r *registry.Registry, out io.Writer, local, re utils.Debugf("(%s) does not match %s (id: %s), skipping", img.Tag, askedTag, img.ID) continue } - out.Write(sf.FormatStatus("Pulling image %s (%s) from %s", img.ID, img.Tag, remote)) + + if img.Tag == "" { + utils.Debugf("Image (id: %s) present in this repository but untagged, skipping", img.ID) + continue + } + out.Write(sf.FormatStatus("Pulling image %s (%s) from %s", img.ID, img.Tag, name)) success := false for _, ep := range repoData.Endpoints { - if !(strings.HasPrefix(ep, "http://") || strings.HasPrefix(ep, "https://")) { - ep = fmt.Sprintf("%s://%s", registry.UrlScheme(), ep) - } - if err := srv.pullImage(r, out, img.ID, ep+"/v1", repoData.Tokens, sf); err != nil { + if err := srv.pullImage(r, out, img.ID, ep, repoData.Tokens, sf); err != nil { out.Write(sf.FormatStatus("Error while retrieving image for tag: %s (%s); checking next endpoint", askedTag, err)) continue } @@ -433,7 +423,7 @@ func (srv *Server) pullRepository(r *registry.Registry, out io.Writer, local, re if askedTag != "" && tag != askedTag { continue } - if err := srv.runtime.repositories.Set(local, tag, id, true); err != nil { + if err := srv.runtime.repositories.Set(name, tag, id, true); err != nil { return err } } @@ -445,8 +435,8 @@ func (srv *Server) pullRepository(r *registry.Registry, out io.Writer, local, re } func (srv *Server) poolAdd(kind, key string) error { - srv.lock.Lock() - defer srv.lock.Unlock() + srv.Lock() + defer srv.Unlock() if _, exists := srv.pullingPool[key]; exists { return fmt.Errorf("%s %s is already in progress", key, kind) @@ -478,7 +468,8 @@ func (srv *Server) poolRemove(kind, key string) error { } return nil } -func (srv *Server) ImagePull(name, tag, endpoint string, out io.Writer, sf *utils.StreamFormatter, authConfig *auth.AuthConfig) error { + +func (srv *Server) ImagePull(name string, tag string, out io.Writer, sf *utils.StreamFormatter, authConfig *auth.AuthConfig) error { r, err := registry.NewRegistry(srv.runtime.root, authConfig) if err != nil { return err @@ -488,14 +479,16 @@ func (srv *Server) ImagePull(name, tag, endpoint string, out io.Writer, sf *util } defer srv.poolRemove("pull", name+":"+tag) - remote := name - parts := strings.Split(name, "/") - if len(parts) > 2 { - remote = fmt.Sprintf("src/%s", url.QueryEscape(strings.Join(parts, "/"))) + // Resolve the Repository name from fqn to endpoint + name + var endpoint string + endpoint, name, err = registry.ResolveRepositoryName(name) + if err != nil { + return err } + out = utils.NewWriteFlusher(out) - err = srv.pullRepository(r, out, name, remote, tag, endpoint, sf) - if err != nil && endpoint != "" { + err = srv.pullRepository(r, out, name, tag, endpoint, sf) + if err != nil { if err := srv.pullImage(r, out, name, endpoint, nil, sf); err != nil { return err } @@ -511,20 +504,20 @@ func (srv *Server) ImagePull(name, tag, endpoint string, out io.Writer, sf *util // - Check if the archive exists, if it does not, ask the registry // - If the archive does exists, process the checksum from it // - If the archive does not exists and not found on registry, process checksum from layer -func (srv *Server) getChecksum(imageId string) (string, error) { +func (srv *Server) getChecksum(imageID string) (string, error) { // FIXME: Use in-memory map instead of reading the file each time if sums, err := srv.runtime.graph.getStoredChecksums(); err != nil { return "", err - } else if checksum, exists := sums[imageId]; exists { + } else if checksum, exists := sums[imageID]; exists { return checksum, nil } - img, err := srv.runtime.graph.Get(imageId) + img, err := srv.runtime.graph.Get(imageID) if err != nil { return "", err } - if _, err := os.Stat(layerArchivePath(srv.runtime.graph.imageRoot(imageId))); err != nil { + if _, err := os.Stat(layerArchivePath(srv.runtime.graph.imageRoot(imageID))); err != nil { if os.IsNotExist(err) { // TODO: Ask the registry for the checksum // As the archive is not there, it is supposed to come from a pull. @@ -571,7 +564,7 @@ func (srv *Server) getImageList(localRepo map[string]string) ([]*registry.ImgDat return imgList, nil } -func (srv *Server) pushRepository(r *registry.Registry, out io.Writer, name, registryEp string, localRepo map[string]string, sf *utils.StreamFormatter) error { +func (srv *Server) pushRepository(r *registry.Registry, out io.Writer, name string, localRepo map[string]string, indexEp string, sf *utils.StreamFormatter) error { out = utils.NewWriteFlusher(out) out.Write(sf.FormatStatus("Processing checksums")) imgList, err := srv.getImageList(localRepo) @@ -586,42 +579,19 @@ func (srv *Server) pushRepository(r *registry.Registry, out io.Writer, name, reg } var repoData *registry.RepositoryData - if registryEp == "" { - repoData, err = r.PushImageJSONIndex(name, imgList, false, nil) - if err != nil { - return err - } - } else { - repoData = ®istry.RepositoryData{ - ImgList: make(map[string]*registry.ImgData), - Tokens: []string{}, - Endpoints: []string{registryEp}, - } - tagsList, err := r.GetRemoteTags(repoData.Endpoints, name, repoData.Tokens) - if err != nil && err.Error() != "Repository not found" { - return err - } else if err == nil { - for tag, id := range tagsList { - repoData.ImgList[id] = ®istry.ImgData{ - ID: id, - Tag: tag, - Checksum: "", - } - } - } + repoData, err = r.PushImageJSONIndex(indexEp, name, imgList, false, nil) + if err != nil { + return err } for _, ep := range repoData.Endpoints { - if !(strings.HasPrefix(ep, "http://") || strings.HasPrefix(ep, "https://")) { - ep = fmt.Sprintf("%s://%s", registry.UrlScheme(), ep) - } out.Write(sf.FormatStatus("Pushing repository %s to %s (%d tags)", name, ep, len(localRepo))) // For each image within the repo, push them for _, elem := range imgList { if _, exists := repoData.ImgList[elem.ID]; exists { out.Write(sf.FormatStatus("Image %s already on registry, skipping", name)) continue - } else if registryEp != "" && r.LookupRemoteImage(elem.ID, registryEp, repoData.Tokens) { + } else if r.LookupRemoteImage(elem.ID, ep, repoData.Tokens) { fmt.Fprintf(out, "Image %s already on registry, skipping\n", name) continue } @@ -629,37 +599,35 @@ func (srv *Server) pushRepository(r *registry.Registry, out io.Writer, name, reg // FIXME: Continue on error? return err } - out.Write(sf.FormatStatus("Pushing tags for rev [%s] on {%s}", elem.ID, ep+"/repositories/"+srvName+"/tags/"+elem.Tag)) + out.Write(sf.FormatStatus("Pushing tags for rev [%s] on {%s}", elem.ID, ep+"repositories/"+srvName+"/tags/"+elem.Tag)) if err := r.PushRegistryTag(srvName, elem.ID, elem.Tag, ep, repoData.Tokens); err != nil { return err } } } - if registryEp == "" { - if _, err := r.PushImageJSONIndex(name, imgList, true, repoData.Endpoints); err != nil { - return err - } + if _, err := r.PushImageJSONIndex(indexEp, name, imgList, true, repoData.Endpoints); err != nil { + return err } return nil } -func (srv *Server) pushImage(r *registry.Registry, out io.Writer, remote, imgId, ep string, token []string, sf *utils.StreamFormatter) error { +func (srv *Server) pushImage(r *registry.Registry, out io.Writer, remote, imgID, ep string, token []string, sf *utils.StreamFormatter) error { out = utils.NewWriteFlusher(out) - jsonRaw, err := ioutil.ReadFile(path.Join(srv.runtime.graph.Root, imgId, "json")) + jsonRaw, err := ioutil.ReadFile(path.Join(srv.runtime.graph.Root, imgID, "json")) if err != nil { - return fmt.Errorf("Error while retreiving the path for {%s}: %s", imgId, err) + return fmt.Errorf("Error while retreiving the path for {%s}: %s", imgID, err) } - out.Write(sf.FormatStatus("Pushing %s", imgId)) + out.Write(sf.FormatStatus("Pushing %s", imgID)) // Make sure we have the image's checksum - checksum, err := srv.getChecksum(imgId) + checksum, err := srv.getChecksum(imgID) if err != nil { return err } imgData := ®istry.ImgData{ - ID: imgId, + ID: imgID, Checksum: checksum, } @@ -675,11 +643,11 @@ func (srv *Server) pushImage(r *registry.Registry, out io.Writer, remote, imgId, // Retrieve the tarball to be sent var layerData *TempArchive // If the archive exists, use it - file, err := os.Open(layerArchivePath(srv.runtime.graph.imageRoot(imgId))) + file, err := os.Open(layerArchivePath(srv.runtime.graph.imageRoot(imgID))) if err != nil { if os.IsNotExist(err) { // If the archive does not exist, create one from the layer - layerData, err = srv.runtime.graph.TempLayerArchive(imgId, Xz, out) + layerData, err = srv.runtime.graph.TempLayerArchive(imgID, Xz, out) if err != nil { return fmt.Errorf("Failed to generate layer archive: %s", err) } @@ -706,12 +674,18 @@ func (srv *Server) pushImage(r *registry.Registry, out io.Writer, remote, imgId, } // FIXME: Allow to interupt current push when new push of same image is done. -func (srv *Server) ImagePush(name, endpoint string, out io.Writer, sf *utils.StreamFormatter, authConfig *auth.AuthConfig) error { +func (srv *Server) ImagePush(name string, out io.Writer, sf *utils.StreamFormatter, authConfig *auth.AuthConfig) error { if err := srv.poolAdd("push", name); err != nil { return err } defer srv.poolRemove("push", name) + // Resolve the Repository name from fqn to endpoint + name + endpoint, name, err := registry.ResolveRepositoryName(name) + if err != nil { + return err + } + out = utils.NewWriteFlusher(out) img, err := srv.runtime.graph.Get(name) r, err2 := registry.NewRegistry(srv.runtime.root, authConfig) @@ -723,16 +697,17 @@ func (srv *Server) ImagePush(name, endpoint string, out io.Writer, sf *utils.Str out.Write(sf.FormatStatus("The push refers to a repository [%s] (len: %d)", name, len(srv.runtime.repositories.Repositories[name]))) // If it fails, try to get the repository if localRepo, exists := srv.runtime.repositories.Repositories[name]; exists { - if err := srv.pushRepository(r, out, name, endpoint, localRepo, sf); err != nil { + if err := srv.pushRepository(r, out, name, localRepo, endpoint, sf); err != nil { return err } return nil } - return err } + + var token []string out.Write(sf.FormatStatus("The push refers to an image: [%s]", name)) - if err := srv.pushImage(r, out, name, img.ID, endpoint, nil, sf); err != nil { + if err := srv.pushImage(r, out, name, img.ID, endpoint, token, sf); err != nil { return err } return nil @@ -804,7 +779,7 @@ func (srv *Server) ContainerCreate(config *Config) (string, error) { func (srv *Server) ContainerRestart(name string, t int) error { if container := srv.runtime.Get(name); container != nil { if err := container.Restart(t); err != nil { - return fmt.Errorf("Error restarting container %s: %s", name, err.Error()) + return fmt.Errorf("Error restarting container %s: %s", name, err) } } else { return fmt.Errorf("No such container: %s", name) @@ -823,7 +798,7 @@ func (srv *Server) ContainerDestroy(name string, removeVolume bool) error { volumes[volumeId] = struct{}{} } if err := srv.runtime.Destroy(container); err != nil { - return fmt.Errorf("Error destroying container %s: %s", name, err.Error()) + return fmt.Errorf("Error destroying container %s: %s", name, err) } if removeVolume { @@ -914,7 +889,7 @@ func (srv *Server) deleteImageParents(img *Image, imgs *[]APIRmi) error { func (srv *Server) deleteImage(img *Image, repoName, tag string) ([]APIRmi, error) { //Untag the current image - var imgs []APIRmi + imgs := []APIRmi{} tagDeleted, err := srv.runtime.repositories.Delete(repoName, tag) if err != nil { return nil, err @@ -943,7 +918,7 @@ func (srv *Server) ImageDelete(name string, autoPrune bool) ([]APIRmi, error) { } if !autoPrune { if err := srv.runtime.graph.Delete(img.ID); err != nil { - return nil, fmt.Errorf("Error deleting image %s: %s", name, err.Error()) + return nil, fmt.Errorf("Error deleting image %s: %s", name, err) } return nil, nil } @@ -958,7 +933,7 @@ func (srv *Server) ImageDelete(name string, autoPrune bool) ([]APIRmi, error) { return srv.deleteImage(img, name, tag) } -func (srv *Server) ImageGetCached(imgId string, config *Config) (*Image, error) { +func (srv *Server) ImageGetCached(imgID string, config *Config) (*Image, error) { // Retrieve all images images, err := srv.runtime.graph.All() @@ -976,7 +951,7 @@ func (srv *Server) ImageGetCached(imgId string, config *Config) (*Image, error) } // Loop on the children of the given image and check the config - for elem := range imageMap[imgId] { + for elem := range imageMap[imgID] { img, err := srv.runtime.graph.Get(elem) if err != nil { return nil, err @@ -991,7 +966,7 @@ func (srv *Server) ImageGetCached(imgId string, config *Config) (*Image, error) func (srv *Server) ContainerStart(name string, hostConfig *HostConfig) error { if container := srv.runtime.Get(name); container != nil { if err := container.Start(hostConfig); err != nil { - return fmt.Errorf("Error starting container %s: %s", name, err.Error()) + return fmt.Errorf("Error starting container %s: %s", name, err) } } else { return fmt.Errorf("No such container: %s", name) @@ -1002,7 +977,7 @@ func (srv *Server) ContainerStart(name string, hostConfig *HostConfig) error { func (srv *Server) ContainerStop(name string, t int) error { if container := srv.runtime.Get(name); container != nil { if err := container.Stop(t); err != nil { - return fmt.Errorf("Error stopping container %s: %s", name, err.Error()) + return fmt.Errorf("Error stopping container %s: %s", name, err) } } else { return fmt.Errorf("No such container: %s", name) @@ -1114,7 +1089,6 @@ func NewServer(flGraphPath string, autoRestart, enableCors bool, dns ListOpts) ( srv := &Server{ runtime: runtime, enableCors: enableCors, - lock: &sync.Mutex{}, pullingPool: make(map[string]struct{}), pushingPool: make(map[string]struct{}), } @@ -1123,9 +1097,9 @@ func NewServer(flGraphPath string, autoRestart, enableCors bool, dns ListOpts) ( } type Server struct { + sync.Mutex runtime *Runtime enableCors bool - lock *sync.Mutex pullingPool map[string]struct{} pushingPool map[string]struct{} } diff --git a/components/engine/server_test.go b/components/engine/server_test.go index 254a4a0c90..cf3e3f0bc8 100644 --- a/components/engine/server_test.go +++ b/components/engine/server_test.go @@ -31,7 +31,7 @@ func TestContainerTagImageDelete(t *testing.T) { } if len(images) != len(initialImages)+2 { - t.Errorf("Excepted %d images, %d found", len(initialImages)+2, len(images)) + t.Errorf("Expected %d images, %d found", len(initialImages)+2, len(images)) } if _, err := srv.ImageDelete("utest/docker:tag2", true); err != nil { @@ -44,7 +44,7 @@ func TestContainerTagImageDelete(t *testing.T) { } if len(images) != len(initialImages)+1 { - t.Errorf("Excepted %d images, %d found", len(initialImages)+1, len(images)) + t.Errorf("Expected %d images, %d found", len(initialImages)+1, len(images)) } if _, err := srv.ImageDelete("utest:tag1", true); err != nil { @@ -57,7 +57,7 @@ func TestContainerTagImageDelete(t *testing.T) { } if len(images) != len(initialImages) { - t.Errorf("Excepted %d image, %d found", len(initialImages), len(images)) + t.Errorf("Expected %d image, %d found", len(initialImages), len(images)) } } diff --git a/components/engine/state.go b/components/engine/state.go index a972e376a2..117659bf5b 100644 --- a/components/engine/state.go +++ b/components/engine/state.go @@ -8,11 +8,11 @@ import ( ) type State struct { + sync.Mutex Running bool Pid int ExitCode int StartedAt time.Time - l *sync.Mutex Ghost bool } @@ -39,15 +39,3 @@ func (s *State) setStopped(exitCode int) { s.Pid = 0 s.ExitCode = exitCode } - -func (s *State) initLock() { - s.l = &sync.Mutex{} -} - -func (s *State) lock() { - s.l.Lock() -} - -func (s *State) unlock() { - s.l.Unlock() -} diff --git a/components/engine/sysinit.go b/components/engine/sysinit.go index 4b2d6c3032..622dbdf095 100644 --- a/components/engine/sysinit.go +++ b/components/engine/sysinit.go @@ -60,9 +60,6 @@ func cleanupEnv(env ListOpts) { if len(parts) == 1 { parts = append(parts, "") } - if parts[0] == "container" { - continue - } os.Setenv(parts[0], parts[1]) } } diff --git a/components/engine/tags.go b/components/engine/tags.go index 33ec4e149d..d1eb36aa72 100644 --- a/components/engine/tags.go +++ b/components/engine/tags.go @@ -197,7 +197,7 @@ func (store *TagStore) Get(repoName string) (Repository, error) { return nil, nil } -func (store *TagStore) GetImage(repoName, tagOrId string) (*Image, error) { +func (store *TagStore) GetImage(repoName, tagOrID string) (*Image, error) { repo, err := store.Get(repoName) if err != nil { return nil, err @@ -206,11 +206,11 @@ func (store *TagStore) GetImage(repoName, tagOrId string) (*Image, error) { } //go through all the tags, to see if tag is in fact an ID for _, revision := range repo { - if strings.HasPrefix(revision, tagOrId) { + if strings.HasPrefix(revision, tagOrID) { return store.graph.Get(revision) } } - if revision, exists := repo[tagOrId]; exists { + if revision, exists := repo[tagOrID]; exists { return store.graph.Get(revision) } return nil, nil diff --git a/components/engine/tags_test.go b/components/engine/tags_test.go index 90bc056406..1974e751be 100644 --- a/components/engine/tags_test.go +++ b/components/engine/tags_test.go @@ -35,13 +35,13 @@ func TestLookupImage(t *testing.T) { t.Errorf("Expected 0 image, 1 found") } - if img, err := runtime.repositories.LookupImage(unitTestImageId); err != nil { + if img, err := runtime.repositories.LookupImage(unitTestImageID); err != nil { t.Fatal(err) } else if img == nil { t.Errorf("Expected 1 image, none found") } - if img, err := runtime.repositories.LookupImage(unitTestImageName + ":" + unitTestImageId); err != nil { + if img, err := runtime.repositories.LookupImage(unitTestImageName + ":" + unitTestImageID); err != nil { t.Fatal(err) } else if img == nil { t.Errorf("Expected 1 image, none found") diff --git a/components/engine/testing/README.rst b/components/engine/testing/README.rst index 405adaed94..3b11092f9f 100644 --- a/components/engine/testing/README.rst +++ b/components/engine/testing/README.rst @@ -30,6 +30,16 @@ Deployment export AWS_KEYPAIR_NAME=xxxxxxxxxxxx export AWS_SSH_PRIVKEY=xxxxxxxxxxxx + # Define email recipient and IRC channel + export EMAIL_RCP=xxxxxx@domain.com + export IRC_CHANNEL=docker + + # Define buildbot credentials + export BUILDBOT_PWD=xxxxxxxxxxxx + export IRC_PWD=xxxxxxxxxxxx + export SMTP_USER=xxxxxxxxxxxx + export SMTP_PWD=xxxxxxxxxxxx + # Checkout docker git clone git://github.com/dotcloud/docker.git diff --git a/components/engine/testing/Vagrantfile b/components/engine/testing/Vagrantfile index e3b25a6f9d..47257201dc 100644 --- a/components/engine/testing/Vagrantfile +++ b/components/engine/testing/Vagrantfile @@ -27,7 +27,9 @@ Vagrant::Config.run do |config| pkg_cmd << "apt-get install -q -y python-dev python-pip supervisor; " \ "pip install -r #{CFG_PATH}/requirements.txt; " \ "chown #{USER}.#{USER} /data; cd /data; " \ - "#{CFG_PATH}/setup.sh #{USER} #{CFG_PATH}; " + "#{CFG_PATH}/setup.sh #{USER} #{CFG_PATH} #{ENV['BUILDBOT_PWD']} " \ + "#{ENV['IRC_PWD']} #{ENV['IRC_CHANNEL']} #{ENV['SMTP_USER']} " \ + "#{ENV['SMTP_PWD']} #{ENV['EMAIL_RCP']}; " # Install docker dependencies pkg_cmd << "apt-get install -q -y python-software-properties; " \ "add-apt-repository -y ppa:dotcloud/docker-golang/ubuntu; apt-get update -qq; " \ diff --git a/components/engine/testing/buildbot/master.cfg b/components/engine/testing/buildbot/master.cfg index 48df5835f7..65399bb1a1 100644 --- a/components/engine/testing/buildbot/master.cfg +++ b/components/engine/testing/buildbot/master.cfg @@ -5,9 +5,11 @@ from buildbot.schedulers.basic import SingleBranchScheduler from buildbot.changes import filter from buildbot.config import BuilderConfig from buildbot.process.factory import BuildFactory +from buildbot.process.properties import Interpolate from buildbot.steps.shell import ShellCommand -from buildbot.status import html +from buildbot.status import html, words from buildbot.status.web import authz, auth +from buildbot.status.mail import MailNotifier PORT_WEB = 80 # Buildbot webserver port PORT_GITHUB = 8011 # Buildbot github hook port @@ -15,20 +17,27 @@ PORT_MASTER = 9989 # Port where buildbot master listen buildworkers TEST_USER = 'buildbot' # Credential to authenticate build triggers TEST_PWD = 'docker' # Credential to authenticate build triggers BUILDER_NAME = 'docker' -BUILDPASSWORD = 'pass-docker' # Credential to authenticate buildworkers -GITHUB_DOCKER = "github.com/dotcloud/docker" -DOCKER_PATH = "/data/docker" -BUILDER_PATH = "/data/buildbot/slave/{0}/build".format(BUILDER_NAME) +GITHUB_DOCKER = 'github.com/dotcloud/docker' +DOCKER_PATH = '/data/docker' +BUILDER_PATH = '/data/buildbot/slave/{0}/build'.format(BUILDER_NAME) DOCKER_BUILD_PATH = BUILDER_PATH + '/src/github.com/dotcloud/docker' +# Credentials set by setup.sh and Vagrantfile +BUILDBOT_PWD = '' +IRC_PWD = '' +IRC_CHANNEL = '' +SMTP_USER = '' +SMTP_PWD = '' +EMAIL_RCP = '' + c = BuildmasterConfig = {} c['title'] = "Docker" c['titleURL'] = "waterfall" -c['buildbotURL'] = "http://0.0.0.0:{0}/".format(PORT_WEB) +c['buildbotURL'] = "http://docker-ci.dotcloud.com/" c['db'] = {'db_url':"sqlite:///state.sqlite"} -c['slaves'] = [BuildSlave('buildworker', BUILDPASSWORD)] +c['slaves'] = [BuildSlave('buildworker', BUILDBOT_PWD)] c['slavePortnum'] = PORT_MASTER c['schedulers'] = [ForceScheduler(name='trigger',builderNames=[BUILDER_NAME])] @@ -36,20 +45,25 @@ c['schedulers'].append(SingleBranchScheduler(name="all", change_filter=filter.ChangeFilter(branch='master'),treeStableTimer=None, builderNames=[BUILDER_NAME])) -# Docker test command -test_cmd = ("cd /tmp; rm -rf {0}; export GOPATH={0}; go get -d {1}; cd {2}; " - "go test").format(BUILDER_PATH,GITHUB_DOCKER,DOCKER_BUILD_PATH) - # Builder factory = BuildFactory() -factory.addStep(ShellCommand(description='Docker',logEnviron=False, - usePTY=True,command=test_cmd)) +factory.addStep(ShellCommand(description='Docker',logEnviron=False,usePTY=True, + command=["sh", "-c", Interpolate("cd ..; rm -rf build; export GOPATH={0}; " + "go get -d {1}; cd {2}; git reset --hard %(src::revision:-unknown)s; " + "go test -v".format(BUILDER_PATH,GITHUB_DOCKER,DOCKER_BUILD_PATH))])) c['builders'] = [BuilderConfig(name=BUILDER_NAME,slavenames=['buildworker'], factory=factory)] # Status -authz_cfg=authz.Authz(auth=auth.BasicAuth([(TEST_USER,TEST_PWD)]), +authz_cfg = authz.Authz(auth=auth.BasicAuth([(TEST_USER, TEST_PWD)]), forceBuild='auth') c['status'] = [html.WebStatus(http_port=PORT_WEB, authz=authz_cfg)] -c['status'].append(html.WebStatus(http_port=PORT_GITHUB,allowForce=True, - change_hook_dialects={ 'github' : True })) +c['status'].append(html.WebStatus(http_port=PORT_GITHUB, allowForce=True, + change_hook_dialects={ 'github': True })) +c['status'].append(MailNotifier(fromaddr='buildbot@docker.io', + sendToInterestedUsers=False, extraRecipients=[EMAIL_RCP], + mode='failing', relayhost='smtp.mailgun.org', smtpPort=587, useTls=True, + smtpUser=SMTP_USER, smtpPassword=SMTP_PWD)) +c['status'].append(words.IRC("irc.freenode.net", "dockerqabot", + channels=[IRC_CHANNEL], password=IRC_PWD, allowForce=True, + notify_events={'exception':1, 'successToFailure':1, 'failureToSuccess':1})) diff --git a/components/engine/testing/buildbot/setup.sh b/components/engine/testing/buildbot/setup.sh index 828ac3ebe5..937533ba1f 100755 --- a/components/engine/testing/buildbot/setup.sh +++ b/components/engine/testing/buildbot/setup.sh @@ -6,11 +6,16 @@ USER=$1 CFG_PATH=$2 +BUILDBOT_PWD=$3 +IRC_PWD=$4 +IRC_CHANNEL=$5 +SMTP_USER=$6 +SMTP_PWD=$7 +EMAIL_RCP=$8 BUILDBOT_PATH="/data/buildbot" DOCKER_PATH="/data/docker" SLAVE_NAME="buildworker" SLAVE_SOCKET="localhost:9989" -BUILDBOT_PWD="pass-docker" export PATH="/bin:sbin:/usr/bin:/usr/sbin:/usr/local/bin" function run { su $USER -c "$1"; } @@ -23,7 +28,12 @@ run "mkdir -p $BUILDBOT_PATH" cd $BUILDBOT_PATH run "buildbot create-master master" run "cp $CFG_PATH/master.cfg master" -run "sed -i -E 's#(DOCKER_PATH = ).+#\1\"$DOCKER_PATH\"#' master/master.cfg" +run "sed -i -E 's#(BUILDBOT_PWD = ).+#\1\"$BUILDBOT_PWD\"#' master/master.cfg" +run "sed -i -E 's#(IRC_PWD = ).+#\1\"$IRC_PWD\"#' master/master.cfg" +run "sed -i -E 's#(IRC_CHANNEL = ).+#\1\"$IRC_CHANNEL\"#' master/master.cfg" +run "sed -i -E 's#(SMTP_USER = ).+#\1\"$SMTP_USER\"#' master/master.cfg" +run "sed -i -E 's#(SMTP_PWD = ).+#\1\"$SMTP_PWD\"#' master/master.cfg" +run "sed -i -E 's#(EMAIL_RCP = ).+#\1\"$EMAIL_RCP\"#' master/master.cfg" run "buildslave create-slave slave $SLAVE_SOCKET $SLAVE_NAME $BUILDBOT_PWD" # Allow buildbot subprocesses (docker tests) to properly run in containers, diff --git a/components/engine/utils.go b/components/engine/utils.go index 22613e9f49..103e762822 100644 --- a/components/engine/utils.go +++ b/components/engine/utils.go @@ -53,9 +53,6 @@ func CompareConfig(a, b *Config) bool { } func MergeConfig(userConf, imageConf *Config) { - if userConf.Hostname == "" { - userConf.Hostname = imageConf.Hostname - } if userConf.User == "" { userConf.User = imageConf.User } diff --git a/components/engine/utils/utils.go b/components/engine/utils/utils.go index 2f2a52867e..eee6685c8b 100644 --- a/components/engine/utils/utils.go +++ b/components/engine/utils/utils.go @@ -170,10 +170,9 @@ func SelfPath() string { return path } -type NopWriter struct { -} +type NopWriter struct{} -func (w *NopWriter) Write(buf []byte) (int, error) { +func (*NopWriter) Write(buf []byte) (int, error) { return len(buf), nil } @@ -188,10 +187,10 @@ func NopWriteCloser(w io.Writer) io.WriteCloser { } type bufReader struct { + sync.Mutex buf *bytes.Buffer reader io.Reader err error - l sync.Mutex wait sync.Cond } @@ -200,7 +199,7 @@ func NewBufReader(r io.Reader) *bufReader { buf: &bytes.Buffer{}, reader: r, } - reader.wait.L = &reader.l + reader.wait.L = &reader.Mutex go reader.drain() return reader } @@ -209,14 +208,14 @@ func (r *bufReader) drain() { buf := make([]byte, 1024) for { n, err := r.reader.Read(buf) - r.l.Lock() + r.Lock() if err != nil { r.err = err } else { r.buf.Write(buf[0:n]) } r.wait.Signal() - r.l.Unlock() + r.Unlock() if err != nil { break } @@ -224,8 +223,8 @@ func (r *bufReader) drain() { } func (r *bufReader) Read(p []byte) (n int, err error) { - r.l.Lock() - defer r.l.Unlock() + r.Lock() + defer r.Unlock() for { n, err = r.buf.Read(p) if n > 0 { @@ -247,27 +246,27 @@ func (r *bufReader) Close() error { } type WriteBroadcaster struct { - mu sync.Mutex + sync.Mutex writers map[io.WriteCloser]struct{} } func (w *WriteBroadcaster) AddWriter(writer io.WriteCloser) { - w.mu.Lock() + w.Lock() w.writers[writer] = struct{}{} - w.mu.Unlock() + w.Unlock() } // FIXME: Is that function used? // FIXME: This relies on the concrete writer type used having equality operator func (w *WriteBroadcaster) RemoveWriter(writer io.WriteCloser) { - w.mu.Lock() + w.Lock() delete(w.writers, writer) - w.mu.Unlock() + w.Unlock() } func (w *WriteBroadcaster) Write(p []byte) (n int, err error) { - w.mu.Lock() - defer w.mu.Unlock() + w.Lock() + defer w.Unlock() for writer := range w.writers { if n, err := writer.Write(p); err != nil || n != len(p) { // On error, evict the writer @@ -278,8 +277,8 @@ func (w *WriteBroadcaster) Write(p []byte) (n int, err error) { } func (w *WriteBroadcaster) CloseWriters() error { - w.mu.Lock() - defer w.mu.Unlock() + w.Lock() + defer w.Unlock() for writer := range w.writers { writer.Close() }