From 627f7fdbfdfeb281e73e04623915d515e02cf697 Mon Sep 17 00:00:00 2001 From: Solomon Hykes Date: Mon, 6 May 2013 14:24:14 -0700 Subject: [PATCH 01/12] + Website: new quotes --- docs/sources/index.html | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/docs/sources/index.html b/docs/sources/index.html index 1d5313cf5c..ead0a402d4 100644 --- a/docs/sources/index.html +++ b/docs/sources/index.html @@ -152,6 +152,35 @@
+ +
+
+
+ + Matt Townsend‏@mtownsend: I have a serious code crush on docker.io - it's Lego for PaaS. Motherfucking awesome Lego. +
+
+
+
+ + Rob Harrop‏@robertharrop: Impressed by @getdocker - it's all kinds of magic. Serious rethink of AWS architecture happening @skillsmatter. +
+
+
+
+
+
+ + Mitchell Hashimoto‏@mitchellh: Docker launched today. It is incredible. They’re also working RIGHT NOW on a Vagrant provider. LXC is COMING!! +
+
+
+
+ + Adam Jacob‏@adamhjk: Docker is clearly the right idea. @solomonstre absolutely killed it. Containerized app deployment is the future, I think. +
+
+
From f796b9c76eb29ae80ea47d290fba3403ab8e1b4c Mon Sep 17 00:00:00 2001 From: Solomon Hykes Date: Mon, 6 May 2013 14:26:07 -0700 Subject: [PATCH 02/12] * Website: Bigger twitter profile pictures --- docs/sources/index.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/sources/index.html b/docs/sources/index.html index ead0a402d4..1be7e571b8 100644 --- a/docs/sources/index.html +++ b/docs/sources/index.html @@ -156,13 +156,13 @@
- + Matt Townsend‏@mtownsend: I have a serious code crush on docker.io - it's Lego for PaaS. Motherfucking awesome Lego.
- + Rob Harrop‏@robertharrop: Impressed by @getdocker - it's all kinds of magic. Serious rethink of AWS architecture happening @skillsmatter.
From b6af9d3d2eb4e1b409f022264192923a631cd85a Mon Sep 17 00:00:00 2001 From: Solomon Hykes Date: Mon, 6 May 2013 14:26:58 -0700 Subject: [PATCH 03/12] * Website: put Adam's and Mitchell's nice tweets on top :) --- docs/sources/index.html | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/docs/sources/index.html b/docs/sources/index.html index 1be7e571b8..8d2ec4a81f 100644 --- a/docs/sources/index.html +++ b/docs/sources/index.html @@ -153,20 +153,6 @@
-
-
-
- - Matt Townsend‏@mtownsend: I have a serious code crush on docker.io - it's Lego for PaaS. Motherfucking awesome Lego. -
-
-
-
- - Rob Harrop‏@robertharrop: Impressed by @getdocker - it's all kinds of magic. Serious rethink of AWS architecture happening @skillsmatter. -
-
-
@@ -181,6 +167,20 @@
+
+
+
+ + Matt Townsend‏@mtownsend: I have a serious code crush on docker.io - it's Lego for PaaS. Motherfucking awesome Lego. +
+
+
+
+ + Rob Harrop‏@robertharrop: Impressed by @getdocker - it's all kinds of magic. Serious rethink of AWS architecture happening @skillsmatter. +
+
+
From faae7220c019882a2160aeea6bebc46c15d702be Mon Sep 17 00:00:00 2001 From: Victor Vieux Date: Wed, 22 May 2013 15:29:54 +0000 Subject: [PATCH 04/12] api versionning --- api.go | 76 +++++++++++++++++++++++++++++++---------------------- api_test.go | 52 ++++++++++++++++++------------------ commands.go | 10 +++---- 3 files changed, 75 insertions(+), 63 deletions(-) diff --git a/api.go b/api.go index 29103fac10..0a902c4043 100644 --- a/api.go +++ b/api.go @@ -13,6 +13,8 @@ import ( "strings" ) +const API_VERSION = 1.0 + func hijackServer(w http.ResponseWriter) (io.ReadCloser, io.Writer, error) { conn, _, err := w.(http.Hijacker).Hijack() if err != nil { @@ -56,7 +58,7 @@ func getBoolParam(value string) (bool, error) { return false, fmt.Errorf("Bad parameter") } -func getAuth(srv *Server, w http.ResponseWriter, r *http.Request, vars map[string]string) error { +func getAuth(srv *Server, version float64, w http.ResponseWriter, r *http.Request, vars map[string]string) error { b, err := json.Marshal(srv.registry.GetAuthConfig()) if err != nil { return err @@ -65,7 +67,7 @@ func getAuth(srv *Server, w http.ResponseWriter, r *http.Request, vars map[strin return nil } -func postAuth(srv *Server, w http.ResponseWriter, r *http.Request, vars map[string]string) error { +func postAuth(srv *Server, version float64, w http.ResponseWriter, r *http.Request, vars map[string]string) error { config := &auth.AuthConfig{} if err := json.NewDecoder(r.Body).Decode(config); err != nil { return err @@ -94,7 +96,7 @@ func postAuth(srv *Server, w http.ResponseWriter, r *http.Request, vars map[stri return nil } -func getVersion(srv *Server, w http.ResponseWriter, r *http.Request, vars map[string]string) error { +func getVersion(srv *Server, version float64, w http.ResponseWriter, r *http.Request, vars map[string]string) error { m := srv.DockerVersion() b, err := json.Marshal(m) if err != nil { @@ -104,7 +106,7 @@ func getVersion(srv *Server, w http.ResponseWriter, r *http.Request, vars map[st return nil } -func postContainersKill(srv *Server, w http.ResponseWriter, r *http.Request, vars map[string]string) error { +func postContainersKill(srv *Server, version float64, w http.ResponseWriter, r *http.Request, vars map[string]string) error { if vars == nil { return fmt.Errorf("Missing parameter") } @@ -116,7 +118,7 @@ func postContainersKill(srv *Server, w http.ResponseWriter, r *http.Request, var return nil } -func getContainersExport(srv *Server, w http.ResponseWriter, r *http.Request, vars map[string]string) error { +func getContainersExport(srv *Server, version float64, w http.ResponseWriter, r *http.Request, vars map[string]string) error { if vars == nil { return fmt.Errorf("Missing parameter") } @@ -129,7 +131,7 @@ func getContainersExport(srv *Server, w http.ResponseWriter, r *http.Request, va return nil } -func getImagesJson(srv *Server, w http.ResponseWriter, r *http.Request, vars map[string]string) error { +func getImagesJson(srv *Server, version float64, w http.ResponseWriter, r *http.Request, vars map[string]string) error { if err := parseForm(r); err != nil { return err } @@ -152,14 +154,14 @@ func getImagesJson(srv *Server, w http.ResponseWriter, r *http.Request, vars map return nil } -func getImagesViz(srv *Server, w http.ResponseWriter, r *http.Request, vars map[string]string) error { +func getImagesViz(srv *Server, version float64, w http.ResponseWriter, r *http.Request, vars map[string]string) error { if err := srv.ImagesViz(w); err != nil { return err } return nil } -func getInfo(srv *Server, w http.ResponseWriter, r *http.Request, vars map[string]string) error { +func getInfo(srv *Server, version float64, w http.ResponseWriter, r *http.Request, vars map[string]string) error { out := srv.DockerInfo() b, err := json.Marshal(out) if err != nil { @@ -169,7 +171,7 @@ func getInfo(srv *Server, w http.ResponseWriter, r *http.Request, vars map[strin return nil } -func getImagesHistory(srv *Server, w http.ResponseWriter, r *http.Request, vars map[string]string) error { +func getImagesHistory(srv *Server, version float64, w http.ResponseWriter, r *http.Request, vars map[string]string) error { if vars == nil { return fmt.Errorf("Missing parameter") } @@ -186,7 +188,7 @@ func getImagesHistory(srv *Server, w http.ResponseWriter, r *http.Request, vars return nil } -func getContainersChanges(srv *Server, w http.ResponseWriter, r *http.Request, vars map[string]string) error { +func getContainersChanges(srv *Server, version float64, w http.ResponseWriter, r *http.Request, vars map[string]string) error { if vars == nil { return fmt.Errorf("Missing parameter") } @@ -203,7 +205,7 @@ func getContainersChanges(srv *Server, w http.ResponseWriter, r *http.Request, v return nil } -func getContainersPs(srv *Server, w http.ResponseWriter, r *http.Request, vars map[string]string) error { +func getContainersPs(srv *Server, version float64, w http.ResponseWriter, r *http.Request, vars map[string]string) error { if err := parseForm(r); err != nil { return err } @@ -227,7 +229,7 @@ func getContainersPs(srv *Server, w http.ResponseWriter, r *http.Request, vars m return nil } -func postImagesTag(srv *Server, w http.ResponseWriter, r *http.Request, vars map[string]string) error { +func postImagesTag(srv *Server, version float64, w http.ResponseWriter, r *http.Request, vars map[string]string) error { if err := parseForm(r); err != nil { return err } @@ -249,7 +251,7 @@ func postImagesTag(srv *Server, w http.ResponseWriter, r *http.Request, vars map return nil } -func postCommit(srv *Server, w http.ResponseWriter, r *http.Request, vars map[string]string) error { +func postCommit(srv *Server, version float64, w http.ResponseWriter, r *http.Request, vars map[string]string) error { if err := parseForm(r); err != nil { return err } @@ -276,7 +278,7 @@ func postCommit(srv *Server, w http.ResponseWriter, r *http.Request, vars map[st } // Creates an image from Pull or from Import -func postImagesCreate(srv *Server, w http.ResponseWriter, r *http.Request, vars map[string]string) error { +func postImagesCreate(srv *Server, version float64, w http.ResponseWriter, r *http.Request, vars map[string]string) error { if err := parseForm(r); err != nil { return err } @@ -299,7 +301,7 @@ func postImagesCreate(srv *Server, w http.ResponseWriter, r *http.Request, vars return nil } -func getImagesSearch(srv *Server, w http.ResponseWriter, r *http.Request, vars map[string]string) error { +func getImagesSearch(srv *Server, version float64, w http.ResponseWriter, r *http.Request, vars map[string]string) error { if err := parseForm(r); err != nil { return err } @@ -317,7 +319,7 @@ func getImagesSearch(srv *Server, w http.ResponseWriter, r *http.Request, vars m return nil } -func postImagesInsert(srv *Server, w http.ResponseWriter, r *http.Request, vars map[string]string) error { +func postImagesInsert(srv *Server, version float64, w http.ResponseWriter, r *http.Request, vars map[string]string) error { if err := parseForm(r); err != nil { return err } @@ -335,7 +337,7 @@ func postImagesInsert(srv *Server, w http.ResponseWriter, r *http.Request, vars return nil } -func postImagesPush(srv *Server, w http.ResponseWriter, r *http.Request, vars map[string]string) error { +func postImagesPush(srv *Server, version float64, w http.ResponseWriter, r *http.Request, vars map[string]string) error { if err := parseForm(r); err != nil { return err } @@ -352,7 +354,7 @@ func postImagesPush(srv *Server, w http.ResponseWriter, r *http.Request, vars ma return nil } -func postContainersCreate(srv *Server, w http.ResponseWriter, r *http.Request, vars map[string]string) error { +func postContainersCreate(srv *Server, version float64, w http.ResponseWriter, r *http.Request, vars map[string]string) error { config := &Config{} if err := json.NewDecoder(r.Body).Decode(config); err != nil { return err @@ -382,7 +384,7 @@ func postContainersCreate(srv *Server, w http.ResponseWriter, r *http.Request, v return nil } -func postContainersRestart(srv *Server, w http.ResponseWriter, r *http.Request, vars map[string]string) error { +func postContainersRestart(srv *Server, version float64, w http.ResponseWriter, r *http.Request, vars map[string]string) error { if err := parseForm(r); err != nil { return err } @@ -401,7 +403,7 @@ func postContainersRestart(srv *Server, w http.ResponseWriter, r *http.Request, return nil } -func deleteContainers(srv *Server, w http.ResponseWriter, r *http.Request, vars map[string]string) error { +func deleteContainers(srv *Server, version float64, w http.ResponseWriter, r *http.Request, vars map[string]string) error { if err := parseForm(r); err != nil { return err } @@ -421,7 +423,7 @@ func deleteContainers(srv *Server, w http.ResponseWriter, r *http.Request, vars return nil } -func deleteImages(srv *Server, w http.ResponseWriter, r *http.Request, vars map[string]string) error { +func deleteImages(srv *Server, version float64, w http.ResponseWriter, r *http.Request, vars map[string]string) error { if vars == nil { return fmt.Errorf("Missing parameter") } @@ -433,7 +435,7 @@ func deleteImages(srv *Server, w http.ResponseWriter, r *http.Request, vars map[ return nil } -func postContainersStart(srv *Server, w http.ResponseWriter, r *http.Request, vars map[string]string) error { +func postContainersStart(srv *Server, version float64, w http.ResponseWriter, r *http.Request, vars map[string]string) error { if vars == nil { return fmt.Errorf("Missing parameter") } @@ -445,7 +447,7 @@ func postContainersStart(srv *Server, w http.ResponseWriter, r *http.Request, va return nil } -func postContainersStop(srv *Server, w http.ResponseWriter, r *http.Request, vars map[string]string) error { +func postContainersStop(srv *Server, version float64, w http.ResponseWriter, r *http.Request, vars map[string]string) error { if err := parseForm(r); err != nil { return err } @@ -466,7 +468,7 @@ func postContainersStop(srv *Server, w http.ResponseWriter, r *http.Request, var return nil } -func postContainersWait(srv *Server, w http.ResponseWriter, r *http.Request, vars map[string]string) error { +func postContainersWait(srv *Server, version float64, w http.ResponseWriter, r *http.Request, vars map[string]string) error { if vars == nil { return fmt.Errorf("Missing parameter") } @@ -483,7 +485,7 @@ func postContainersWait(srv *Server, w http.ResponseWriter, r *http.Request, var return nil } -func postContainersAttach(srv *Server, w http.ResponseWriter, r *http.Request, vars map[string]string) error { +func postContainersAttach(srv *Server, version float64, w http.ResponseWriter, r *http.Request, vars map[string]string) error { if err := parseForm(r); err != nil { return err } @@ -526,7 +528,7 @@ func postContainersAttach(srv *Server, w http.ResponseWriter, r *http.Request, v return nil } -func getContainersByName(srv *Server, w http.ResponseWriter, r *http.Request, vars map[string]string) error { +func getContainersByName(srv *Server, version float64, w http.ResponseWriter, r *http.Request, vars map[string]string) error { if vars == nil { return fmt.Errorf("Missing parameter") } @@ -544,7 +546,7 @@ func getContainersByName(srv *Server, w http.ResponseWriter, r *http.Request, va return nil } -func getImagesByName(srv *Server, w http.ResponseWriter, r *http.Request, vars map[string]string) error { +func getImagesByName(srv *Server, version float64, w http.ResponseWriter, r *http.Request, vars map[string]string) error { if vars == nil { return fmt.Errorf("Missing parameter") } @@ -562,7 +564,7 @@ func getImagesByName(srv *Server, w http.ResponseWriter, r *http.Request, vars m return nil } -func postImagesGetCache(srv *Server, w http.ResponseWriter, r *http.Request, vars map[string]string) error { +func postImagesGetCache(srv *Server, version float64, w http.ResponseWriter, r *http.Request, vars map[string]string) error { apiConfig := &ApiImageConfig{} if err := json.NewDecoder(r.Body).Decode(apiConfig); err != nil { return err @@ -589,7 +591,7 @@ func ListenAndServe(addr string, srv *Server, logging bool) error { r := mux.NewRouter() log.Printf("Listening for HTTP on %s\n", addr) - m := map[string]map[string]func(*Server, http.ResponseWriter, *http.Request, map[string]string) error{ + m := map[string]map[string]func(*Server, float64, http.ResponseWriter, *http.Request, map[string]string) error{ "GET": { "/auth": getAuth, "/version": getVersion, @@ -633,7 +635,7 @@ func ListenAndServe(addr string, srv *Server, logging bool) error { localRoute := route localMethod := method localFct := fct - r.Path(localRoute).Methods(localMethod).HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + f := func(w http.ResponseWriter, r *http.Request) { utils.Debugf("Calling %s %s", localMethod, localRoute) if logging { log.Println(r.Method, r.RequestURI) @@ -644,10 +646,20 @@ func ListenAndServe(addr string, srv *Server, logging bool) error { utils.Debugf("Warning: client and server don't have the same version (client: %s, server: %s)", userAgent[1], VERSION) } } - if err := localFct(srv, w, r, mux.Vars(r)); err != nil { + version, err := strconv.ParseFloat(mux.Vars(r)["version"], 64) + if err != nil { + version = API_VERSION + } + if version == 0 || version > API_VERSION { + w.WriteHeader(http.StatusNotFound) + return + } + if err := localFct(srv, version, w, r, mux.Vars(r)); err != nil { httpError(w, err) } - }) + } + r.Path("/v{version:[0-9.]+}" + localRoute).Methods(localMethod).HandlerFunc(f) + r.Path(localRoute).Methods(localMethod).HandlerFunc(f) } } diff --git a/api_test.go b/api_test.go index dd685ffece..de4289728e 100644 --- a/api_test.go +++ b/api_test.go @@ -48,7 +48,7 @@ func TestGetAuth(t *testing.T) { t.Fatal(err) } - if err := postAuth(srv, r, req, nil); err != nil { + if err := postAuth(srv, API_VERSION, r, req, nil); err != nil { t.Fatal(err) } @@ -74,7 +74,7 @@ func TestGetVersion(t *testing.T) { r := httptest.NewRecorder() - if err := getVersion(srv, r, nil, nil); err != nil { + if err := getVersion(srv, API_VERSION, r, nil, nil); err != nil { t.Fatal(err) } @@ -98,7 +98,7 @@ func TestGetInfo(t *testing.T) { r := httptest.NewRecorder() - if err := getInfo(srv, r, nil, nil); err != nil { + if err := getInfo(srv, API_VERSION, r, nil, nil); err != nil { t.Fatal(err) } @@ -129,7 +129,7 @@ func TestGetImagesJson(t *testing.T) { r := httptest.NewRecorder() - if err := getImagesJson(srv, r, req, nil); err != nil { + if err := getImagesJson(srv, API_VERSION, r, req, nil); err != nil { t.Fatal(err) } @@ -154,7 +154,7 @@ func TestGetImagesJson(t *testing.T) { t.Fatal(err) } - if err := getImagesJson(srv, r2, req2, nil); err != nil { + if err := getImagesJson(srv, API_VERSION, r2, req2, nil); err != nil { t.Fatal(err) } @@ -179,7 +179,7 @@ func TestGetImagesJson(t *testing.T) { t.Fatal(err) } - if err := getImagesJson(srv, r3, req3, nil); err != nil { + if err := getImagesJson(srv, API_VERSION, r3, req3, nil); err != nil { t.Fatal(err) } @@ -200,7 +200,7 @@ func TestGetImagesJson(t *testing.T) { t.Fatal(err) } - err = getImagesJson(srv, r4, req4, nil) + err = getImagesJson(srv, API_VERSION, r4, req4, nil) if err == nil { t.Fatalf("Error expected, received none") } @@ -221,7 +221,7 @@ func TestGetImagesViz(t *testing.T) { srv := &Server{runtime: runtime} r := httptest.NewRecorder() - if err := getImagesViz(srv, r, nil, nil); err != nil { + if err := getImagesViz(srv, API_VERSION, r, nil, nil); err != nil { t.Fatal(err) } @@ -258,7 +258,7 @@ func TestGetImagesSearch(t *testing.T) { t.Fatal(err) } - if err := getImagesSearch(srv, r, req, nil); err != nil { + if err := getImagesSearch(srv, API_VERSION, r, req, nil); err != nil { t.Fatal(err) } @@ -282,7 +282,7 @@ func TestGetImagesHistory(t *testing.T) { r := httptest.NewRecorder() - if err := getImagesHistory(srv, r, nil, map[string]string{"name": unitTestImageName}); err != nil { + if err := getImagesHistory(srv, API_VERSION, r, nil, map[string]string{"name": unitTestImageName}); err != nil { t.Fatal(err) } @@ -305,7 +305,7 @@ func TestGetImagesByName(t *testing.T) { srv := &Server{runtime: runtime} r := httptest.NewRecorder() - if err := getImagesByName(srv, r, nil, map[string]string{"name": unitTestImageName}); err != nil { + if err := getImagesByName(srv, API_VERSION, r, nil, map[string]string{"name": unitTestImageName}); err != nil { t.Fatal(err) } @@ -342,7 +342,7 @@ func TestGetContainersPs(t *testing.T) { } r := httptest.NewRecorder() - if err := getContainersPs(srv, r, req, nil); err != nil { + if err := getContainersPs(srv, API_VERSION, r, req, nil); err != nil { t.Fatal(err) } containers := []ApiContainers{} @@ -385,7 +385,7 @@ func TestGetContainersExport(t *testing.T) { } r := httptest.NewRecorder() - if err = getContainersExport(srv, r, nil, map[string]string{"name": container.Id}); err != nil { + if err = getContainersExport(srv, API_VERSION, r, nil, map[string]string{"name": container.Id}); err != nil { t.Fatal(err) } @@ -440,7 +440,7 @@ func TestGetContainersChanges(t *testing.T) { } r := httptest.NewRecorder() - if err := getContainersChanges(srv, r, nil, map[string]string{"name": container.Id}); err != nil { + if err := getContainersChanges(srv, API_VERSION, r, nil, map[string]string{"name": container.Id}); err != nil { t.Fatal(err) } changes := []Change{} @@ -484,7 +484,7 @@ func TestGetContainersByName(t *testing.T) { defer runtime.Destroy(container) r := httptest.NewRecorder() - if err := getContainersByName(srv, r, nil, map[string]string{"name": container.Id}); err != nil { + if err := getContainersByName(srv, API_VERSION, r, nil, map[string]string{"name": container.Id}); err != nil { t.Fatal(err) } outContainer := &Container{} @@ -515,7 +515,7 @@ func TestPostAuth(t *testing.T) { srv.registry.ResetClient(authConfigOrig) r := httptest.NewRecorder() - if err := getAuth(srv, r, nil, nil); err != nil { + if err := getAuth(srv, API_VERSION, r, nil, nil); err != nil { t.Fatal(err) } @@ -562,7 +562,7 @@ func TestPostCommit(t *testing.T) { } r := httptest.NewRecorder() - if err := postCommit(srv, r, req, nil); err != nil { + if err := postCommit(srv, API_VERSION, r, req, nil); err != nil { t.Fatal(err) } if r.Code != http.StatusCreated { @@ -840,7 +840,7 @@ func TestPostContainersCreate(t *testing.T) { } r := httptest.NewRecorder() - if err := postContainersCreate(srv, r, req, nil); err != nil { + if err := postContainersCreate(srv, API_VERSION, r, req, nil); err != nil { t.Fatal(err) } if r.Code != http.StatusCreated { @@ -903,7 +903,7 @@ func TestPostContainersKill(t *testing.T) { } r := httptest.NewRecorder() - if err := postContainersKill(srv, r, nil, map[string]string{"name": container.Id}); err != nil { + if err := postContainersKill(srv, API_VERSION, r, nil, map[string]string{"name": container.Id}); err != nil { t.Fatal(err) } if r.Code != http.StatusNoContent { @@ -951,7 +951,7 @@ func TestPostContainersRestart(t *testing.T) { t.Fatal(err) } r := httptest.NewRecorder() - if err := postContainersRestart(srv, r, req, map[string]string{"name": container.Id}); err != nil { + if err := postContainersRestart(srv, API_VERSION, r, req, map[string]string{"name": container.Id}); err != nil { t.Fatal(err) } if r.Code != http.StatusNoContent { @@ -992,7 +992,7 @@ func TestPostContainersStart(t *testing.T) { defer runtime.Destroy(container) r := httptest.NewRecorder() - if err := postContainersStart(srv, r, nil, map[string]string{"name": container.Id}); err != nil { + if err := postContainersStart(srv, API_VERSION, r, nil, map[string]string{"name": container.Id}); err != nil { t.Fatal(err) } if r.Code != http.StatusNoContent { @@ -1007,7 +1007,7 @@ func TestPostContainersStart(t *testing.T) { } r = httptest.NewRecorder() - if err = postContainersStart(srv, r, nil, map[string]string{"name": container.Id}); err == nil { + if err = postContainersStart(srv, API_VERSION, r, nil, map[string]string{"name": container.Id}); err == nil { t.Fatalf("A running containter should be able to be started") } @@ -1054,7 +1054,7 @@ func TestPostContainersStop(t *testing.T) { t.Fatal(err) } r := httptest.NewRecorder() - if err := postContainersStop(srv, r, req, map[string]string{"name": container.Id}); err != nil { + if err := postContainersStop(srv, API_VERSION, r, req, map[string]string{"name": container.Id}); err != nil { t.Fatal(err) } if r.Code != http.StatusNoContent { @@ -1092,7 +1092,7 @@ func TestPostContainersWait(t *testing.T) { setTimeout(t, "Wait timed out", 3*time.Second, func() { r := httptest.NewRecorder() - if err := postContainersWait(srv, r, nil, map[string]string{"name": container.Id}); err != nil { + if err := postContainersWait(srv, API_VERSION, r, nil, map[string]string{"name": container.Id}); err != nil { t.Fatal(err) } apiWait := &ApiWait{} @@ -1154,7 +1154,7 @@ func TestPostContainersAttach(t *testing.T) { t.Fatal(err) } - if err := postContainersAttach(srv, r, req, map[string]string{"name": container.Id}); err != nil { + if err := postContainersAttach(srv, API_VERSION, r, req, map[string]string{"name": container.Id}); err != nil { t.Fatal(err) } }() @@ -1224,7 +1224,7 @@ func TestDeleteContainers(t *testing.T) { t.Fatal(err) } r := httptest.NewRecorder() - if err := deleteContainers(srv, r, req, map[string]string{"name": container.Id}); err != nil { + if err := deleteContainers(srv, API_VERSION, r, req, map[string]string{"name": container.Id}); err != nil { t.Fatal(err) } if r.Code != http.StatusNoContent { diff --git a/commands.go b/commands.go index 5e459a1d94..17d7e08ff2 100644 --- a/commands.go +++ b/commands.go @@ -1167,7 +1167,7 @@ func (cli *DockerCli) call(method, path string, data interface{}) ([]byte, int, params = bytes.NewBuffer(buf) } - req, err := http.NewRequest(method, fmt.Sprintf("http://%s:%d", cli.host, cli.port)+path, params) + req, err := http.NewRequest(method, fmt.Sprintf("http://%s:%d/v%f", cli.host, cli.port, API_VERSION)+path, params) if err != nil { return nil, -1, err } @@ -1199,7 +1199,7 @@ func (cli *DockerCli) stream(method, path string, in io.Reader, out io.Writer) e if (method == "POST" || method == "PUT") && in == nil { in = bytes.NewReader([]byte{}) } - req, err := http.NewRequest(method, fmt.Sprintf("http://%s:%d%s", cli.host, cli.port, path), in) + req, err := http.NewRequest(method, fmt.Sprintf("http://%s:%d/v%f%s", cli.host, cli.port, API_VERSION, path), in) if err != nil { return err } @@ -1230,7 +1230,7 @@ func (cli *DockerCli) stream(method, path string, in io.Reader, out io.Writer) e } func (cli *DockerCli) hijack(method, path string, setRawTerminal bool) error { - req, err := http.NewRequest(method, path, nil) + req, err := http.NewRequest(method, fmt.Sprintf("/v%f%s", API_VERSION, path), nil) if err != nil { return err } @@ -1294,6 +1294,6 @@ func NewDockerCli(host string, port int) *DockerCli { } type DockerCli struct { - host string - port int + host string + port int } From 9e0427081e80dbf6c7702c8428ec64e40f362804 Mon Sep 17 00:00:00 2001 From: Andreas Tiefenthaler Date: Thu, 23 May 2013 18:09:59 +0300 Subject: [PATCH 05/12] Fixing two typos in the run help --- docs/sources/commandline/command/run.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/sources/commandline/command/run.rst b/docs/sources/commandline/command/run.rst index f9bd568b6c..d6c9aef315 100644 --- a/docs/sources/commandline/command/run.rst +++ b/docs/sources/commandline/command/run.rst @@ -23,5 +23,5 @@ -t=false: Allocate a pseudo-tty -u="": Username or UID -d=[]: Set custom dns servers for the container - -v=[]: Creates a new volumes and mount it at the specified path. + -v=[]: Creates a new volume and mounts it at the specified path. -volumes-from="": Mount all volumes from the given container. From e77263010ce882790f12dfcd0841ea784dab0738 Mon Sep 17 00:00:00 2001 From: Solomon Hykes Date: Thu, 23 May 2013 09:47:20 -0600 Subject: [PATCH 06/12] Simplified and clarified kernel install instructions --- docs/sources/installation/kernel.rst | 61 +++++----------------------- 1 file changed, 11 insertions(+), 50 deletions(-) diff --git a/docs/sources/installation/kernel.rst b/docs/sources/installation/kernel.rst index 61a7bb3855..6331a77348 100644 --- a/docs/sources/installation/kernel.rst +++ b/docs/sources/installation/kernel.rst @@ -7,20 +7,25 @@ Kernel Requirements =================== +In short, Docker has the following kernel requirements: + +- Linux version 3.8 or above. + +- Compiled with `AUFS support `_. + +- Cgroups and namespaces must be enabled. + + The officially supported kernel is the one recommended by the :ref:`ubuntu_linux` installation path. It is the one that most developers will use, and the one that receives the most attention from the core contributors. If you decide to go with a different kernel and hit a bug, please try to reproduce it with the official kernels first. -If for some reason you cannot or do not want to use the "official" kernels, +If you cannot or do not want to use the "official" kernels, here is some technical background about the features (both optional and mandatory) that docker needs to run successfully. -In short, you need kernel version 3.8 (or above), compiled to include -`AUFS support `_. Of course, you need to -enable cgroups and namespaces. - Namespaces and Cgroups ---------------------- @@ -38,30 +43,11 @@ Kernels 2.6.38, and every version since 3.2, have been deployed successfully to run containerized production workloads. Feature-wise, there is no huge improvement between 2.6.38 and up to 3.6 (as far as docker is concerned!). -Starting with version 3.7, the kernel has basic support for -`Checkpoint/Restore In Userspace `_, which is not used by -docker at this point, but allows to suspend the state of a container to -disk and resume it later. - -Version 3.8 provides improvements in stability, which are deemed necessary -for the operation of docker. Versions 3.2 to 3.5 have been shown to -exhibit a reproducible bug (for more details, see issue -`#407 `_). - -Version 3.8 also brings better support for the -`setns() syscall `_ -- but this should not -be a concern since docker does not leverage on this feature for now. - -If you want a technical overview about those concepts, you might -want to check those articles on dotCloud's blog: -`about namespaces `_ -and `about cgroups `_. - Important Note About Pre-3.8 Kernels ------------------------------------ -As mentioned above, kernels before 3.8 are not stable when used with docker. +Kernel versions 3.2 to 3.5 are not stable when used with docker. In some circumstances, you will experience kernel "oopses", or even crashes. The symptoms include: @@ -126,28 +112,3 @@ distributions, is not part of the standard kernel. This means that if you decide to roll your own kernel, you will have to patch your kernel tree to add AUFS. The process is documented on `AUFS webpage `_. - -Note: the AUFS patch is fairly intrusive, but for the record, people have -successfully applied GRSEC and AUFS together, to obtain hardened production -kernels. - -If you want more information about that topic, there is an -`article about AUFS on dotCloud's blog -`_. - - -BTRFS, ZFS, OverlayFS... ------------------------- - -There is ongoing development on docker, to implement support for -`BTRFS `_ -(see github issue `#443 `_). - -People have also showed interest for `ZFS `_ -(using e.g. `ZFS-on-Linux `_) and OverlayFS. -The latter is functionally close to AUFS, and it might end up being included -in the stock kernel; so it's a strong candidate! - -Would you like to `contribute -`_ -support for your favorite filesystem? From dbb7b60cfc97dc1b7a1412775475048b6bf18e67 Mon Sep 17 00:00:00 2001 From: Solomon Hykes Date: Thu, 23 May 2013 09:49:53 -0600 Subject: [PATCH 07/12] Re-ordered and re-titled kernel requirement details to match the shortlist --- docs/sources/installation/kernel.rst | 65 ++++++++++++++-------------- 1 file changed, 33 insertions(+), 32 deletions(-) diff --git a/docs/sources/installation/kernel.rst b/docs/sources/installation/kernel.rst index 6331a77348..6f242e9e10 100644 --- a/docs/sources/installation/kernel.rst +++ b/docs/sources/installation/kernel.rst @@ -11,7 +11,7 @@ In short, Docker has the following kernel requirements: - Linux version 3.8 or above. -- Compiled with `AUFS support `_. +- `AUFS support `_. - Cgroups and namespaces must be enabled. @@ -26,26 +26,8 @@ If you cannot or do not want to use the "official" kernels, here is some technical background about the features (both optional and mandatory) that docker needs to run successfully. - -Namespaces and Cgroups ----------------------- - -You need to enable namespaces and cgroups, to the extend of what is needed -to run LXC containers. Technically, while namespaces have been introduced -in the early 2.6 kernels, we do not advise to try any kernel before 2.6.32 -to run LXC containers. Note that 2.6.32 has some documented issues regarding -network namespace setup and teardown; those issues are not a risk if you -run containers in a private environment, but can lead to denial-of-service -attacks if you want to run untrusted code in your containers. For more details, -see `[LP#720095 `_. - -Kernels 2.6.38, and every version since 3.2, have been deployed successfully -to run containerized production workloads. Feature-wise, there is no huge -improvement between 2.6.38 and up to 3.6 (as far as docker is concerned!). - - -Important Note About Pre-3.8 Kernels ------------------------------------- +Linux version 3.8 or above +-------------------------- Kernel versions 3.2 to 3.5 are not stable when used with docker. In some circumstances, you will experience kernel "oopses", or even crashes. @@ -67,6 +49,36 @@ detects something older than 3.8. See issue `#407 `_ for details. +AUFS support +------------ + +Docker currently relies on AUFS, an unioning filesystem. +While AUFS is included in the kernels built by the Debian and Ubuntu +distributions, is not part of the standard kernel. This means that if +you decide to roll your own kernel, you will have to patch your +kernel tree to add AUFS. The process is documented on +`AUFS webpage `_. + + +Cgroups and namespaces +---------------------- + +You need to enable namespaces and cgroups, to the extend of what is needed +to run LXC containers. Technically, while namespaces have been introduced +in the early 2.6 kernels, we do not advise to try any kernel before 2.6.32 +to run LXC containers. Note that 2.6.32 has some documented issues regarding +network namespace setup and teardown; those issues are not a risk if you +run containers in a private environment, but can lead to denial-of-service +attacks if you want to run untrusted code in your containers. For more details, +see `[LP#720095 `_. + +Kernels 2.6.38, and every version since 3.2, have been deployed successfully +to run containerized production workloads. Feature-wise, there is no huge +improvement between 2.6.38 and up to 3.6 (as far as docker is concerned!). + + + + Extra Cgroup Controllers ------------------------ @@ -101,14 +113,3 @@ And replace it by the following one:: GRUB_CMDLINE_LINUX="cgroup_enable=memory swapaccount" Then run ``update-grub``, and reboot. - - -AUFS ----- - -Docker currently relies on AUFS, an unioning filesystem. -While AUFS is included in the kernels built by the Debian and Ubuntu -distributions, is not part of the standard kernel. This means that if -you decide to roll your own kernel, you will have to patch your -kernel tree to add AUFS. The process is documented on -`AUFS webpage `_. From e0e385ac696c339958cdb9b4094c25f120dae1ec Mon Sep 17 00:00:00 2001 From: Solomon Hykes Date: Thu, 23 May 2013 11:12:54 -0600 Subject: [PATCH 08/12] * Build: leave temporary containers untouched after a failure to help debugging --- builder_client.go | 6 ------ 1 file changed, 6 deletions(-) diff --git a/builder_client.go b/builder_client.go index ceeab002c9..c3950b2be3 100644 --- a/builder_client.go +++ b/builder_client.go @@ -32,12 +32,6 @@ type builderClient struct { } func (b *builderClient) clearTmp(containers, images map[string]struct{}) { - for c := range containers { - if _, _, err := b.cli.call("DELETE", "/containers/"+c, nil); err != nil { - utils.Debugf("%s", err) - } - utils.Debugf("Removing container %s", c) - } for i := range images { if _, _, err := b.cli.call("DELETE", "/images/"+i, nil); err != nil { utils.Debugf("%s", err) From d17c0b83681d45f4b4c57ca66cfc574246fd6618 Mon Sep 17 00:00:00 2001 From: Daniel Mizyrycki Date: Thu, 23 May 2013 12:42:58 -0700 Subject: [PATCH 09/12] Packaging: Update changelog for release 0.3.3 --- CHANGELOG.md | 4 +++ packaging/ubuntu/changelog | 63 +++++++++++++++++++++----------------- 2 files changed, 39 insertions(+), 28 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a9e2dab79e..4d3502d23a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## 0.3.3 (2013-05-23) + - Registry: Fix push regression + - Various bugfixes + ## 0.3.2 (2013-05-09) * Runtime: Store the actual archive on commit * Registry: Improve the checksum process diff --git a/packaging/ubuntu/changelog b/packaging/ubuntu/changelog index 2e4907f200..c8a8c1689b 100644 --- a/packaging/ubuntu/changelog +++ b/packaging/ubuntu/changelog @@ -1,37 +1,44 @@ +lxc-docker (0.3.3-1) precise; urgency=low + - Registry: Fix push regression + - Various bugfixes + + -- dotCloud Thu, 23 May 2013 00:00:00 -0700 + + lxc-docker (0.3.2-1) precise; urgency=low - - Runtime: Store the actual archive on commit - - Registry: Improve the checksum process - - Registry: Use the size to have a good progress bar while pushing - - Registry: Use the actual archive if it exists in order to speed up the push - - Registry: Fix error 400 on push + - Runtime: Store the actual archive on commit + - Registry: Improve the checksum process + - Registry: Use the size to have a good progress bar while pushing + - Registry: Use the actual archive if it exists in order to speed up the push + - Registry: Fix error 400 on push -- dotCloud Fri, 9 May 2013 00:00:00 -0700 lxc-docker (0.3.1-1) precise; urgency=low - - Builder: Implement the autorun capability within docker builder - - Builder: Add caching to docker builder - - Builder: Add support for docker builder with native API as top level command - - Runtime: Add go version to debug infos - - Builder: Implement ENV within docker builder - - Registry: Add docker search top level command in order to search a repository - - Images: output graph of images to dot (graphviz) - - Documentation: new introduction and high-level overview - - Documentation: Add the documentation for docker builder - - Website: new high-level overview - - Makefile: Swap "go get" for "go get -d", especially to compile on go1.1rc - - Images: fix ByParent function - - Builder: Check the command existance prior create and add Unit tests for the case - - Registry: Fix pull for official images with specific tag - - Registry: Fix issue when login in with a different user and trying to push - - Documentation: CSS fix for docker documentation to make REST API docs look better. - - Documentation: Fixed CouchDB example page header mistake - - Documentation: fixed README formatting - - Registry: Improve checksum - async calculation - - Runtime: kernel version - don't show the dash if flavor is empty - - Documentation: updated www.docker.io website. - - Builder: use any whitespaces instead of tabs - - Packaging: packaging ubuntu; issue #510: Use goland-stable PPA package to build docker + - Builder: Implement the autorun capability within docker builder + - Builder: Add caching to docker builder + - Builder: Add support for docker builder with native API as top level command + - Runtime: Add go version to debug infos + - Builder: Implement ENV within docker builder + - Registry: Add docker search top level command in order to search a repository + - Images: output graph of images to dot (graphviz) + - Documentation: new introduction and high-level overview + - Documentation: Add the documentation for docker builder + - Website: new high-level overview + - Makefile: Swap "go get" for "go get -d", especially to compile on go1.1rc + - Images: fix ByParent function + - Builder: Check the command existance prior create and add Unit tests for the case + - Registry: Fix pull for official images with specific tag + - Registry: Fix issue when login in with a different user and trying to push + - Documentation: CSS fix for docker documentation to make REST API docs look better. + - Documentation: Fixed CouchDB example page header mistake + - Documentation: fixed README formatting + - Registry: Improve checksum - async calculation + - Runtime: kernel version - don't show the dash if flavor is empty + - Documentation: updated www.docker.io website. + - Builder: use any whitespaces instead of tabs + - Packaging: packaging ubuntu; issue #510: Use goland-stable PPA package to build docker -- dotCloud Fri, 8 May 2013 00:00:00 -0700 From 822056094aa31c224e78cd568e02fe5458a0eecc Mon Sep 17 00:00:00 2001 From: "Guillaume J. Charmes" Date: Thu, 23 May 2013 12:46:14 -0700 Subject: [PATCH 10/12] Bumped version to 0.3.3 --- commands.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/commands.go b/commands.go index 17d7e08ff2..75ba562cd8 100644 --- a/commands.go +++ b/commands.go @@ -24,7 +24,7 @@ import ( "unicode" ) -const VERSION = "0.3.2" +const VERSION = "0.3.3" var ( GIT_COMMIT string From 83bc5b7435565d227a7745f4832bc9ce6be7a80d Mon Sep 17 00:00:00 2001 From: Will Dietz Date: Thu, 23 May 2013 15:48:50 -0500 Subject: [PATCH 11/12] utils.go: Fix merge logic for user and hostname. Fall back to image-specified hostname if user doesn't provide one, instead of only using image-specified hostname if the user *does* try to set one. (ditto for username) Closes #694. --- utils.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/utils.go b/utils.go index 27478002d3..5a9d02c490 100644 --- a/utils.go +++ b/utils.go @@ -49,10 +49,10 @@ func CompareConfig(a, b *Config) bool { } func MergeConfig(userConf, imageConf *Config) { - if userConf.Hostname != "" { + if userConf.Hostname == "" { userConf.Hostname = imageConf.Hostname } - if userConf.User != "" { + if userConf.User == "" { userConf.User = imageConf.User } if userConf.Memory == 0 { From 1f23b4caae6cd60a2bc1911c17fcebcadc539497 Mon Sep 17 00:00:00 2001 From: Victor Vieux Date: Fri, 24 May 2013 14:23:43 +0000 Subject: [PATCH 12/12] fix docker login when same username --- api.go | 8 ++++---- commands.go | 4 ++-- registry/registry.go | 7 ++++++- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/api.go b/api.go index 0a902c4043..216ae027ee 100644 --- a/api.go +++ b/api.go @@ -59,7 +59,7 @@ func getBoolParam(value string) (bool, error) { } func getAuth(srv *Server, version float64, w http.ResponseWriter, r *http.Request, vars map[string]string) error { - b, err := json.Marshal(srv.registry.GetAuthConfig()) + b, err := json.Marshal(srv.registry.GetAuthConfig(false)) if err != nil { return err } @@ -72,9 +72,9 @@ func postAuth(srv *Server, version float64, w http.ResponseWriter, r *http.Reque if err := json.NewDecoder(r.Body).Decode(config); err != nil { return err } - - if config.Username == srv.registry.GetAuthConfig().Username { - config.Password = srv.registry.GetAuthConfig().Password + authConfig := srv.registry.GetAuthConfig(true) + if config.Username == authConfig.Username { + config.Password = authConfig.Password } newAuthConfig := auth.NewAuthConfig(config.Username, config.Password, config.Email, srv.runtime.root) diff --git a/commands.go b/commands.go index 75ba562cd8..8c4630b828 100644 --- a/commands.go +++ b/commands.go @@ -1294,6 +1294,6 @@ func NewDockerCli(host string, port int) *DockerCli { } type DockerCli struct { - host string - port int + host string + port int } diff --git a/registry/registry.go b/registry/registry.go index ce9b4b4ac7..bd361b5e74 100644 --- a/registry/registry.go +++ b/registry/registry.go @@ -428,9 +428,14 @@ func (r *Registry) ResetClient(authConfig *auth.AuthConfig) { r.client.Jar = cookiejar.NewCookieJar() } -func (r *Registry) GetAuthConfig() *auth.AuthConfig { +func (r *Registry) GetAuthConfig(withPasswd bool) *auth.AuthConfig { + password := "" + if withPasswd { + password = r.authConfig.Password + } return &auth.AuthConfig{ Username: r.authConfig.Username, + Password: password, Email: r.authConfig.Email, } }