diff --git a/.gitignore b/.gitignore index 15841891c..512e4f2cd 100644 --- a/.gitignore +++ b/.gitignore @@ -15,3 +15,4 @@ docs/_build docs/_static docs/_templates .gopath/ +.dotcloud diff --git a/api.go b/api.go index ff428885d..fad4e7937 100644 --- a/api.go +++ b/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") diff --git a/api_test.go b/api_test.go index 487394a54..f82782643 100644 --- a/api_test.go +++ b/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,7 +1356,7 @@ 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) @@ -1385,7 +1385,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/archive.go b/archive.go index 357fdd9a7..c9a650cb8 100644 --- a/archive.go +++ b/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/archive_test.go b/archive_test.go index bb4235ad5..9a0a8e1b9 100644 --- a/archive_test.go +++ b/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/auth/auth_test.go b/auth/auth_test.go index 8e7adaef8..d036de736 100644 --- a/auth/auth_test.go +++ b/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/buildfile_test.go b/buildfile_test.go index 8dc041062..b7cc7be8e 100644 --- a/buildfile_test.go +++ b/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/commands.go b/commands.go index b85a52a3d..35f41e13c 100644 --- a/commands.go +++ b/commands.go @@ -1548,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/commands_test.go b/commands_test.go index 87c4c02a5..31cd014e3 100644 --- a/commands_test.go +++ b/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/container.go b/container.go index 508f39c0e..52a0517af 100644 --- a/container.go +++ b/container.go @@ -466,8 +466,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 container.State.Running { return fmt.Errorf("The container %s is already running.", container.ID) @@ -494,7 +494,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 @@ -513,7 +513,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) } @@ -821,8 +821,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 } @@ -830,8 +830,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/docker/docker.go b/docker/docker.go index c508d8905..fb7c46536 100644 --- a/docker/docker.go +++ b/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/docs/sources/concepts/images/dockerlogo-h.png b/docs/sources/concepts/images/dockerlogo-h.png new file mode 100644 index 000000000..d0e37e548 Binary files /dev/null and b/docs/sources/concepts/images/dockerlogo-h.png differ diff --git a/docs/sources/concepts/images/dockerlogo-v.png b/docs/sources/concepts/images/dockerlogo-v.png new file mode 100644 index 000000000..591e770d2 Binary files /dev/null and b/docs/sources/concepts/images/dockerlogo-v.png differ diff --git a/docs/sources/concepts/index.rst b/docs/sources/concepts/index.rst index 8b02d15d3..e1cb8cd1a 100644 --- a/docs/sources/concepts/index.rst +++ b/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/docs/sources/concepts/manifesto.rst b/docs/sources/concepts/manifesto.rst new file mode 100644 index 000000000..ae0964709 --- /dev/null +++ b/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/docs/sources/index.rst b/docs/sources/index.rst index 3e66fde1f..05e69dd8e 100644 --- a/docs/sources/index.rst +++ b/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/docs/sources/installation/index.rst b/docs/sources/installation/index.rst index 9f831091c..c2a93f5a0 100644 --- a/docs/sources/installation/index.rst +++ b/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/docs/sources/terms/container.rst b/docs/sources/terms/container.rst new file mode 100644 index 000000000..aeb7b1c3a --- /dev/null +++ b/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/docs/sources/terms/filesystem.rst b/docs/sources/terms/filesystem.rst new file mode 100644 index 000000000..0af893f19 --- /dev/null +++ b/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/docs/sources/terms/fundamentals.rst b/docs/sources/terms/fundamentals.rst deleted file mode 100644 index fed3decb0..000000000 --- a/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/docs/sources/terms/image.rst b/docs/sources/terms/image.rst new file mode 100644 index 000000000..dafda1f3f --- /dev/null +++ b/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/docs/sources/terms/images/docker-filesystems-busyboxrw.png b/docs/sources/terms/images/docker-filesystems-busyboxrw.png index b99a58242..24277dc1f 100644 Binary files a/docs/sources/terms/images/docker-filesystems-busyboxrw.png and b/docs/sources/terms/images/docker-filesystems-busyboxrw.png differ diff --git a/docs/sources/terms/images/docker-filesystems-debian.png b/docs/sources/terms/images/docker-filesystems-debian.png index 0a6468a47..8411733a5 100644 Binary files a/docs/sources/terms/images/docker-filesystems-debian.png and b/docs/sources/terms/images/docker-filesystems-debian.png differ diff --git a/docs/sources/terms/images/docker-filesystems-debianrw.png b/docs/sources/terms/images/docker-filesystems-debianrw.png index 68537f2f5..b7b16c1cc 100644 Binary files a/docs/sources/terms/images/docker-filesystems-debianrw.png and b/docs/sources/terms/images/docker-filesystems-debianrw.png differ diff --git a/docs/sources/terms/images/docker-filesystems-generic.png b/docs/sources/terms/images/docker-filesystems-generic.png index 3866b9560..a6710680a 100644 Binary files a/docs/sources/terms/images/docker-filesystems-generic.png and b/docs/sources/terms/images/docker-filesystems-generic.png differ diff --git a/docs/sources/terms/images/docker-filesystems-multilayer.png b/docs/sources/terms/images/docker-filesystems-multilayer.png index 2fdb23655..025a9d47b 100644 Binary files a/docs/sources/terms/images/docker-filesystems-multilayer.png and b/docs/sources/terms/images/docker-filesystems-multilayer.png differ diff --git a/docs/sources/terms/images/docker-filesystems-multiroot.png b/docs/sources/terms/images/docker-filesystems-multiroot.png index d575b3a4c..42a710cc8 100644 Binary files a/docs/sources/terms/images/docker-filesystems-multiroot.png and b/docs/sources/terms/images/docker-filesystems-multiroot.png differ diff --git a/docs/sources/terms/images/docker-filesystems.svg b/docs/sources/terms/images/docker-filesystems.svg index c0e7b5ba1..13d61dc1e 100644 --- a/docs/sources/terms/images/docker-filesystems.svg +++ b/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/docs/sources/toctree.rst b/docs/sources/toctree.rst index 6226e155f..3c319863e 100644 --- a/docs/sources/toctree.rst +++ b/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/docs/sources/use/workingwithrepository.rst b/docs/sources/use/workingwithrepository.rst index 45702597a..243c99afd 100644 --- a/docs/sources/use/workingwithrepository.rst +++ b/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/network.go b/network.go index 37037dd14..dd79e6059 100644 --- a/network.go +++ b/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/registry/registry.go b/registry/registry.go index e9d7b2b8d..ee473493a 100644 --- a/registry/registry.go +++ b/registry/registry.go @@ -96,7 +96,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 } @@ -116,7 +116,7 @@ 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) @@ -132,7 +132,7 @@ func (r *Registry) LookupRemoteImage(imgId, registry string, token []string) boo } // 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) if err != nil { diff --git a/runtime.go b/runtime.go index 06b1f8e1b..5b0f7b2b2 100644 --- a/runtime.go +++ b/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/runtime_test.go b/runtime_test.go index c367ecd4c..59b219195 100644 --- a/runtime_test.go +++ b/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,7 +89,6 @@ func init() { srv := &Server{ runtime: runtime, enableCors: false, - lock: &sync.Mutex{}, pullingPool: make(map[string]struct{}), pushingPool: make(map[string]struct{}), } @@ -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/server.go b/server.go index 04f43870b..5690bfa8c 100644 --- a/server.go +++ b/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 } @@ -435,8 +435,8 @@ func (srv *Server) pullRepository(r *registry.Registry, out io.Writer, name, ask } 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) @@ -504,20 +504,20 @@ func (srv *Server) ImagePull(name string, tag string, out io.Writer, sf *utils.S // - 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. @@ -591,6 +591,9 @@ func (srv *Server) pushRepository(r *registry.Registry, out io.Writer, name stri if _, exists := repoData.ImgList[elem.ID]; exists { out.Write(sf.FormatStatus("Image %s already on registry, skipping", name)) continue + } else if r.LookupRemoteImage(elem.ID, ep, repoData.Tokens) { + fmt.Fprintf(out, "Image %s already on registry, skipping\n", name) + continue } if err := srv.pushImage(r, out, name, elem.ID, ep, repoData.Tokens, sf); err != nil { // FIXME: Continue on error? @@ -610,21 +613,21 @@ func (srv *Server) pushRepository(r *registry.Registry, out io.Writer, name stri 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, } @@ -640,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) } @@ -780,7 +783,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) @@ -799,7 +802,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 { @@ -919,7 +922,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 } @@ -934,7 +937,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() @@ -952,7 +955,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 @@ -967,7 +970,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) @@ -978,7 +981,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) @@ -1090,7 +1093,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{}), } @@ -1099,9 +1101,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/server_test.go b/server_test.go index 254a4a0c9..cf3e3f0bc 100644 --- a/server_test.go +++ b/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/state.go b/state.go index a972e376a..117659bf5 100644 --- a/state.go +++ b/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/tags.go b/tags.go index 33ec4e149..d1eb36aa7 100644 --- a/tags.go +++ b/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/tags_test.go b/tags_test.go index 90bc05640..1974e751b 100644 --- a/tags_test.go +++ b/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/testing/README.rst b/testing/README.rst index 405adaed9..3b11092f9 100644 --- a/testing/README.rst +++ b/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/testing/Vagrantfile b/testing/Vagrantfile index e3b25a6f9..47257201d 100644 --- a/testing/Vagrantfile +++ b/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/testing/buildbot/master.cfg b/testing/buildbot/master.cfg index 48df5835f..65399bb1a 100644 --- a/testing/buildbot/master.cfg +++ b/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/testing/buildbot/setup.sh b/testing/buildbot/setup.sh index 828ac3ebe..937533ba1 100755 --- a/testing/buildbot/setup.sh +++ b/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/utils.go b/utils.go index 22613e9f4..103e76282 100644 --- a/utils.go +++ b/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/utils/utils.go b/utils/utils.go index 2f2a52867..eee6685c8 100644 --- a/utils/utils.go +++ b/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() }