Browse code

bump to master

Victor Vieux authored on 2013/06/13 02:39:32
Showing 37 changed files
... ...
@@ -42,6 +42,7 @@ Ken Cochrane <kencochrane@gmail.com>
42 42
 Kevin J. Lynagh <kevin@keminglabs.com>
43 43
 Louis Opter <kalessin@kalessin.fr>
44 44
 Maxim Treskin <zerthurd@gmail.com>
45
+Michael Crosby <crosby.michael@gmail.com>
45 46
 Mikhail Sobolev <mss@mawhrin.net>
46 47
 Nate Jones <nate@endot.org>
47 48
 Nelson Chen <crazysim@gmail.com>
... ...
@@ -251,7 +251,7 @@ Note
251 251
 ----
252 252
 
253 253
 We also keep the documentation in this repository. The website documentation is generated using sphinx using these sources.
254
-Please find it under docs/sources/ and read more about it https://github.com/dotcloud/docker/master/docs/README.md
254
+Please find it under docs/sources/ and read more about it https://github.com/dotcloud/docker/tree/master/docs/README.md
255 255
 
256 256
 Please feel free to fix / update the documentation and send us pull requests. More tutorials are also welcome.
257 257
 
... ...
@@ -371,4 +371,7 @@ Standard Container Specification
371 371
 
372 372
 #### Security
373 373
 
374
+### Legal
375
+
376
+Transfers Docker shall be in accordance with any applicable export control or other legal requirements.
374 377
 
... ...
@@ -722,9 +722,18 @@ func postBuild(srv *Server, version float64, w http.ResponseWriter, r *http.Requ
722 722
 	return nil
723 723
 }
724 724
 
725
-func ListenAndServe(addr string, srv *Server, logging bool) error {
725
+func optionsHandler(srv *Server, version float64, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
726
+	w.WriteHeader(http.StatusOK)
727
+	return nil
728
+}
729
+func writeCorsHeaders(w http.ResponseWriter, r *http.Request) {
730
+	w.Header().Add("Access-Control-Allow-Origin", "*")
731
+	w.Header().Add("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept")
732
+	w.Header().Add("Access-Control-Allow-Methods", "GET, POST, DELETE, PUT, OPTIONS")
733
+}
734
+
735
+func createRouter(srv *Server, logging bool) (*mux.Router, error) {
726 736
 	r := mux.NewRouter()
727
-	log.Printf("Listening for HTTP on %s\n", addr)
728 737
 
729 738
 	m := map[string]map[string]func(*Server, float64, http.ResponseWriter, *http.Request, map[string]string) error{
730 739
 		"GET": {
... ...
@@ -764,6 +773,9 @@ func ListenAndServe(addr string, srv *Server, logging bool) error {
764 764
 			"/containers/{name:.*}": deleteContainers,
765 765
 			"/images/{name:.*}":     deleteImages,
766 766
 		},
767
+		"OPTIONS": {
768
+			"": optionsHandler,
769
+		},
767 770
 	}
768 771
 
769 772
 	for method, routes := range m {
... ...
@@ -788,6 +800,9 @@ func ListenAndServe(addr string, srv *Server, logging bool) error {
788 788
 				if err != nil {
789 789
 					version = APIVERSION
790 790
 				}
791
+				if srv.enableCors {
792
+					writeCorsHeaders(w, r)
793
+				}
791 794
 				if version == 0 || version > APIVERSION {
792 795
 					w.WriteHeader(http.StatusNotFound)
793 796
 					return
... ...
@@ -796,9 +811,24 @@ func ListenAndServe(addr string, srv *Server, logging bool) error {
796 796
 					httpError(w, err)
797 797
 				}
798 798
 			}
799
-			r.Path("/v{version:[0-9.]+}" + localRoute).Methods(localMethod).HandlerFunc(f)
800
-			r.Path(localRoute).Methods(localMethod).HandlerFunc(f)
799
+
800
+			if localRoute == "" {
801
+				r.Methods(localMethod).HandlerFunc(f)
802
+			} else {
803
+				r.Path("/v{version:[0-9.]+}" + localRoute).Methods(localMethod).HandlerFunc(f)
804
+				r.Path(localRoute).Methods(localMethod).HandlerFunc(f)
805
+			}
801 806
 		}
802 807
 	}
808
+	return r, nil
809
+}
810
+
811
+func ListenAndServe(addr string, srv *Server, logging bool) error {
812
+	log.Printf("Listening for HTTP on %s\n", addr)
813
+
814
+	r, err := createRouter(srv, logging)
815
+	if err != nil {
816
+		return err
817
+	}
803 818
 	return http.ListenAndServe(addr, r)
804 819
 }
... ...
@@ -1198,6 +1198,73 @@ func TestDeleteContainers(t *testing.T) {
1198 1198
 	}
1199 1199
 }
1200 1200
 
1201
+func TestOptionsRoute(t *testing.T) {
1202
+	runtime, err := newTestRuntime()
1203
+	if err != nil {
1204
+		t.Fatal(err)
1205
+	}
1206
+	defer nuke(runtime)
1207
+
1208
+	srv := &Server{runtime: runtime, enableCors: true}
1209
+
1210
+	r := httptest.NewRecorder()
1211
+	router, err := createRouter(srv, false)
1212
+	if err != nil {
1213
+		t.Fatal(err)
1214
+	}
1215
+
1216
+	req, err := http.NewRequest("OPTIONS", "/", nil)
1217
+	if err != nil {
1218
+		t.Fatal(err)
1219
+	}
1220
+
1221
+	router.ServeHTTP(r, req)
1222
+	if r.Code != http.StatusOK {
1223
+		t.Errorf("Expected response for OPTIONS request to be \"200\", %v found.", r.Code)
1224
+	}
1225
+}
1226
+
1227
+func TestGetEnabledCors(t *testing.T) {
1228
+	runtime, err := newTestRuntime()
1229
+	if err != nil {
1230
+		t.Fatal(err)
1231
+	}
1232
+	defer nuke(runtime)
1233
+
1234
+	srv := &Server{runtime: runtime, enableCors: true}
1235
+
1236
+	r := httptest.NewRecorder()
1237
+
1238
+	router, err := createRouter(srv, false)
1239
+	if err != nil {
1240
+		t.Fatal(err)
1241
+	}
1242
+
1243
+	req, err := http.NewRequest("GET", "/version", nil)
1244
+	if err != nil {
1245
+		t.Fatal(err)
1246
+	}
1247
+
1248
+	router.ServeHTTP(r, req)
1249
+	if r.Code != http.StatusOK {
1250
+		t.Errorf("Expected response for OPTIONS request to be \"200\", %v found.", r.Code)
1251
+	}
1252
+
1253
+	allowOrigin := r.Header().Get("Access-Control-Allow-Origin")
1254
+	allowHeaders := r.Header().Get("Access-Control-Allow-Headers")
1255
+	allowMethods := r.Header().Get("Access-Control-Allow-Methods")
1256
+
1257
+	if allowOrigin != "*" {
1258
+		t.Errorf("Expected header Access-Control-Allow-Origin to be \"*\", %s found.", allowOrigin)
1259
+	}
1260
+	if allowHeaders != "Origin, X-Requested-With, Content-Type, Accept" {
1261
+		t.Errorf("Expected header Access-Control-Allow-Headers to be \"Origin, X-Requested-With, Content-Type, Accept\", %s found.", allowHeaders)
1262
+	}
1263
+	if allowMethods != "GET, POST, DELETE, PUT, OPTIONS" {
1264
+		t.Errorf("Expected hearder Access-Control-Allow-Methods to be \"GET, POST, DELETE, PUT, OPTIONS\", %s found.", allowMethods)
1265
+	}
1266
+}
1267
+
1201 1268
 func TestDeleteImages(t *testing.T) {
1202 1269
 	//FIXME: Implement this test
1203 1270
 	t.Log("Test not implemented")
... ...
@@ -313,10 +313,11 @@ func (b *buildFile) Build(dockerfile, context io.Reader) (string, error) {
313 313
 	for {
314 314
 		line, err := file.ReadString('\n')
315 315
 		if err != nil {
316
-			if err == io.EOF {
316
+			if err == io.EOF && line == "" {
317 317
 				break
318
+			} else if err != io.EOF {
319
+				return "", err
318 320
 			}
319
-			return "", err
320 321
 		}
321 322
 		line = strings.Replace(strings.TrimSpace(line), "	", " ", 1)
322 323
 		// Skip comments and empty line
... ...
@@ -15,58 +15,69 @@ run    sh -c 'echo root:testpass > /tmp/passwd'
15 15
 run    mkdir -p /var/run/sshd
16 16
 `
17 17
 
18
+const DockerfileNoNewLine = `
19
+# VERSION		0.1
20
+# DOCKER-VERSION	0.2
21
+
22
+from   ` + unitTestImageName + `
23
+run    sh -c 'echo root:testpass > /tmp/passwd'
24
+run    mkdir -p /var/run/sshd`
25
+
18 26
 func TestBuild(t *testing.T) {
19
-	runtime, err := newTestRuntime()
20
-	if err != nil {
21
-		t.Fatal(err)
22
-	}
23
-	defer nuke(runtime)
27
+	dockerfiles := []string{Dockerfile, DockerfileNoNewLine}
28
+	for _, Dockerfile := range dockerfiles {
29
+		runtime, err := newTestRuntime()
30
+		if err != nil {
31
+			t.Fatal(err)
32
+		}
33
+		defer nuke(runtime)
24 34
 
25
-	srv := &Server{runtime: runtime}
35
+		srv := &Server{runtime: runtime}
26 36
 
27
-	buildfile := NewBuildFile(srv, &utils.NopWriter{})
37
+		buildfile := NewBuildFile(srv, &utils.NopWriter{})
28 38
 
29
-	imgID, err := buildfile.Build(strings.NewReader(Dockerfile), nil)
30
-	if err != nil {
31
-		t.Fatal(err)
32
-	}
39
+		imgID, err := buildfile.Build(strings.NewReader(Dockerfile), nil)
40
+		if err != nil {
41
+			t.Fatal(err)
42
+		}
33 43
 
34
-	builder := NewBuilder(runtime)
35
-	container, err := builder.Create(
36
-		&Config{
37
-			Image: imgID,
38
-			Cmd:   []string{"cat", "/tmp/passwd"},
39
-		},
40
-	)
41
-	if err != nil {
42
-		t.Fatal(err)
43
-	}
44
-	defer runtime.Destroy(container)
44
+		builder := NewBuilder(runtime)
45
+		container, err := builder.Create(
46
+			&Config{
47
+				Image: imgID,
48
+				Cmd:   []string{"cat", "/tmp/passwd"},
49
+			},
50
+		)
51
+		if err != nil {
52
+			t.Fatal(err)
53
+		}
54
+		defer runtime.Destroy(container)
45 55
 
46
-	output, err := container.Output()
47
-	if err != nil {
48
-		t.Fatal(err)
49
-	}
50
-	if string(output) != "root:testpass\n" {
51
-		t.Fatalf("Unexpected output. Read '%s', expected '%s'", output, "root:testpass\n")
52
-	}
56
+		output, err := container.Output()
57
+		if err != nil {
58
+			t.Fatal(err)
59
+		}
60
+		if string(output) != "root:testpass\n" {
61
+			t.Fatalf("Unexpected output. Read '%s', expected '%s'", output, "root:testpass\n")
62
+		}
53 63
 
54
-	container2, err := builder.Create(
55
-		&Config{
56
-			Image: imgID,
57
-			Cmd:   []string{"ls", "-d", "/var/run/sshd"},
58
-		},
59
-	)
60
-	if err != nil {
61
-		t.Fatal(err)
62
-	}
63
-	defer runtime.Destroy(container2)
64
+		container2, err := builder.Create(
65
+			&Config{
66
+				Image: imgID,
67
+				Cmd:   []string{"ls", "-d", "/var/run/sshd"},
68
+			},
69
+		)
70
+		if err != nil {
71
+			t.Fatal(err)
72
+		}
73
+		defer runtime.Destroy(container2)
64 74
 
65
-	output, err = container2.Output()
66
-	if err != nil {
67
-		t.Fatal(err)
68
-	}
69
-	if string(output) != "/var/run/sshd\n" {
70
-		t.Fatal("/var/run/sshd has not been created")
75
+		output, err = container2.Output()
76
+		if err != nil {
77
+			t.Fatal(err)
78
+		}
79
+		if string(output) != "/var/run/sshd\n" {
80
+			t.Fatal("/var/run/sshd has not been created")
81
+		}
71 82
 	}
72 83
 }
... ...
@@ -218,7 +218,10 @@ func (cli *DockerCli) CmdBuild(args ...string) error {
218 218
 		if err != nil {
219 219
 			return err
220 220
 		}
221
-		return fmt.Errorf("error: %s", body)
221
+		if len(body) == 0 {
222
+			return fmt.Errorf("Error: %s", http.StatusText(resp.StatusCode))
223
+		}
224
+		return fmt.Errorf("Error: %s", body)
222 225
 	}
223 226
 
224 227
 	// Output the result
... ...
@@ -448,7 +451,7 @@ func (cli *DockerCli) CmdStop(args ...string) error {
448 448
 	for _, name := range cmd.Args() {
449 449
 		_, _, err := cli.call("POST", "/containers/"+name+"/stop?"+v.Encode(), nil)
450 450
 		if err != nil {
451
-			fmt.Printf("%s", err)
451
+			fmt.Fprintf(os.Stderr, "%s", err)
452 452
 		} else {
453 453
 			fmt.Println(name)
454 454
 		}
... ...
@@ -473,7 +476,7 @@ func (cli *DockerCli) CmdRestart(args ...string) error {
473 473
 	for _, name := range cmd.Args() {
474 474
 		_, _, err := cli.call("POST", "/containers/"+name+"/restart?"+v.Encode(), nil)
475 475
 		if err != nil {
476
-			fmt.Printf("%s", err)
476
+			fmt.Fprintf(os.Stderr, "%s", err)
477 477
 		} else {
478 478
 			fmt.Println(name)
479 479
 		}
... ...
@@ -494,7 +497,7 @@ func (cli *DockerCli) CmdStart(args ...string) error {
494 494
 	for _, name := range args {
495 495
 		_, _, err := cli.call("POST", "/containers/"+name+"/start", nil)
496 496
 		if err != nil {
497
-			fmt.Printf("%s", err)
497
+			fmt.Fprintf(os.Stderr, "%s", err)
498 498
 		} else {
499 499
 			fmt.Println(name)
500 500
 		}
... ...
@@ -503,29 +506,38 @@ func (cli *DockerCli) CmdStart(args ...string) error {
503 503
 }
504 504
 
505 505
 func (cli *DockerCli) CmdInspect(args ...string) error {
506
-	cmd := Subcmd("inspect", "CONTAINER|IMAGE", "Return low-level information on a container/image")
506
+	cmd := Subcmd("inspect", "CONTAINER|IMAGE [CONTAINER|IMAGE...]", "Return low-level information on a container/image")
507 507
 	if err := cmd.Parse(args); err != nil {
508 508
 		return nil
509 509
 	}
510
-	if cmd.NArg() != 1 {
510
+	if cmd.NArg() < 1 {
511 511
 		cmd.Usage()
512 512
 		return nil
513 513
 	}
514
-	obj, _, err := cli.call("GET", "/containers/"+cmd.Arg(0)+"/json", nil)
515
-	if err != nil {
516
-		obj, _, err = cli.call("GET", "/images/"+cmd.Arg(0)+"/json", nil)
514
+	fmt.Printf("[")
515
+	for i, name := range args {
516
+		if i > 0 {
517
+			fmt.Printf(",")
518
+		}
519
+		obj, _, err := cli.call("GET", "/containers/"+name+"/json", nil)
517 520
 		if err != nil {
518
-			return err
521
+			obj, _, err = cli.call("GET", "/images/"+name+"/json", nil)
522
+			if err != nil {
523
+				fmt.Fprintf(os.Stderr, "%s", err)
524
+				continue
525
+			}
519 526
 		}
520
-	}
521 527
 
522
-	indented := new(bytes.Buffer)
523
-	if err = json.Indent(indented, obj, "", "    "); err != nil {
524
-		return err
525
-	}
526
-	if _, err := io.Copy(os.Stdout, indented); err != nil {
527
-		return err
528
+		indented := new(bytes.Buffer)
529
+		if err = json.Indent(indented, obj, "", "    "); err != nil {
530
+			fmt.Fprintf(os.Stderr, "%s", err)
531
+			continue
532
+		}
533
+		if _, err := io.Copy(os.Stdout, indented); err != nil {
534
+			fmt.Fprintf(os.Stderr, "%s", err)
535
+		}
528 536
 	}
537
+	fmt.Printf("]")
529 538
 	return nil
530 539
 }
531 540
 
... ...
@@ -552,7 +564,7 @@ func (cli *DockerCli) CmdPort(args ...string) error {
552 552
 	if frontend, exists := out.NetworkSettings.PortMapping[cmd.Arg(1)]; exists {
553 553
 		fmt.Println(frontend)
554 554
 	} else {
555
-		return fmt.Errorf("error: No private port '%s' allocated on %s", cmd.Arg(1), cmd.Arg(0))
555
+		return fmt.Errorf("Error: No private port '%s' allocated on %s", cmd.Arg(1), cmd.Arg(0))
556 556
 	}
557 557
 	return nil
558 558
 }
... ...
@@ -1074,7 +1086,12 @@ func (cli *DockerCli) CmdSearch(args ...string) error {
1074 1074
 	w := tabwriter.NewWriter(os.Stdout, 20, 1, 3, ' ', 0)
1075 1075
 	fmt.Fprintf(w, "NAME\tDESCRIPTION\n")
1076 1076
 	for _, out := range outs {
1077
-		fmt.Fprintf(w, "%s\t%s\n", out.Name, out.Description)
1077
+		desc := strings.Replace(out.Description, "\n", " ", -1)
1078
+		desc = strings.Replace(desc, "\r", " ", -1)
1079
+		if len(desc) > 45 {
1080
+			desc = utils.Trunc(desc, 42) + "..."
1081
+		}
1082
+		fmt.Fprintf(w, "%s\t%s\n", out.Name, desc)
1078 1083
 	}
1079 1084
 	w.Flush()
1080 1085
 	return nil
... ...
@@ -1309,7 +1326,10 @@ func (cli *DockerCli) call(method, path string, data interface{}) ([]byte, int,
1309 1309
 		return nil, -1, err
1310 1310
 	}
1311 1311
 	if resp.StatusCode < 200 || resp.StatusCode >= 400 {
1312
-		return nil, resp.StatusCode, fmt.Errorf("error: %s", body)
1312
+		if len(body) == 0 {
1313
+			return nil, resp.StatusCode, fmt.Errorf("Error: %s", http.StatusText(resp.StatusCode))
1314
+		}
1315
+		return nil, resp.StatusCode, fmt.Errorf("Error: %s", body)
1313 1316
 	}
1314 1317
 	return body, resp.StatusCode, nil
1315 1318
 }
... ...
@@ -1339,7 +1359,10 @@ func (cli *DockerCli) stream(method, path string, in io.Reader, out io.Writer) e
1339 1339
 		if err != nil {
1340 1340
 			return err
1341 1341
 		}
1342
-		return fmt.Errorf("error: %s", body)
1342
+		if len(body) == 0 {
1343
+			return fmt.Errorf("Error :%s", http.StatusText(resp.StatusCode))
1344
+		}
1345
+		return fmt.Errorf("Error: %s", body)
1343 1346
 	}
1344 1347
 
1345 1348
 	if resp.Header.Get("Content-Type") == "application/json" {
... ...
@@ -1408,7 +1431,7 @@ func (cli *DockerCli) hijack(method, path string, setRawTerminal bool, in *os.Fi
1408 1408
 		return err
1409 1409
 	}
1410 1410
 
1411
-	if !term.IsTerminal(os.Stdin.Fd()) {
1411
+	if !term.IsTerminal(in.Fd()) {
1412 1412
 		if err := <-sendStdin; err != nil {
1413 1413
 			return err
1414 1414
 		}
1415 1415
deleted file mode 100644
... ...
@@ -1 +0,0 @@
1
-Solomon Hykes <solomon@dotcloud.com>
2 1
deleted file mode 100644
... ...
@@ -1,68 +0,0 @@
1
-# docker-build: build your software with docker
2
-
3
-## Description
4
-
5
-docker-build is a script to build docker images from source. It will be deprecated once the 'build' feature is incorporated into docker itself (See https://github.com/dotcloud/docker/issues/278)
6
-
7
-Author: Solomon Hykes <solomon@dotcloud.com>
8
-
9
-
10
-## Install
11
-
12
-docker-builder requires:
13
-
14
-1) A reasonably recent Python setup (tested on 2.7.2).
15
-
16
-2) A running docker daemon at version 0.1.4 or more recent (http://www.docker.io/gettingstarted)
17
-
18
-
19
-## Usage
20
-
21
-First create a valid Changefile, which defines a sequence of changes to apply to a base image.
22
-
23
-    $ cat Changefile
24
-    # Start build from a know base image
25
-    from	base:ubuntu-12.10
26
-    # Update ubuntu sources
27
-    run	echo 'deb http://archive.ubuntu.com/ubuntu quantal main universe multiverse' > /etc/apt/sources.list
28
-    run	apt-get update
29
-    # Install system packages
30
-    run	DEBIAN_FRONTEND=noninteractive apt-get install -y -q git
31
-    run DEBIAN_FRONTEND=noninteractive apt-get install -y -q curl
32
-    run DEBIAN_FRONTEND=noninteractive apt-get install -y -q golang
33
-    # Insert files from the host (./myscript must be present in the current directory)
34
-    copy	myscript /usr/local/bin/myscript
35
-
36
-
37
-Run docker-build, and pass the contents of your Changefile as standard input.
38
-
39
-    $ IMG=$(./docker-build < Changefile)
40
-
41
-This will take a while: for each line of the changefile, docker-build will:
42
-
43
-1. Create a new container to execute the given command or insert the given file
44
-2. Wait for the container to complete execution
45
-3. Commit the resulting changes as a new image
46
-4. Use the resulting image as the input of the next step
47
-
48
-
49
-If all the steps succeed, the result will be an image containing the combined results of each build step.
50
-You can trace back those build steps by inspecting the image's history:
51
-
52
-    $ docker history $IMG
53
-    ID                  CREATED             CREATED BY
54
-    1e9e2045de86        A few seconds ago   /bin/sh -c cat > /usr/local/bin/myscript; chmod +x /usr/local/bin/git
55
-    77db140aa62a        A few seconds ago   /bin/sh -c DEBIAN_FRONTEND=noninteractive apt-get install -y -q golang
56
-    77db140aa62a        A few seconds ago   /bin/sh -c DEBIAN_FRONTEND=noninteractive apt-get install -y -q curl
57
-    77db140aa62a        A few seconds ago   /bin/sh -c DEBIAN_FRONTEND=noninteractive apt-get install -y -q git 
58
-    83e85d155451        A few seconds ago   /bin/sh -c apt-get update
59
-    bfd53b36d9d3        A few seconds ago   /bin/sh -c echo 'deb http://archive.ubuntu.com/ubuntu quantal main universe multiverse' > /etc/apt/sources.list
60
-    base		2 weeks ago         /bin/bash
61
-    27cf78414709        2 weeks ago
62
-
63
-
64
-Note that your build started from 'base', as instructed by your Changefile. But that base image itself seems to have been built in 2 steps - hence the extra step in the history.
65
-
66
-
67
-You can use this build technique to create any image you want: a database, a web application, or anything else that can be build by a sequence of unix commands - in other words, anything else.
68
-
69 1
deleted file mode 100755
... ...
@@ -1,142 +0,0 @@
1
-#!/usr/bin/env python
2
-
3
-# docker-build is a script to build docker images from source.
4
-# It will be deprecated once the 'build' feature is incorporated into docker itself.
5
-# (See https://github.com/dotcloud/docker/issues/278)
6
-#
7
-# Author: Solomon Hykes <solomon@dotcloud.com>
8
-
9
-
10
-
11
-# First create a valid Changefile, which defines a sequence of changes to apply to a base image.
12
-# 
13
-#     $ cat Changefile
14
-#     # Start build from a know base image
15
-#     from	base:ubuntu-12.10
16
-#     # Update ubuntu sources
17
-#     run	echo 'deb http://archive.ubuntu.com/ubuntu quantal main universe multiverse' > /etc/apt/sources.list
18
-#     run	apt-get update
19
-#     # Install system packages
20
-#     run	DEBIAN_FRONTEND=noninteractive apt-get install -y -q git
21
-#     run DEBIAN_FRONTEND=noninteractive apt-get install -y -q curl
22
-#     run DEBIAN_FRONTEND=noninteractive apt-get install -y -q golang
23
-#     # Insert files from the host (./myscript must be present in the current directory)
24
-#     copy	myscript /usr/local/bin/myscript
25
-# 
26
-# 
27
-# Run docker-build, and pass the contents of your Changefile as standard input.
28
-# 
29
-#     $ IMG=$(./docker-build < Changefile)
30
-# 
31
-# This will take a while: for each line of the changefile, docker-build will:
32
-# 
33
-# 1. Create a new container to execute the given command or insert the given file
34
-# 2. Wait for the container to complete execution
35
-# 3. Commit the resulting changes as a new image
36
-# 4. Use the resulting image as the input of the next step
37
-
38
-
39
-import sys
40
-import subprocess
41
-import json
42
-import hashlib
43
-
44
-def docker(args, stdin=None):
45
-	print "# docker " + " ".join(args)
46
-	p = subprocess.Popen(["docker"] + list(args), stdin=stdin, stdout=subprocess.PIPE)
47
-	return p.stdout
48
-
49
-def image_exists(img):
50
-	return docker(["inspect", img]).read().strip() != ""
51
-
52
-def image_config(img):
53
-	return json.loads(docker(["inspect", img]).read()).get("config", {})
54
-
55
-def run_and_commit(img_in, cmd, stdin=None, author=None, run=None):
56
-	run_id = docker(["run"] + (["-i", "-a", "stdin"] if stdin else ["-d"]) + [img_in, "/bin/sh", "-c", cmd], stdin=stdin).read().rstrip()
57
-	print "---> Waiting for " + run_id
58
-	result=int(docker(["wait", run_id]).read().rstrip())
59
-	if result != 0:
60
-		print "!!! '{}' return non-zero exit code '{}'. Aborting.".format(cmd, result)
61
-		sys.exit(1)
62
-	return docker(["commit"] + (["-author", author] if author else []) + (["-run", json.dumps(run)] if run is not None else []) + [run_id]).read().rstrip()
63
-
64
-def insert(base, src, dst, author=None):
65
-	print "COPY {} to {} in {}".format(src, dst, base)
66
-	if dst == "":
67
-		raise Exception("Missing destination path")
68
-	stdin = file(src)
69
-	stdin.seek(0)
70
-	return run_and_commit(base, "cat > {0}; chmod +x {0}".format(dst), stdin=stdin, author=author)
71
-
72
-def add(base, src, dst, author=None):
73
-	print "PUSH to {} in {}".format(dst, base)
74
-	if src == ".":
75
-		tar = subprocess.Popen(["tar", "-c", "."], stdout=subprocess.PIPE).stdout
76
-	else:
77
-		tar = subprocess.Popen(["curl", src], stdout=subprocess.PIPE).stdout
78
-	if dst == "":
79
-		raise Exception("Missing argument to push")
80
-	return run_and_commit(base, "mkdir -p '{0}' && tar -C '{0}' -x".format(dst), stdin=tar, author=author)
81
-
82
-def main():
83
-	base=""
84
-	maintainer=""
85
-	steps = []
86
-	try:
87
-		for line in sys.stdin.readlines():
88
-			line = line.strip()
89
-			# Skip comments and empty lines
90
-			if line == "" or line[0] == "#":
91
-				continue
92
-			op, param = line.split(None, 1)
93
-			print op.upper() + " " + param
94
-			if op == "from":
95
-				base = param
96
-				steps.append(base)
97
-			elif op == "maintainer":
98
-				maintainer = param
99
-			elif op == "run":
100
-				result = run_and_commit(base, param, author=maintainer)
101
-				steps.append(result)
102
-				base = result
103
-				print "===> " + base
104
-			elif op == "copy":
105
-				src, dst = param.split("	", 1)
106
-				result = insert(base, src, dst, author=maintainer)
107
-				steps.append(result)
108
-				base = result
109
-				print "===> " + base
110
-			elif op == "add":
111
-				src, dst = param.split("	", 1)
112
-				result = add(base, src, dst, author=maintainer)
113
-				steps.append(result)
114
-				base=result
115
-				print "===> " + base
116
-			elif op == "expose":
117
-				config = image_config(base)
118
-				if config.get("PortSpecs") is None:
119
-					config["PortSpecs"] = []
120
-				portspec = param.strip()
121
-				config["PortSpecs"].append(portspec)
122
-				result = run_and_commit(base, "# (nop) expose port {}".format(portspec), author=maintainer, run=config)
123
-				steps.append(result)
124
-				base=result
125
-				print "===> " + base
126
-			elif op == "cmd":
127
-				config  = image_config(base)
128
-				cmd = list(json.loads(param))
129
-				config["Cmd"] = cmd
130
-				result = run_and_commit(base, "# (nop) set default command to '{}'".format(" ".join(cmd)), author=maintainer, run=config)
131
-				steps.append(result)
132
-				base=result
133
-				print "===> " + base
134
-			else:
135
-				print "Skipping uknown op " + op
136
-	except:
137
-		docker(["rmi"] + steps[1:])
138
-		raise
139
-	print base
140
-
141
-if __name__ == "__main__":
142
-	main()
143 1
deleted file mode 100644
... ...
@@ -1,13 +0,0 @@
1
-# Start build from a know base image
2
-maintainer	Solomon Hykes <solomon@dotcloud.com>
3
-from	base:ubuntu-12.10
4
-# Update ubuntu sources
5
-run	echo 'deb http://archive.ubuntu.com/ubuntu quantal main universe multiverse' > /etc/apt/sources.list
6
-run	apt-get update
7
-# Install system packages
8
-run	DEBIAN_FRONTEND=noninteractive apt-get install -y -q git
9
-run	DEBIAN_FRONTEND=noninteractive apt-get install -y -q curl
10
-run	DEBIAN_FRONTEND=noninteractive apt-get install -y -q golang
11
-# Insert files from the host (./myscript must be present in the current directory)
12
-copy	myscript	/usr/local/bin/myscript
13
-push	/src
14 1
deleted file mode 100644
... ...
@@ -1,3 +0,0 @@
1
-#!/bin/sh
2
-
3
-echo hello, world!
... ...
@@ -33,6 +33,7 @@ func main() {
33 33
 	bridgeName := flag.String("b", "", "Attach containers to a pre-existing network bridge")
34 34
 	pidfile := flag.String("p", "/var/run/docker.pid", "File containing process PID")
35 35
 	flHost := flag.String("H", fmt.Sprintf("%s:%d", host, port), "Host:port to bind/connect to")
36
+	flEnableCors := flag.Bool("api-enable-cors", false, "Enable CORS requests in the remote api.")
36 37
 	flag.Parse()
37 38
 	if *bridgeName != "" {
38 39
 		docker.NetworkBridgeIface = *bridgeName
... ...
@@ -65,7 +66,7 @@ func main() {
65 65
 			flag.Usage()
66 66
 			return
67 67
 		}
68
-		if err := daemon(*pidfile, host, port, *flAutoRestart); err != nil {
68
+		if err := daemon(*pidfile, host, port, *flAutoRestart, *flEnableCors); err != nil {
69 69
 			log.Fatal(err)
70 70
 			os.Exit(-1)
71 71
 		}
... ...
@@ -104,7 +105,7 @@ func removePidFile(pidfile string) {
104 104
 	}
105 105
 }
106 106
 
107
-func daemon(pidfile, addr string, port int, autoRestart bool) error {
107
+func daemon(pidfile, addr string, port int, autoRestart, enableCors bool) error {
108 108
 	if addr != "127.0.0.1" {
109 109
 		log.Println("/!\\ DON'T BIND ON ANOTHER IP ADDRESS THAN 127.0.0.1 IF YOU DON'T KNOW WHAT YOU'RE DOING /!\\")
110 110
 	}
... ...
@@ -122,7 +123,7 @@ func daemon(pidfile, addr string, port int, autoRestart bool) error {
122 122
 		os.Exit(0)
123 123
 	}()
124 124
 
125
-	server, err := docker.NewServer(autoRestart)
125
+	server, err := docker.NewServer(autoRestart, enableCors)
126 126
 	if err != nil {
127 127
 		return err
128 128
 	}
... ...
@@ -46,12 +46,11 @@ clean:
46 46
 	-rm -rf $(BUILDDIR)/*
47 47
 
48 48
 docs:
49
-	#-rm -rf $(BUILDDIR)/*
50 49
 	$(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/html
51 50
 	@echo
52 51
 	@echo "Build finished. The documentation pages are now in $(BUILDDIR)/html."
53 52
 
54
-server:
53
+server: docs
55 54
 	@cd $(BUILDDIR)/html; $(PYTHON) -m SimpleHTTPServer 8000
56 55
 
57 56
 site:
... ...
@@ -62,12 +61,13 @@ site:
62 62
 
63 63
 connect:
64 64
 	@echo connecting dotcloud to www.docker.io website, make sure to use user 1
65
-	@cd _build/website/ ; \
65
+	@echo or create your own "dockerwebsite" app
66
+	@cd $(BUILDDIR)/website/ ; \
66 67
 	dotcloud connect dockerwebsite ; \
67 68
 	dotcloud list
68 69
 
69 70
 push:
70
-	@cd _build/website/ ; \
71
+	@cd $(BUILDDIR)/website/ ; \
71 72
 	dotcloud push
72 73
 
73 74
 $(VERSIONS):
74 75
new file mode 100644
... ...
@@ -0,0 +1,5 @@
0
+This directory holds the authoritative specifications of APIs defined and implemented by Docker. Currently this includes:
1
+
2
+* The remote API by which a docker node can be queried over HTTP
3
+* The registry API by which a docker node can download and upload container images for storage and sharing
4
+* The index search API by which a docker node can search the public index for images to download
... ...
@@ -69,3 +69,27 @@ Initial version
69 69
 
70 70
 .. _a8ae398: https://github.com/dotcloud/docker/commit/a8ae398bf52e97148ee7bd0d5868de2e15bd297f
71 71
 .. _8d73740: https://github.com/dotcloud/docker/commit/8d73740343778651c09160cde9661f5f387b36f4
72
+
73
+==================================
74
+Docker Remote API Client Libraries
75
+==================================
76
+
77
+These libraries have been not tested by the Docker Maintainers for
78
+compatibility. Please file issues with the library owners.  If you
79
+find more library implementations, please list them in Docker doc bugs
80
+and we will add the libraries here.
81
+
82
++----------------------+----------------+--------------------------------------------+
83
+| Language/Framework   | Name           | Repository                                 |
84
++======================+================+============================================+
85
+| Python               | docker-py      | https://github.com/dotcloud/docker-py      |
86
++----------------------+----------------+--------------------------------------------+
87
+| Ruby                 | docker-ruby    | https://github.com/ActiveState/docker-ruby |
88
++----------------------+----------------+--------------------------------------------+
89
+| Ruby                 | docker-client  | https://github.com/geku/docker-client      |
90
++----------------------+----------------+--------------------------------------------+
91
+| Javascript           | docker-js      | https://github.com/dgoujard/docker-js      |
92
++----------------------+----------------+--------------------------------------------+
93
+| Javascript (Angular) | dockerui       | https://github.com/crosbymichael/dockerui  |
94
+| **WebUI**            |                |                                            |
95
++----------------------+----------------+--------------------------------------------+
... ...
@@ -994,3 +994,11 @@ Here are the steps of 'docker run' :
994 994
 -------------
995 995
 
996 996
 In this version of the API, /attach, uses hijacking to transport stdin, stdout and stderr on the same socket. This might change in the future.
997
+
998
+3.3 CORS Requests
999
+-----------------
1000
+
1001
+To enable cross origin requests to the remote api add the flag "-api-enable-cors" when running docker in daemon mode.
1002
+    
1003
+    docker -d -H="192.168.1.9:4243" -api-enable-cors
1004
+
... ...
@@ -5,13 +5,14 @@
5 5
 APIs
6 6
 ====
7 7
 
8
-This following :
8
+Your programs and scripts can access Docker's functionality via these interfaces:
9 9
 
10 10
 .. toctree::
11 11
   :maxdepth: 3
12 12
 
13
+  registry_index_spec
13 14
   registry_api
14
-  index_search_api
15
+  index_api
15 16
   docker_remote_api
16 17
 
17 18
 
18 19
new file mode 100644
... ...
@@ -0,0 +1,553 @@
0
+:title: Index API
1
+:description: API Documentation for Docker Index
2
+:keywords: API, Docker, index, REST, documentation
3
+
4
+=================
5
+Docker Index API
6
+=================
7
+
8
+.. contents:: Table of Contents
9
+
10
+1. Brief introduction
11
+=====================
12
+
13
+- This is the REST API for the Docker index
14
+- Authorization is done with basic auth over SSL
15
+- Not all commands require authentication, only those noted as such.
16
+
17
+2. Endpoints
18
+============
19
+
20
+2.1 Repository
21
+^^^^^^^^^^^^^^
22
+
23
+Repositories
24
+*************
25
+
26
+User Repo
27
+~~~~~~~~~
28
+
29
+.. http:put:: /v1/repositories/(namespace)/(repo_name)/
30
+
31
+    Create a user repository with the given ``namespace`` and ``repo_name``.
32
+
33
+    **Example Request**:
34
+
35
+    .. sourcecode:: http
36
+
37
+        PUT /v1/repositories/foo/bar/ HTTP/1.1
38
+        Host: index.docker.io
39
+        Accept: application/json
40
+        Content-Type: application/json
41
+        Authorization: Basic akmklmasadalkm==
42
+        X-Docker-Token: true
43
+
44
+        [{“id”: “9e89cc6f0bc3c38722009fe6857087b486531f9a779a0c17e3ed29dae8f12c4f”}]
45
+
46
+    :parameter namespace: the namespace for the repo
47
+    :parameter repo_name: the name for the repo
48
+
49
+    **Example Response**:
50
+
51
+    .. sourcecode:: http
52
+
53
+        HTTP/1.1 200
54
+        Vary: Accept
55
+        Content-Type: application/json
56
+        WWW-Authenticate: Token signature=123abc,repository=”foo/bar”,access=write
57
+        X-Docker-Endpoints: registry-1.docker.io [, registry-2.docker.io]
58
+
59
+        ""
60
+
61
+    :statuscode 200: Created
62
+    :statuscode 400: Errors (invalid json, missing or invalid fields, etc)
63
+    :statuscode 401: Unauthorized
64
+    :statuscode 403: Account is not Active
65
+
66
+
67
+.. http:delete:: /v1/repositories/(namespace)/(repo_name)/
68
+
69
+    Delete a user repository with the given ``namespace`` and ``repo_name``.
70
+
71
+    **Example Request**:
72
+
73
+    .. sourcecode:: http
74
+
75
+        DELETE /v1/repositories/foo/bar/ HTTP/1.1
76
+        Host: index.docker.io
77
+        Accept: application/json
78
+        Content-Type: application/json
79
+        Authorization: Basic akmklmasadalkm==
80
+        X-Docker-Token: true
81
+
82
+        ""
83
+
84
+    :parameter namespace: the namespace for the repo
85
+    :parameter repo_name: the name for the repo
86
+
87
+    **Example Response**:
88
+
89
+    .. sourcecode:: http
90
+
91
+        HTTP/1.1 202
92
+        Vary: Accept
93
+        Content-Type: application/json
94
+        WWW-Authenticate: Token signature=123abc,repository=”foo/bar”,access=delete
95
+        X-Docker-Endpoints: registry-1.docker.io [, registry-2.docker.io]
96
+
97
+        ""
98
+
99
+    :statuscode 200: Deleted
100
+    :statuscode 202: Accepted
101
+    :statuscode 400: Errors (invalid json, missing or invalid fields, etc)
102
+    :statuscode 401: Unauthorized
103
+    :statuscode 403: Account is not Active
104
+
105
+Library Repo
106
+~~~~~~~~~~~~
107
+
108
+.. http:put:: /v1/repositories/(repo_name)/
109
+
110
+    Create a library repository with the given ``repo_name``.
111
+    This is a restricted feature only available to docker admins.
112
+    
113
+    When namespace is missing, it is assumed to be ``library``
114
+
115
+    **Example Request**:
116
+
117
+    .. sourcecode:: http
118
+
119
+        PUT /v1/repositories/foobar/ HTTP/1.1
120
+        Host: index.docker.io
121
+        Accept: application/json
122
+        Content-Type: application/json
123
+        Authorization: Basic akmklmasadalkm==
124
+        X-Docker-Token: true
125
+
126
+        [{“id”: “9e89cc6f0bc3c38722009fe6857087b486531f9a779a0c17e3ed29dae8f12c4f”}]
127
+
128
+    :parameter repo_name:  the library name for the repo
129
+
130
+    **Example Response**:
131
+
132
+    .. sourcecode:: http
133
+
134
+        HTTP/1.1 200
135
+        Vary: Accept
136
+        Content-Type: application/json
137
+        WWW-Authenticate: Token signature=123abc,repository=”library/foobar”,access=write
138
+        X-Docker-Endpoints: registry-1.docker.io [, registry-2.docker.io]
139
+
140
+        ""
141
+
142
+    :statuscode 200: Created
143
+    :statuscode 400: Errors (invalid json, missing or invalid fields, etc)
144
+    :statuscode 401: Unauthorized
145
+    :statuscode 403: Account is not Active
146
+
147
+.. http:delete:: /v1/repositories/(repo_name)/
148
+
149
+    Delete a library repository with the given ``repo_name``.
150
+    This is a restricted feature only available to docker admins.
151
+    
152
+    When namespace is missing, it is assumed to be ``library``
153
+
154
+    **Example Request**:
155
+
156
+    .. sourcecode:: http
157
+
158
+        DELETE /v1/repositories/foobar/ HTTP/1.1
159
+        Host: index.docker.io
160
+        Accept: application/json
161
+        Content-Type: application/json
162
+        Authorization: Basic akmklmasadalkm==
163
+        X-Docker-Token: true
164
+
165
+        ""
166
+
167
+    :parameter repo_name:  the library name for the repo
168
+
169
+    **Example Response**:
170
+
171
+    .. sourcecode:: http
172
+
173
+        HTTP/1.1 202
174
+        Vary: Accept
175
+        Content-Type: application/json
176
+        WWW-Authenticate: Token signature=123abc,repository=”library/foobar”,access=delete
177
+        X-Docker-Endpoints: registry-1.docker.io [, registry-2.docker.io]
178
+
179
+        ""
180
+
181
+    :statuscode 200: Deleted
182
+    :statuscode 202: Accepted
183
+    :statuscode 400: Errors (invalid json, missing or invalid fields, etc)
184
+    :statuscode 401: Unauthorized
185
+    :statuscode 403: Account is not Active
186
+
187
+Repository Images
188
+*****************
189
+
190
+User Repo Images
191
+~~~~~~~~~~~~~~~~
192
+
193
+.. http:put:: /v1/repositories/(namespace)/(repo_name)/images
194
+
195
+    Update the images for a user repo.
196
+
197
+    **Example Request**:
198
+
199
+    .. sourcecode:: http
200
+
201
+        PUT /v1/repositories/foo/bar/images HTTP/1.1
202
+        Host: index.docker.io
203
+        Accept: application/json
204
+        Content-Type: application/json
205
+        Authorization: Basic akmklmasadalkm==
206
+
207
+        [{“id”: “9e89cc6f0bc3c38722009fe6857087b486531f9a779a0c17e3ed29dae8f12c4f”,
208
+        “checksum”: “b486531f9a779a0c17e3ed29dae8f12c4f9e89cc6f0bc3c38722009fe6857087”}]
209
+
210
+    :parameter namespace: the namespace for the repo
211
+    :parameter repo_name: the name for the repo
212
+
213
+    **Example Response**:
214
+
215
+    .. sourcecode:: http
216
+
217
+        HTTP/1.1 204
218
+        Vary: Accept
219
+        Content-Type: application/json
220
+
221
+        ""
222
+
223
+    :statuscode 204: Created
224
+    :statuscode 400: Errors (invalid json, missing or invalid fields, etc)
225
+    :statuscode 401: Unauthorized
226
+    :statuscode 403: Account is not Active or permission denied
227
+
228
+
229
+.. http:get:: /v1/repositories/(namespace)/(repo_name)/images
230
+
231
+    get the images for a user repo.
232
+
233
+    **Example Request**:
234
+
235
+    .. sourcecode:: http
236
+
237
+        GET /v1/repositories/foo/bar/images HTTP/1.1
238
+        Host: index.docker.io
239
+        Accept: application/json
240
+
241
+    :parameter namespace: the namespace for the repo
242
+    :parameter repo_name: the name for the repo
243
+
244
+    **Example Response**:
245
+
246
+    .. sourcecode:: http
247
+
248
+        HTTP/1.1 200
249
+        Vary: Accept
250
+        Content-Type: application/json
251
+
252
+        [{“id”: “9e89cc6f0bc3c38722009fe6857087b486531f9a779a0c17e3ed29dae8f12c4f”,
253
+        “checksum”: “b486531f9a779a0c17e3ed29dae8f12c4f9e89cc6f0bc3c38722009fe6857087”},
254
+        {“id”: “ertwetewtwe38722009fe6857087b486531f9a779a0c1dfddgfgsdgdsgds”,
255
+        “checksum”: “34t23f23fc17e3ed29dae8f12c4f9e89cc6f0bsdfgfsdgdsgdsgerwgew”}]
256
+
257
+    :statuscode 200: OK
258
+    :statuscode 404: Not found
259
+
260
+Library Repo Images
261
+~~~~~~~~~~~~~~~~~~~
262
+
263
+.. http:put:: /v1/repositories/(repo_name)/images
264
+
265
+    Update the images for a library repo.
266
+
267
+    **Example Request**:
268
+
269
+    .. sourcecode:: http
270
+
271
+        PUT /v1/repositories/foobar/images HTTP/1.1
272
+        Host: index.docker.io
273
+        Accept: application/json
274
+        Content-Type: application/json
275
+        Authorization: Basic akmklmasadalkm==
276
+
277
+        [{“id”: “9e89cc6f0bc3c38722009fe6857087b486531f9a779a0c17e3ed29dae8f12c4f”,
278
+        “checksum”: “b486531f9a779a0c17e3ed29dae8f12c4f9e89cc6f0bc3c38722009fe6857087”}]
279
+
280
+    :parameter repo_name: the library name for the repo
281
+
282
+    **Example Response**:
283
+
284
+    .. sourcecode:: http
285
+
286
+        HTTP/1.1 204
287
+        Vary: Accept
288
+        Content-Type: application/json
289
+
290
+        ""
291
+
292
+    :statuscode 204: Created
293
+    :statuscode 400: Errors (invalid json, missing or invalid fields, etc)
294
+    :statuscode 401: Unauthorized
295
+    :statuscode 403: Account is not Active or permission denied
296
+
297
+
298
+.. http:get:: /v1/repositories/(repo_name)/images
299
+
300
+    get the images for a library repo.
301
+
302
+    **Example Request**:
303
+
304
+    .. sourcecode:: http
305
+
306
+        GET /v1/repositories/foobar/images HTTP/1.1
307
+        Host: index.docker.io
308
+        Accept: application/json
309
+
310
+    :parameter repo_name: the library name for the repo
311
+
312
+    **Example Response**:
313
+
314
+    .. sourcecode:: http
315
+
316
+        HTTP/1.1 200
317
+        Vary: Accept
318
+        Content-Type: application/json
319
+
320
+        [{“id”: “9e89cc6f0bc3c38722009fe6857087b486531f9a779a0c17e3ed29dae8f12c4f”,
321
+        “checksum”: “b486531f9a779a0c17e3ed29dae8f12c4f9e89cc6f0bc3c38722009fe6857087”},
322
+        {“id”: “ertwetewtwe38722009fe6857087b486531f9a779a0c1dfddgfgsdgdsgds”,
323
+        “checksum”: “34t23f23fc17e3ed29dae8f12c4f9e89cc6f0bsdfgfsdgdsgdsgerwgew”}]
324
+
325
+    :statuscode 200: OK
326
+    :statuscode 404: Not found
327
+
328
+
329
+Repository Authorization
330
+************************
331
+
332
+Library Repo
333
+~~~~~~~~~~~~
334
+
335
+.. http:put:: /v1/repositories/(repo_name)/auth
336
+
337
+    authorize a token for a library repo
338
+
339
+    **Example Request**:
340
+
341
+    .. sourcecode:: http
342
+
343
+        PUT /v1/repositories/foobar/auth HTTP/1.1
344
+        Host: index.docker.io
345
+        Accept: application/json
346
+        Authorization: Token signature=123abc,repository="library/foobar",access=write
347
+
348
+    :parameter repo_name: the library name for the repo
349
+
350
+    **Example Response**:
351
+
352
+    .. sourcecode:: http
353
+
354
+        HTTP/1.1 200
355
+        Vary: Accept
356
+        Content-Type: application/json
357
+
358
+        "OK"
359
+
360
+    :statuscode 200: OK
361
+    :statuscode 403: Permission denied
362
+    :statuscode 404: Not found
363
+
364
+
365
+User Repo
366
+~~~~~~~~~
367
+
368
+.. http:put:: /v1/repositories/(namespace)/(repo_name)/auth
369
+
370
+    authorize a token for a user repo
371
+
372
+    **Example Request**:
373
+
374
+    .. sourcecode:: http
375
+
376
+        PUT /v1/repositories/foo/bar/auth HTTP/1.1
377
+        Host: index.docker.io
378
+        Accept: application/json
379
+        Authorization: Token signature=123abc,repository="foo/bar",access=write
380
+
381
+    :parameter namespace: the namespace for the repo
382
+    :parameter repo_name: the name for the repo
383
+
384
+    **Example Response**:
385
+
386
+    .. sourcecode:: http
387
+
388
+        HTTP/1.1 200
389
+        Vary: Accept
390
+        Content-Type: application/json
391
+
392
+        "OK"
393
+
394
+    :statuscode 200: OK
395
+    :statuscode 403: Permission denied
396
+    :statuscode 404: Not found
397
+
398
+
399
+2.2 Users
400
+^^^^^^^^^
401
+
402
+User Login
403
+**********
404
+
405
+.. http:get:: /v1/users
406
+
407
+    If you want to check your login, you can try this endpoint
408
+    
409
+    **Example Request**:
410
+    
411
+    .. sourcecode:: http
412
+    
413
+        GET /v1/users HTTP/1.1
414
+        Host: index.docker.io
415
+        Accept: application/json
416
+        Authorization: Basic akmklmasadalkm==
417
+
418
+    **Example Response**:
419
+
420
+    .. sourcecode:: http
421
+
422
+        HTTP/1.1 200 OK
423
+        Vary: Accept
424
+        Content-Type: application/json
425
+
426
+        OK
427
+
428
+    :statuscode 200: no error
429
+    :statuscode 401: Unauthorized
430
+    :statuscode 403: Account is not Active
431
+
432
+
433
+User Register
434
+*************
435
+
436
+.. http:post:: /v1/users
437
+
438
+    Registering a new account.
439
+
440
+    **Example request**:
441
+
442
+    .. sourcecode:: http
443
+
444
+        POST /v1/users HTTP/1.1
445
+        Host: index.docker.io
446
+        Accept: application/json
447
+        Content-Type: application/json
448
+
449
+        {"email": "sam@dotcloud.com",
450
+         "password": "toto42",
451
+         "username": "foobar"'}
452
+
453
+    :jsonparameter email: valid email address, that needs to be confirmed
454
+    :jsonparameter username: min 4 character, max 30 characters, must match the regular expression [a-z0-9_].
455
+    :jsonparameter password: min 5 characters
456
+
457
+    **Example Response**:
458
+
459
+    .. sourcecode:: http
460
+
461
+        HTTP/1.1 201 OK
462
+        Vary: Accept
463
+        Content-Type: application/json
464
+
465
+        "User Created"
466
+
467
+    :statuscode 201: User Created
468
+    :statuscode 400: Errors (invalid json, missing or invalid fields, etc)
469
+
470
+Update User
471
+***********
472
+
473
+.. http:put:: /v1/users/(username)/
474
+
475
+    Change a password or email address for given user. If you pass in an email,
476
+    it will add it to your account, it will not remove the old one. Passwords will
477
+    be updated.
478
+
479
+    It is up to the client to verify that that password that is sent is the one that
480
+    they want. Common approach is to have them type it twice.
481
+
482
+    **Example Request**:
483
+
484
+    .. sourcecode:: http
485
+
486
+        PUT /v1/users/fakeuser/ HTTP/1.1
487
+        Host: index.docker.io
488
+        Accept: application/json
489
+        Content-Type: application/json
490
+        Authorization: Basic akmklmasadalkm==
491
+
492
+        {"email": "sam@dotcloud.com",
493
+         "password": "toto42"}
494
+
495
+    :parameter username: username for the person you want to update
496
+
497
+    **Example Response**:
498
+
499
+    .. sourcecode:: http
500
+
501
+        HTTP/1.1 204
502
+        Vary: Accept
503
+        Content-Type: application/json
504
+
505
+        ""
506
+
507
+    :statuscode 204: User Updated
508
+    :statuscode 400: Errors (invalid json, missing or invalid fields, etc)
509
+    :statuscode 401: Unauthorized
510
+    :statuscode 403: Account is not Active
511
+    :statuscode 404: User not found
512
+
513
+
514
+2.3 Search
515
+^^^^^^^^^^
516
+If you need to search the index, this is the endpoint you would use.
517
+
518
+Search
519
+******
520
+
521
+.. http:get:: /v1/search
522
+
523
+   Search the Index given a search term. It accepts :http:method:`get` only.
524
+
525
+   **Example request**:
526
+
527
+   .. sourcecode:: http
528
+
529
+      GET /v1/search?q=search_term HTTP/1.1
530
+      Host: example.com
531
+      Accept: application/json
532
+
533
+
534
+   **Example response**:
535
+
536
+   .. sourcecode:: http
537
+
538
+      HTTP/1.1 200 OK
539
+      Vary: Accept
540
+      Content-Type: application/json
541
+
542
+      {"query":"search_term",
543
+        "num_results": 2,
544
+        "results" : [
545
+           {"name": "dotcloud/base", "description": "A base ubuntu64  image..."},
546
+           {"name": "base2", "description": "A base ubuntu64  image..."},
547
+         ]
548
+       }
549
+
550
+   :query q: what you want to search for
551
+   :statuscode 200: no error
552
+   :statuscode 500: server error
0 553
deleted file mode 100644
... ...
@@ -1,43 +0,0 @@
1
-:title: Docker Index documentation
2
-:description: Documentation for docker Index
3
-:keywords: docker, index, api
4
-
5
-
6
-=======================
7
-Docker Index Search API
8
-=======================
9
-
10
-Search
11
-
12
-.. http:get:: /v1/search
13
-
14
-   Search the Index given a search term. It accepts :http:method:`get` only.
15
-
16
-   **Example request**:
17
-
18
-   .. sourcecode:: http
19
-
20
-      GET /v1/search?q=search_term HTTP/1.1
21
-      Host: example.com
22
-      Accept: application/json
23
-
24
-   **Example response**:
25
-
26
-   .. sourcecode:: http
27
-
28
-      HTTP/1.1 200 OK
29
-      Vary: Accept
30
-      Content-Type: application/json
31
-
32
-      {"query":"search_term",
33
-        "num_results": 2,
34
-        "results" : [
35
-           {"name": "dotcloud/base", "description": "A base ubuntu64  image..."},
36
-           {"name": "base2", "description": "A base ubuntu64  image..."},
37
-         ]
38
-       }
39
-
40
-   :query q: what you want to search for
41
-   :statuscode 200: no error
42
-   :statuscode 500: server error
43 1
\ No newline at end of file
... ...
@@ -1,7 +1,6 @@
1
-:title: Registry Documentation
2
-:description: Documentation for docker Registry and Registry API
3
-:keywords: docker, registry, api, index
4
-
1
+:title: Registry API
2
+:description: API Documentation for Docker Registry
3
+:keywords: API, Docker, index, registry, REST, documentation
5 4
 
6 5
 ===================
7 6
 Docker Registry API
... ...
@@ -9,29 +8,10 @@ Docker Registry API
9 9
 
10 10
 .. contents:: Table of Contents
11 11
 
12
-1. The 3 roles
13
-===============
14
-
15
-1.1 Index
16
-
17
-The Index is responsible for centralizing information about:
18
-- User accounts
19
-- Checksums of the images
20
-- Public namespaces
21
-
22
-The Index has different components:
23
-- Web UI
24
-- Meta-data store (comments, stars, list public repositories)
25
-- Authentication service
26
-- Tokenization
12
+1. Brief introduction
13
+=====================
27 14
 
28
-The index is authoritative for those information.
29
-
30
-We expect that there will be only one instance of the index, run and managed by dotCloud.
31
-
32
-1.2 Registry
15
+- This is the REST API for the Docker Registry
33 16
 - It stores the images and the graph for a set of repositories
34 17
 - It does not have user accounts data
35 18
 - It has no notion of user accounts or authorization
... ...
@@ -60,418 +40,424 @@ We expect that there will be multiple registries out there. To help to grasp the
60 60
 
61 61
 The latter would only require two new commands in docker, e.g. “registryget” and “registryput”, wrapping access to the local filesystem (and optionally doing consistency checks). Authentication and authorization are then delegated to SSH (e.g. with public keys).
62 62
 
63
-1.3 Docker
64
-
65
-On top of being a runtime for LXC, Docker is the Registry client. It supports:
66
-- Push / Pull on the registry
67
-- Client authentication on the Index
68
-
69
-2. Workflow
70
-===========
71
-
72
-2.1 Pull
73
-
74
-.. image:: /static_files/docker_pull_chart.png
75
-
76
-1. Contact the Index to know where I should download “samalba/busybox”
77
-2. Index replies:
78
-   a. “samalba/busybox” is on Registry A
79
-   b. here are the checksums for “samalba/busybox” (for all layers)
80
-   c. token
81
-3. Contact Registry A to receive the layers for “samalba/busybox” (all of them to the base image). Registry A is authoritative for “samalba/busybox” but keeps a copy of all inherited layers and serve them all from the same location.
82
-4. registry contacts index to verify if token/user is allowed to download images
83
-5. Index returns true/false lettings registry know if it should proceed or error out
84
-6. Get the payload for all layers
85
-
86
-It’s possible to run docker pull \https://<registry>/repositories/samalba/busybox. In this case, docker bypasses the Index. However the security is not guaranteed (in case Registry A is corrupted) because there won’t be any checksum checks.
87
-
88
-Currently registry redirects to s3 urls for downloads, going forward all downloads need to be streamed through the registry. The Registry will then abstract the calls to S3 by a top-level class which implements sub-classes for S3 and local storage.
89
-
90
-Token is only returned when the 'X-Docker-Token' header is sent with request.
91
-
92
-Basic Auth is required to pull private repos. Basic auth isn't required for pulling public repos, but if one is provided, it needs to be valid and for an active account.
93
-
94
-API (pulling repository foo/bar):
95
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
96
-
97
-1. (Docker -> Index) GET /v1/repositories/foo/bar/images
98
-    **Headers**:
99
-        Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==
100
-        X-Docker-Token: true
101
-    **Action**:
102
-        (looking up the foo/bar in db and gets images and checksums for that repo (all if no tag is specified, if tag, only checksums for those tags) see part 4.4.1)
103
-
104
-2. (Index -> Docker) HTTP 200 OK
105
-
106
-    **Headers**:
107
-        - Authorization: Token signature=123abc,repository=”foo/bar”,access=write
108
-        - X-Docker-Endpoints: registry.docker.io [, registry2.docker.io]
109
-    **Body**:
110
-        Jsonified checksums (see part 4.4.1)
111
-
112
-3. (Docker -> Registry) GET /v1/repositories/foo/bar/tags/latest
113
-    **Headers**:
114
-        Authorization: Token signature=123abc,repository=”foo/bar”,access=write
115
-
116
-4. (Registry -> Index) GET /v1/repositories/foo/bar/images
117
-
118
-    **Headers**:
119
-        Authorization: Token signature=123abc,repository=”foo/bar”,access=read
120
-
121
-    **Body**:
122
-        <ids and checksums in payload>
123
-
124
-    **Action**:
125
-        ( Lookup token see if they have access to pull.)
126
-
127
-        If good:
128
-            HTTP 200 OK
129
-            Index will invalidate the token
130
-        If bad:
131
-            HTTP 401 Unauthorized
132
-
133
-5. (Docker -> Registry) GET /v1/images/928374982374/ancestry
134
-    **Action**:
135
-        (for each image id returned in the registry, fetch /json + /layer)
63
+2. Endpoints
64
+============
136 65
 
137
-.. note::
138
-
139
-    If someone makes a second request, then we will always give a new token, never reuse tokens.
140
-
141
-2.2 Push
142
-
143
-.. image:: /static_files/docker_push_chart.png
144
-
145
-1. Contact the index to allocate the repository name “samalba/busybox” (authentication required with user credentials)
146
-2. If authentication works and namespace available, “samalba/busybox” is allocated and a temporary token is returned (namespace is marked as initialized in index)
147
-3. Push the image on the registry (along with the token)
148
-4. Registry A contacts the Index to verify the token (token must corresponds to the repository name)
149
-5. Index validates the token. Registry A starts reading the stream pushed by docker and store the repository (with its images)
150
-6. docker contacts the index to give checksums for upload images
151
-
152
-.. note::
153
-
154
-    **It’s possible not to use the Index at all!** In this case, a deployed version of the Registry is deployed to store and serve images. Those images are not authentified and the security is not guaranteed.
155
-
156
-.. note::
157
-
158
-    **Index can be replaced!** For a private Registry deployed, a custom Index can be used to serve and validate token according to different policies.
159
-
160
-Docker computes the checksums and submit them to the Index at the end of the push. When a repository name does not have checksums on the Index, it means that the push is in progress (since checksums are submitted at the end).
66
+2.1 Images
67
+----------
161 68
 
162
-API (pushing repos foo/bar):
163
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^
69
+Layer
70
+*****
164 71
 
165
-1. (Docker -> Index) PUT /v1/repositories/foo/bar/
166
-    **Headers**:
167
-        Authorization: Basic sdkjfskdjfhsdkjfh==
168
-        X-Docker-Token: true
72
+.. http:get:: /v1/images/(image_id)/layer 
169 73
 
170
-    **Action**::
171
-        - in index, we allocated a new repository, and set to initialized
74
+    get image layer for a given ``image_id``
172 75
 
173
-    **Body**::
174
-        (The body contains the list of images that are going to be pushed, with empty checksums. The checksums will be set at the end of the push)::
76
+    **Example Request**:
175 77
 
176
-        [{“id”: “9e89cc6f0bc3c38722009fe6857087b486531f9a779a0c17e3ed29dae8f12c4f”}]
78
+    .. sourcecode:: http
177 79
 
178
-2. (Index -> Docker) 200 Created
179
-    **Headers**:
180
-        - WWW-Authenticate: Token signature=123abc,repository=”foo/bar”,access=write
181
-        - X-Docker-Endpoints: registry.docker.io [, registry2.docker.io]
80
+        GET /v1/images/088b4505aa3adc3d35e79c031fa126b403200f02f51920fbd9b7c503e87c7a2c/layer HTTP/1.1
81
+        Host: registry-1.docker.io
82
+        Accept: application/json
83
+        Content-Type: application/json
84
+        Authorization: Token akmklmasadalkmsdfgsdgdge33
182 85
 
183
-3. (Docker -> Registry) PUT /v1/images/98765432_parent/json
184
-    **Headers**:
185
-        Authorization: Token signature=123abc,repository=”foo/bar”,access=write
86
+    :parameter image_id: the id for the layer you want to get
186 87
 
187
-4. (Registry->Index) GET /v1/repositories/foo/bar/images
188
-    **Headers**:
189
-        Authorization: Token signature=123abc,repository=”foo/bar”,access=write
190
-    **Action**::
191
-        - Index:
192
-            will invalidate the token.
193
-        - Registry:
194
-            grants a session (if token is approved) and fetches the images id
88
+    **Example Response**:
195 89
 
196
-5. (Docker -> Registry) PUT /v1/images/98765432_parent/json
197
-    **Headers**::
198
-        - Authorization: Token signature=123abc,repository=”foo/bar”,access=write
199
-        - Cookie: (Cookie provided by the Registry)
90
+    .. sourcecode:: http
200 91
 
201
-6. (Docker -> Registry) PUT /v1/images/98765432/json
202
-    **Headers**:
92
+        HTTP/1.1 200
93
+        Vary: Accept
94
+        Content-Type: application/json
203 95
         Cookie: (Cookie provided by the Registry)
204 96
 
205
-7. (Docker -> Registry) PUT /v1/images/98765432_parent/layer
206
-    **Headers**:
97
+        {
98
+            id: "088b4505aa3adc3d35e79c031fa126b403200f02f51920fbd9b7c503e87c7a2c",
99
+            parent: "aeee6396d62273d180a49c96c62e45438d87c7da4a5cf5d2be6bee4e21bc226f",
100
+            created: "2013-04-30T17:46:10.843673+03:00",
101
+            container: "8305672a76cc5e3d168f97221106ced35a76ec7ddbb03209b0f0d96bf74f6ef7",
102
+            container_config: {
103
+                Hostname: "host-test",
104
+                User: "",
105
+                Memory: 0,
106
+                MemorySwap: 0,
107
+                AttachStdin: false,
108
+                AttachStdout: false,
109
+                AttachStderr: false,
110
+                PortSpecs: null,
111
+                Tty: false,
112
+                OpenStdin: false,
113
+                StdinOnce: false,
114
+                Env: null,
115
+                Cmd: [
116
+                "/bin/bash",
117
+                "-c",
118
+                "apt-get -q -yy -f install libevent-dev"
119
+                ],
120
+                Dns: null,
121
+                Image: "imagename/blah",
122
+                Volumes: { },
123
+                VolumesFrom: ""
124
+            },
125
+            docker_version: "0.1.7"
126
+        }
127
+
128
+    :statuscode 200: OK
129
+    :statuscode 401: Requires authorization
130
+    :statuscode 404: Image not found
131
+
132
+
133
+.. http:put:: /v1/images/(image_id)/layer 
134
+
135
+    put image layer for a given ``image_id``
136
+
137
+    **Example Request**:
138
+
139
+    .. sourcecode:: http
140
+
141
+        PUT /v1/images/088b4505aa3adc3d35e79c031fa126b403200f02f51920fbd9b7c503e87c7a2c/layer HTTP/1.1
142
+        Host: registry-1.docker.io
143
+        Accept: application/json
144
+        Content-Type: application/json
145
+        Authorization: Token akmklmasadalkmsdfgsdgdge33
146
+
147
+        {
148
+            id: "088b4505aa3adc3d35e79c031fa126b403200f02f51920fbd9b7c503e87c7a2c",
149
+            parent: "aeee6396d62273d180a49c96c62e45438d87c7da4a5cf5d2be6bee4e21bc226f",
150
+            created: "2013-04-30T17:46:10.843673+03:00",
151
+            container: "8305672a76cc5e3d168f97221106ced35a76ec7ddbb03209b0f0d96bf74f6ef7",
152
+            container_config: {
153
+                Hostname: "host-test",
154
+                User: "",
155
+                Memory: 0,
156
+                MemorySwap: 0,
157
+                AttachStdin: false,
158
+                AttachStdout: false,
159
+                AttachStderr: false,
160
+                PortSpecs: null,
161
+                Tty: false,
162
+                OpenStdin: false,
163
+                StdinOnce: false,
164
+                Env: null,
165
+                Cmd: [
166
+                "/bin/bash",
167
+                "-c",
168
+                "apt-get -q -yy -f install libevent-dev"
169
+                ],
170
+                Dns: null,
171
+                Image: "imagename/blah",
172
+                Volumes: { },
173
+                VolumesFrom: ""
174
+            },
175
+            docker_version: "0.1.7"
176
+        }
177
+
178
+    :parameter image_id: the id for the layer you want to get
179
+
180
+
181
+    **Example Response**:
182
+
183
+    .. sourcecode:: http
184
+    
185
+        HTTP/1.1 200
186
+        Vary: Accept
187
+        Content-Type: application/json
188
+
189
+        ""
190
+
191
+    :statuscode 200: OK
192
+    :statuscode 401: Requires authorization
193
+    :statuscode 404: Image not found
194
+
195
+
196
+Image
197
+*****
198
+
199
+.. http:put:: /v1/images/(image_id)/json
200
+
201
+    put image for a given ``image_id``
202
+
203
+    **Example Request**:
204
+
205
+    .. sourcecode:: http
206
+
207
+        PUT /v1/images/088b4505aa3adc3d35e79c031fa126b403200f02f51920fbd9b7c503e87c7a2c/json HTTP/1.1
208
+        Host: registry-1.docker.io
209
+        Accept: application/json
210
+        Content-Type: application/json
207 211
         Cookie: (Cookie provided by the Registry)
208 212
 
209
-8. (Docker -> Registry) PUT /v1/images/98765432/layer
210
-    **Headers**:
211
-        X-Docker-Checksum: sha256:436745873465fdjkhdfjkgh
213
+        {
214
+         “id”: “088b4505aa3adc3d35e79c031fa126b403200f02f51920fbd9b7c503e87c7a2c”,
215
+         “checksum”:  “sha256:b486531f9a779a0c17e3ed29dae8f12c4f9e89cc6f0bc3c38722009fe6857087”
216
+         }
212 217
 
213
-9. (Docker -> Registry) PUT /v1/repositories/foo/bar/tags/latest
214
-    **Headers**:
215
-        Cookie: (Cookie provided by the Registry)
216
-    **Body**:
217
-        “98765432”
218
+    :parameter image_id: the id for the layer you want to get
218 219
 
219
-10. (Docker -> Index) PUT /v1/repositories/foo/bar/images
220 220
 
221
-    **Headers**:
222
-        Authorization: Basic 123oislifjsldfj==
223
-        X-Docker-Endpoints: registry1.docker.io (no validation on this right now)
221
+    **Example Response**:
224 222
 
225
-    **Body**:
226
-        (The image, id’s, tags and checksums)
223
+    .. sourcecode:: http
224
+    
225
+        HTTP/1.1 200
226
+        Vary: Accept
227
+        Content-Type: application/json
227 228
 
228
-        [{“id”: “9e89cc6f0bc3c38722009fe6857087b486531f9a779a0c17e3ed29dae8f12c4f”,
229
-        “checksum”: “b486531f9a779a0c17e3ed29dae8f12c4f9e89cc6f0bc3c38722009fe6857087”}]
229
+        ""
230 230
 
231
-    **Return** HTTP 204
231
+    :statuscode 200: OK
232
+    :statuscode 401: Requires authorization
232 233
 
233
-.. note::
234
+.. http:get:: /v1/images/(image_id)/json
234 235
 
235
-     If push fails and they need to start again, what happens in the index, there will already be a record for the namespace/name, but it will be initialized. Should we allow it, or mark as name already used? One edge case could be if someone pushes the same thing at the same time with two different shells.
236
+    get image for a given ``image_id``
236 237
 
237
-     If it's a retry on the Registry, Docker has a cookie (provided by the registry after token validation). So the Index won’t have to provide a new token.
238
+    **Example Request**:
238 239
 
239
-3. How to use the Registry in standalone mode
240
-=============================================
240
+    .. sourcecode:: http
241 241
 
242
-The Index has two main purposes (along with its fancy social features):
242
+        GET /v1/images/088b4505aa3adc3d35e79c031fa126b403200f02f51920fbd9b7c503e87c7a2c/json HTTP/1.1
243
+        Host: registry-1.docker.io
244
+        Accept: application/json
245
+        Content-Type: application/json
246
+        Cookie: (Cookie provided by the Registry)
243 247
 
244
-- Resolve short names (to avoid passing absolute URLs all the time)
245
-   - username/projectname -> \https://registry.docker.io/users/<username>/repositories/<projectname>/
246
-- Authenticate a user as a repos owner (for a central referenced repository)
248
+    :parameter image_id: the id for the layer you want to get
247 249
 
248
-3.1 Without an Index
249
-Using the Registry without the Index can be useful to store the images on a private network without having to rely on an external entity controlled by dotCloud.
250
+    **Example Response**:
250 251
 
251
-In this case, the registry will be launched in a special mode (--standalone? --no-index?). In this mode, the only thing which changes is that Registry will never contact the Index to verify a token. It will be the Registry owner responsibility to authenticate the user who pushes (or even pulls) an image using any mechanism (HTTP auth, IP based, etc...).
252
+    .. sourcecode:: http
252 253
 
253
-In this scenario, the Registry is responsible for the security in case of data corruption since the checksums are not delivered by a trusted entity.
254
+        HTTP/1.1 200
255
+        Vary: Accept
256
+        Content-Type: application/json
254 257
 
255
-As hinted previously, a standalone registry can also be implemented by any HTTP server handling GET/PUT requests (or even only GET requests if no write access is necessary).
258
+        {
259
+         “id”: “088b4505aa3adc3d35e79c031fa126b403200f02f51920fbd9b7c503e87c7a2c”,
260
+         “checksum”:  “sha256:b486531f9a779a0c17e3ed29dae8f12c4f9e89cc6f0bc3c38722009fe6857087”
261
+         }
256 262
 
257
-3.2 With an Index
263
+    :statuscode 200: OK
264
+    :statuscode 401: Requires authorization
265
+    :statuscode 404: Image not found
258 266
 
259
-The Index data needed by the Registry are simple:
260
-- Serve the checksums
261
-- Provide and authorize a Token
262 267
 
263
-In the scenario of a Registry running on a private network with the need of centralizing and authorizing, it’s easy to use a custom Index.
268
+Ancestry
269
+********
264 270
 
265
-The only challenge will be to tell Docker to contact (and trust) this custom Index. Docker will be configurable at some point to use a specific Index, it’ll be the private entity responsibility (basically the organization who uses Docker in a private environment) to maintain the Index and the Docker’s configuration among its consumers.
271
+.. http:get:: /v1/images/(image_id)/ancestry
266 272
 
267
-4. The API
268
-==========
273
+    get ancestry for an image given an ``image_id``
269 274
 
270
-The first version of the api is available here: https://github.com/jpetazzo/docker/blob/acd51ecea8f5d3c02b00a08176171c59442df8b3/docs/images-repositories-push-pull.md
275
+    **Example Request**:
271 276
 
272
-4.1 Images
277
+    .. sourcecode:: http
273 278
 
274
-The format returned in the images is not defined here (for layer and json), basically because Registry stores exactly the same kind of information as Docker uses to manage them.
275
-
276
-The format of ancestry is a line-separated list of image ids, in age order. I.e. the image’s parent is on the last line, the parent of the parent on the next-to-last line, etc.; if the image has no parent, the file is empty.
279
+        GET /v1/images/088b4505aa3adc3d35e79c031fa126b403200f02f51920fbd9b7c503e87c7a2c/ancestry HTTP/1.1
280
+        Host: registry-1.docker.io
281
+        Accept: application/json
282
+        Content-Type: application/json
283
+        Cookie: (Cookie provided by the Registry)
277 284
 
278
-GET /v1/images/<image_id>/layer
279
-PUT /v1/images/<image_id>/layer
280
-GET /v1/images/<image_id>/json
281
-PUT /v1/images/<image_id>/json
282
-GET /v1/images/<image_id>/ancestry
283
-PUT /v1/images/<image_id>/ancestry
285
+    :parameter image_id: the id for the layer you want to get
284 286
 
285
-4.2 Users
287
+    **Example Response**:
286 288
 
287
-4.2.1 Create a user (Index)
288
-^^^^^^^^^^^^^^^^^^^^^^^^^^^
289
+    .. sourcecode:: http
289 290
 
290
-POST /v1/users
291
+        HTTP/1.1 200
292
+        Vary: Accept
293
+        Content-Type: application/json
291 294
 
292
-**Body**:
293
-    {"email": "sam@dotcloud.com", "password": "toto42", "username": "foobar"'}
295
+        ["088b4502f51920fbd9b7c503e87c7a2c05aa3adc3d35e79c031fa126b403200f",
296
+         "aeee63968d87c7da4a5cf5d2be6bee4e21bc226fd62273d180a49c96c62e4543",
297
+         "bfa4c5326bc764280b0863b46a4b20d940bc1897ef9c1dfec060604bdc383280",
298
+         "6ab5893c6927c15a15665191f2c6cf751f5056d8b95ceee32e43c5e8a3648544"]
294 299
 
295
-**Validation**:
296
-    - **username** : min 4 character, max 30 characters, must match the regular expression [a-z0-9_].
297
-    - **password**: min 5 characters
300
+    :statuscode 200: OK
301
+    :statuscode 401: Requires authorization
302
+    :statuscode 404: Image not found
298 303
 
299
-**Valid**: return HTTP 200
300 304
 
301
-Errors: HTTP 400 (we should create error codes for possible errors)
302
-- invalid json
303
-- missing field
304
-- wrong format (username, password, email, etc)
305
-- forbidden name
306
-- name already exists
305
+2.2 Tags
306
+--------
307 307
 
308
-.. note::
308
+.. http:get:: /v1/repositories/(namespace)/(repository)/tags
309 309
 
310
-    A user account will be valid only if the email has been validated (a validation link is sent to the email address).
310
+    get all of the tags for the given repo.
311 311
 
312
-4.2.2 Update a user (Index)
313
-^^^^^^^^^^^^^^^^^^^^^^^^^^^
312
+    **Example Request**:
314 313
 
315
-PUT /v1/users/<username>
314
+    .. sourcecode:: http
316 315
 
317
-**Body**:
318
-    {"password": "toto"}
316
+        GET /v1/repositories/foo/bar/tags HTTP/1.1
317
+        Host: registry-1.docker.io
318
+        Accept: application/json
319
+        Content-Type: application/json
320
+        Cookie: (Cookie provided by the Registry)
319 321
 
320
-.. note::
322
+    :parameter namespace: namespace for the repo
323
+    :parameter repository: name for the repo
321 324
 
322
-    We can also update email address, if they do, they will need to reverify their new email address.
325
+    **Example Response**:
323 326
 
324
-4.2.3 Login (Index)
325
-^^^^^^^^^^^^^^^^^^^
326
-Does nothing else but asking for a user authentication. Can be used to validate credentials. HTTP Basic Auth for now, maybe change in future.
327
+    .. sourcecode:: http
327 328
 
328
-GET /v1/users
329
+        HTTP/1.1 200
330
+        Vary: Accept
331
+        Content-Type: application/json
329 332
 
330
-**Return**:
331
-    - Valid: HTTP 200
332
-    - Invalid login: HTTP 401
333
-    - Account inactive: HTTP 403 Account is not Active
333
+        {
334
+            "latest": "9e89cc6f0bc3c38722009fe6857087b486531f9a779a0c17e3ed29dae8f12c4f",
335
+            “0.1.1”:  “b486531f9a779a0c17e3ed29dae8f12c4f9e89cc6f0bc3c38722009fe6857087”
336
+        }
334 337
 
335
-4.3 Tags (Registry)
338
+    :statuscode 200: OK
339
+    :statuscode 401: Requires authorization
340
+    :statuscode 404: Repository not found
336 341
 
337
-The Registry does not know anything about users. Even though repositories are under usernames, it’s just a namespace for the registry. Allowing us to implement organizations or different namespaces per user later, without modifying the Registry’s API.
338 342
 
339
-The following naming restrictions apply:
343
+.. http:get:: /v1/repositories/(namespace)/(repository)/tags/(tag)
340 344
 
341
-- Namespaces must match the same regular expression as usernames (See 4.2.1.)
342
-- Repository names must match the regular expression [a-zA-Z0-9-_.]
345
+    get a tag for the given repo.
343 346
 
344
-4.3.1 Get all tags
345
-^^^^^^^^^^^^^^^^^^
347
+    **Example Request**:
346 348
 
347
-GET /v1/repositories/<namespace>/<repository_name>/tags
349
+    .. sourcecode:: http
348 350
 
349
-**Return**: HTTP 200
350
-    {
351
-    "latest": "9e89cc6f0bc3c38722009fe6857087b486531f9a779a0c17e3ed29dae8f12c4f",
352
-    “0.1.1”:  “b486531f9a779a0c17e3ed29dae8f12c4f9e89cc6f0bc3c38722009fe6857087”
353
-    }
351
+        GET /v1/repositories/foo/bar/tags/latest HTTP/1.1
352
+        Host: registry-1.docker.io
353
+        Accept: application/json
354
+        Content-Type: application/json
355
+        Cookie: (Cookie provided by the Registry)
354 356
 
355
-4.3.2 Read the content of a tag (resolve the image id)
356
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
357
+    :parameter namespace: namespace for the repo
358
+    :parameter repository: name for the repo
359
+    :parameter tag: name of tag you want to get
357 360
 
358
-GET /v1/repositories/<namespace>/<repo_name>/tags/<tag>
361
+    **Example Response**:
359 362
 
360
-**Return**:
361
-    "9e89cc6f0bc3c38722009fe6857087b486531f9a779a0c17e3ed29dae8f12c4f"
363
+    .. sourcecode:: http
362 364
 
363
-4.3.3 Delete a tag (registry)
364
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
365
+        HTTP/1.1 200
366
+        Vary: Accept
367
+        Content-Type: application/json
365 368
 
366
-DELETE /v1/repositories/<namespace>/<repo_name>/tags/<tag>
369
+        "9e89cc6f0bc3c38722009fe6857087b486531f9a779a0c17e3ed29dae8f12c4f"
367 370
 
368
-4.4 Images (Index)
371
+    :statuscode 200: OK
372
+    :statuscode 401: Requires authorization
373
+    :statuscode 404: Tag not found
369 374
 
370
-For the Index to “resolve” the repository name to a Registry location, it uses the X-Docker-Endpoints header. In other terms, this requests always add a “X-Docker-Endpoints” to indicate the location of the registry which hosts this repository.
375
+.. http:delete:: /v1/repositories/(namespace)/(repository)/tags/(tag)
371 376
 
372
-4.4.1 Get the images
373
-^^^^^^^^^^^^^^^^^^^^^
377
+    delete the tag for the repo
374 378
 
375
-GET /v1/repositories/<namespace>/<repo_name>/images
379
+    **Example Request**:
376 380
 
377
-**Return**: HTTP 200
378
-    [{“id”: “9e89cc6f0bc3c38722009fe6857087b486531f9a779a0c17e3ed29dae8f12c4f”, “checksum”: “md5:b486531f9a779a0c17e3ed29dae8f12c4f9e89cc6f0bc3c38722009fe6857087”}]
381
+    .. sourcecode:: http
379 382
 
383
+        DELETE /v1/repositories/foo/bar/tags/latest HTTP/1.1
384
+        Host: registry-1.docker.io
385
+        Accept: application/json
386
+        Content-Type: application/json
387
+        Cookie: (Cookie provided by the Registry)
380 388
 
381
-4.4.2 Add/update the images
382
-^^^^^^^^^^^^^^^^^^^^^^^^^^^
389
+    :parameter namespace: namespace for the repo
390
+    :parameter repository: name for the repo
391
+    :parameter tag: name of tag you want to delete
383 392
 
384
-You always add images, you never remove them.
393
+    **Example Response**:
385 394
 
386
-PUT /v1/repositories/<namespace>/<repo_name>/images
395
+    .. sourcecode:: http
387 396
 
388
-**Body**:
389
-    [ {“id”: “9e89cc6f0bc3c38722009fe6857087b486531f9a779a0c17e3ed29dae8f12c4f”, “checksum”: “sha256:b486531f9a779a0c17e3ed29dae8f12c4f9e89cc6f0bc3c38722009fe6857087”} ]
397
+        HTTP/1.1 200
398
+        Vary: Accept
399
+        Content-Type: application/json
390 400
 
391
-**Return** 204
401
+        ""
392 402
 
393
-5. Chaining Registries
394
-======================
403
+    :statuscode 200: OK
404
+    :statuscode 401: Requires authorization
405
+    :statuscode 404: Tag not found
395 406
 
396
-It’s possible to chain Registries server for several reasons:
397
-- Load balancing
398
-- Delegate the next request to another server
399 407
 
400
-When a Registry is a reference for a repository, it should host the entire images chain in order to avoid breaking the chain during the download.
408
+.. http:put:: /v1/repositories/(namespace)/(repository)/tags/(tag)
401 409
 
402
-The Index and Registry use this mechanism to redirect on one or the other.
410
+    put a tag for the given repo.
403 411
 
404
-Example with an image download:
405
-On every request, a special header can be returned:
412
+    **Example Request**:
406 413
 
407
-X-Docker-Endpoints: server1,server2
414
+    .. sourcecode:: http
408 415
 
409
-On the next request, the client will always pick a server from this list.
416
+        PUT /v1/repositories/foo/bar/tags/latest HTTP/1.1
417
+        Host: registry-1.docker.io
418
+        Accept: application/json
419
+        Content-Type: application/json
420
+        Cookie: (Cookie provided by the Registry)
410 421
 
411
-6. Authentication & Authorization
412
-=================================
422
+        “9e89cc6f0bc3c38722009fe6857087b486531f9a779a0c17e3ed29dae8f12c4f”
413 423
 
414
-6.1 On the Index
424
+    :parameter namespace: namespace for the repo
425
+    :parameter repository: name for the repo
426
+    :parameter tag: name of tag you want to add
415 427
 
416
-The Index supports both “Basic” and “Token” challenges. Usually when there is a “401 Unauthorized”, the Index replies this::
428
+    **Example Response**:
417 429
 
418
-    401 Unauthorized
419
-    WWW-Authenticate: Basic realm="auth required",Token
430
+    .. sourcecode:: http
420 431
 
421
-You have 3 options:
432
+        HTTP/1.1 200
433
+        Vary: Accept
434
+        Content-Type: application/json
422 435
 
423
-1. Provide user credentials and ask for a token
436
+        ""
424 437
 
425
-    **Header**:
426
-        - Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==
427
-        - X-Docker-Token: true
438
+    :statuscode 200: OK
439
+    :statuscode 400: Invalid data
440
+    :statuscode 401: Requires authorization
441
+    :statuscode 404: Image not found
428 442
 
429
-    In this case, along with the 200 response, you’ll get a new token (if user auth is ok):
430
-    If authorization isn't correct you get a 401 response.
431
-    If account isn't active you will get a 403 response.
443
+2.3 Repositories
444
+----------------
432 445
 
433
-    **Response**:
434
-        - 200 OK
435
-        - X-Docker-Token: Token signature=123abc,repository=”foo/bar”,access=read
446
+.. http:delete:: /v1/repositories/(namespace)/(repository)/
436 447
 
437
-2. Provide user credentials only
448
+    delete a repository
438 449
 
439
-    **Header**:
440
-        Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==
450
+    **Example Request**:
441 451
 
442
-3. Provide Token
452
+    .. sourcecode:: http
443 453
 
444
-    **Header**:
445
-        Authorization: Token signature=123abc,repository=”foo/bar”,access=read
454
+        DELETE /v1/repositories/foo/bar/ HTTP/1.1
455
+        Host: registry-1.docker.io
456
+        Accept: application/json
457
+        Content-Type: application/json
458
+        Cookie: (Cookie provided by the Registry)
446 459
 
447
-6.2 On the Registry
460
+        ""
448 461
 
449
-The Registry only supports the Token challenge::
462
+    :parameter namespace: namespace for the repo
463
+    :parameter repository: name for the repo
450 464
 
451
-    401 Unauthorized
452
-    WWW-Authenticate: Token
465
+    **Example Response**:
453 466
 
454
-The only way is to provide a token on “401 Unauthorized” responses::
467
+    .. sourcecode:: http
455 468
 
456
-    Authorization: Token signature=123abc,repository=”foo/bar”,access=read
469
+        HTTP/1.1 200
470
+        Vary: Accept
471
+        Content-Type: application/json
457 472
 
458
-Usually, the Registry provides a Cookie when a Token verification succeeded. Every time the Registry passes a Cookie, you have to pass it back the same cookie.::
473
+        ""
459 474
 
460
-    200 OK
461
-    Set-Cookie: session="wD/J7LqL5ctqw8haL10vgfhrb2Q=?foo=UydiYXInCnAxCi4=&timestamp=RjEzNjYzMTQ5NDcuNDc0NjQzCi4="; Path=/; HttpOnly
475
+    :statuscode 200: OK
476
+    :statuscode 401: Requires authorization
477
+    :statuscode 404: Repository not found
462 478
 
463
-Next request::
479
+3.0 Authorization
480
+=================
481
+This is where we describe the authorization process, including the tokens and cookies. 
464 482
 
465
-    GET /(...)
466
-    Cookie: session="wD/J7LqL5ctqw8haL10vgfhrb2Q=?foo=UydiYXInCnAxCi4=&timestamp=RjEzNjYzMTQ5NDcuNDc0NjQzCi4="
483
+TODO: add more info.
467 484
new file mode 100644
... ...
@@ -0,0 +1,569 @@
0
+:title: Registry Documentation
1
+:description: Documentation for docker Registry and Registry API
2
+:keywords: docker, registry, api, index
3
+
4
+
5
+=====================
6
+Registry & index Spec
7
+=====================
8
+
9
+.. contents:: Table of Contents
10
+
11
+1. The 3 roles
12
+===============
13
+
14
+1.1 Index
15
+---------
16
+
17
+The Index is responsible for centralizing information about:
18
+- User accounts
19
+- Checksums of the images
20
+- Public namespaces
21
+
22
+The Index has different components:
23
+- Web UI
24
+- Meta-data store (comments, stars, list public repositories)
25
+- Authentication service
26
+- Tokenization
27
+
28
+The index is authoritative for those information.
29
+
30
+We expect that there will be only one instance of the index, run and managed by dotCloud.
31
+
32
+1.2 Registry
33
+------------
34
+- It stores the images and the graph for a set of repositories
35
+- It does not have user accounts data
36
+- It has no notion of user accounts or authorization
37
+- It delegates authentication and authorization to the Index Auth service using tokens
38
+- It supports different storage backends (S3, cloud files, local FS)
39
+- It doesn’t have a local database
40
+- It will be open-sourced at some point
41
+
42
+We expect that there will be multiple registries out there. To help to grasp the context, here are some examples of registries:
43
+
44
+- **sponsor registry**: such a registry is provided by a third-party hosting infrastructure as a convenience for their customers and the docker community as a whole. Its costs are supported by the third party, but the management and operation of the registry are supported by dotCloud. It features read/write access, and delegates authentication and authorization to the Index.
45
+- **mirror registry**: such a registry is provided by a third-party hosting infrastructure but is targeted at their customers only. Some mechanism (unspecified to date) ensures that public images are pulled from a sponsor registry to the mirror registry, to make sure that the customers of the third-party provider can “docker pull” those images locally.
46
+- **vendor registry**: such a registry is provided by a software vendor, who wants to distribute docker images. It would be operated and managed by the vendor. Only users authorized by the vendor would be able to get write access. Some images would be public (accessible for anyone), others private (accessible only for authorized users). Authentication and authorization would be delegated to the Index. The goal of vendor registries is to let someone do “docker pull basho/riak1.3” and automatically push from the vendor registry (instead of a sponsor registry); i.e. get all the convenience of a sponsor registry, while retaining control on the asset distribution.
47
+- **private registry**: such a registry is located behind a firewall, or protected by an additional security layer (HTTP authorization, SSL client-side certificates, IP address authorization...). The registry is operated by a private entity, outside of dotCloud’s control. It can optionally delegate additional authorization to the Index, but it is not mandatory.
48
+
49
+.. note::
50
+
51
+    Mirror registries and private registries which do not use the Index don’t even need to run the registry code. They can be implemented by any kind of transport implementing HTTP GET and PUT. Read-only registries can be powered by a simple static HTTP server.
52
+
53
+.. note::
54
+
55
+    The latter implies that while HTTP is the protocol of choice for a registry, multiple schemes are possible (and in some cases, trivial):
56
+        - HTTP with GET (and PUT for read-write registries);
57
+        - local mount point;
58
+        - remote docker addressed through SSH.
59
+
60
+The latter would only require two new commands in docker, e.g. “registryget” and “registryput”, wrapping access to the local filesystem (and optionally doing consistency checks). Authentication and authorization are then delegated to SSH (e.g. with public keys).
61
+
62
+1.3 Docker
63
+----------
64
+
65
+On top of being a runtime for LXC, Docker is the Registry client. It supports:
66
+- Push / Pull on the registry
67
+- Client authentication on the Index
68
+
69
+2. Workflow
70
+===========
71
+
72
+2.1 Pull
73
+--------
74
+
75
+.. image:: /static_files/docker_pull_chart.png
76
+
77
+1. Contact the Index to know where I should download “samalba/busybox”
78
+2. Index replies:
79
+   a. “samalba/busybox” is on Registry A
80
+   b. here are the checksums for “samalba/busybox” (for all layers)
81
+   c. token
82
+3. Contact Registry A to receive the layers for “samalba/busybox” (all of them to the base image). Registry A is authoritative for “samalba/busybox” but keeps a copy of all inherited layers and serve them all from the same location.
83
+4. registry contacts index to verify if token/user is allowed to download images
84
+5. Index returns true/false lettings registry know if it should proceed or error out
85
+6. Get the payload for all layers
86
+
87
+It’s possible to run docker pull \https://<registry>/repositories/samalba/busybox. In this case, docker bypasses the Index. However the security is not guaranteed (in case Registry A is corrupted) because there won’t be any checksum checks.
88
+
89
+Currently registry redirects to s3 urls for downloads, going forward all downloads need to be streamed through the registry. The Registry will then abstract the calls to S3 by a top-level class which implements sub-classes for S3 and local storage.
90
+
91
+Token is only returned when the 'X-Docker-Token' header is sent with request.
92
+
93
+Basic Auth is required to pull private repos. Basic auth isn't required for pulling public repos, but if one is provided, it needs to be valid and for an active account.
94
+
95
+API (pulling repository foo/bar):
96
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
97
+
98
+1. (Docker -> Index) GET /v1/repositories/foo/bar/images
99
+    **Headers**:
100
+        Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==
101
+        X-Docker-Token: true
102
+    **Action**:
103
+        (looking up the foo/bar in db and gets images and checksums for that repo (all if no tag is specified, if tag, only checksums for those tags) see part 4.4.1)
104
+
105
+2. (Index -> Docker) HTTP 200 OK
106
+
107
+    **Headers**:
108
+        - Authorization: Token signature=123abc,repository=”foo/bar”,access=write
109
+        - X-Docker-Endpoints: registry.docker.io [, registry2.docker.io]
110
+    **Body**:
111
+        Jsonified checksums (see part 4.4.1)
112
+
113
+3. (Docker -> Registry) GET /v1/repositories/foo/bar/tags/latest
114
+    **Headers**:
115
+        Authorization: Token signature=123abc,repository=”foo/bar”,access=write
116
+
117
+4. (Registry -> Index) GET /v1/repositories/foo/bar/images
118
+
119
+    **Headers**:
120
+        Authorization: Token signature=123abc,repository=”foo/bar”,access=read
121
+
122
+    **Body**:
123
+        <ids and checksums in payload>
124
+
125
+    **Action**:
126
+        ( Lookup token see if they have access to pull.)
127
+
128
+        If good:
129
+            HTTP 200 OK
130
+            Index will invalidate the token
131
+        If bad:
132
+            HTTP 401 Unauthorized
133
+
134
+5. (Docker -> Registry) GET /v1/images/928374982374/ancestry
135
+    **Action**:
136
+        (for each image id returned in the registry, fetch /json + /layer)
137
+
138
+.. note::
139
+
140
+    If someone makes a second request, then we will always give a new token, never reuse tokens.
141
+
142
+2.2 Push
143
+--------
144
+
145
+.. image:: /static_files/docker_push_chart.png
146
+
147
+1. Contact the index to allocate the repository name “samalba/busybox” (authentication required with user credentials)
148
+2. If authentication works and namespace available, “samalba/busybox” is allocated and a temporary token is returned (namespace is marked as initialized in index)
149
+3. Push the image on the registry (along with the token)
150
+4. Registry A contacts the Index to verify the token (token must corresponds to the repository name)
151
+5. Index validates the token. Registry A starts reading the stream pushed by docker and store the repository (with its images)
152
+6. docker contacts the index to give checksums for upload images
153
+
154
+.. note::
155
+
156
+    **It’s possible not to use the Index at all!** In this case, a deployed version of the Registry is deployed to store and serve images. Those images are not authentified and the security is not guaranteed.
157
+
158
+.. note::
159
+
160
+    **Index can be replaced!** For a private Registry deployed, a custom Index can be used to serve and validate token according to different policies.
161
+
162
+Docker computes the checksums and submit them to the Index at the end of the push. When a repository name does not have checksums on the Index, it means that the push is in progress (since checksums are submitted at the end).
163
+
164
+API (pushing repos foo/bar):
165
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^
166
+
167
+1. (Docker -> Index) PUT /v1/repositories/foo/bar/
168
+    **Headers**:
169
+        Authorization: Basic sdkjfskdjfhsdkjfh==
170
+        X-Docker-Token: true
171
+
172
+    **Action**::
173
+        - in index, we allocated a new repository, and set to initialized
174
+
175
+    **Body**::
176
+        (The body contains the list of images that are going to be pushed, with empty checksums. The checksums will be set at the end of the push)::
177
+
178
+        [{“id”: “9e89cc6f0bc3c38722009fe6857087b486531f9a779a0c17e3ed29dae8f12c4f”}]
179
+
180
+2. (Index -> Docker) 200 Created
181
+    **Headers**:
182
+        - WWW-Authenticate: Token signature=123abc,repository=”foo/bar”,access=write
183
+        - X-Docker-Endpoints: registry.docker.io [, registry2.docker.io]
184
+
185
+3. (Docker -> Registry) PUT /v1/images/98765432_parent/json
186
+    **Headers**:
187
+        Authorization: Token signature=123abc,repository=”foo/bar”,access=write
188
+
189
+4. (Registry->Index) GET /v1/repositories/foo/bar/images
190
+    **Headers**:
191
+        Authorization: Token signature=123abc,repository=”foo/bar”,access=write
192
+    **Action**::
193
+        - Index:
194
+            will invalidate the token.
195
+        - Registry:
196
+            grants a session (if token is approved) and fetches the images id
197
+
198
+5. (Docker -> Registry) PUT /v1/images/98765432_parent/json
199
+    **Headers**::
200
+        - Authorization: Token signature=123abc,repository=”foo/bar”,access=write
201
+        - Cookie: (Cookie provided by the Registry)
202
+
203
+6. (Docker -> Registry) PUT /v1/images/98765432/json
204
+    **Headers**:
205
+        Cookie: (Cookie provided by the Registry)
206
+
207
+7. (Docker -> Registry) PUT /v1/images/98765432_parent/layer
208
+    **Headers**:
209
+        Cookie: (Cookie provided by the Registry)
210
+
211
+8. (Docker -> Registry) PUT /v1/images/98765432/layer
212
+    **Headers**:
213
+        X-Docker-Checksum: sha256:436745873465fdjkhdfjkgh
214
+
215
+9. (Docker -> Registry) PUT /v1/repositories/foo/bar/tags/latest
216
+    **Headers**:
217
+        Cookie: (Cookie provided by the Registry)
218
+    **Body**:
219
+        “98765432”
220
+
221
+10. (Docker -> Index) PUT /v1/repositories/foo/bar/images
222
+
223
+    **Headers**:
224
+        Authorization: Basic 123oislifjsldfj==
225
+        X-Docker-Endpoints: registry1.docker.io (no validation on this right now)
226
+
227
+    **Body**:
228
+        (The image, id’s, tags and checksums)
229
+
230
+        [{“id”: “9e89cc6f0bc3c38722009fe6857087b486531f9a779a0c17e3ed29dae8f12c4f”,
231
+        “checksum”: “b486531f9a779a0c17e3ed29dae8f12c4f9e89cc6f0bc3c38722009fe6857087”}]
232
+
233
+    **Return** HTTP 204
234
+
235
+.. note::
236
+
237
+     If push fails and they need to start again, what happens in the index, there will already be a record for the namespace/name, but it will be initialized. Should we allow it, or mark as name already used? One edge case could be if someone pushes the same thing at the same time with two different shells.
238
+
239
+     If it's a retry on the Registry, Docker has a cookie (provided by the registry after token validation). So the Index won’t have to provide a new token.
240
+
241
+2.3 Delete
242
+----------
243
+
244
+If you need to delete something from the index or registry, we need a nice clean way to do that. Here is the workflow.
245
+
246
+1. Docker contacts the index to request a delete of a repository “samalba/busybox” (authentication required with user credentials)
247
+2. If authentication works and repository is valid, “samalba/busybox” is marked as deleted and a temporary token is returned
248
+3. Send a delete request to the registry for the repository (along with the token)
249
+4. Registry A contacts the Index to verify the token (token must corresponds to the repository name)
250
+5. Index validates the token. Registry A deletes the repository and everything associated to it.
251
+6. docker contacts the index to let it know it was removed from the registry, the index removes all records from the database.
252
+
253
+.. note::
254
+
255
+    The Docker client should present an "Are you sure?" prompt to confirm the deletion before starting the process. Once it starts it can't be undone.
256
+
257
+API (deleting repository foo/bar):
258
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
259
+
260
+1. (Docker -> Index) DELETE /v1/repositories/foo/bar/
261
+    **Headers**:
262
+        Authorization: Basic sdkjfskdjfhsdkjfh==
263
+        X-Docker-Token: true
264
+
265
+    **Action**::
266
+        - in index, we make sure it is a valid repository, and set to deleted (logically)
267
+
268
+    **Body**::
269
+        Empty
270
+
271
+2. (Index -> Docker) 202 Accepted
272
+    **Headers**:
273
+        - WWW-Authenticate: Token signature=123abc,repository=”foo/bar”,access=delete
274
+        - X-Docker-Endpoints: registry.docker.io [, registry2.docker.io]   # list of endpoints where this repo lives.
275
+
276
+3. (Docker -> Registry) DELETE /v1/repositories/foo/bar/
277
+    **Headers**:
278
+        Authorization: Token signature=123abc,repository=”foo/bar”,access=delete
279
+
280
+4. (Registry->Index) PUT /v1/repositories/foo/bar/auth
281
+    **Headers**:
282
+        Authorization: Token signature=123abc,repository=”foo/bar”,access=delete
283
+    **Action**::
284
+        - Index:
285
+            will invalidate the token.
286
+        - Registry:
287
+            deletes the repository (if token is approved)
288
+
289
+5. (Registry -> Docker) 200 OK
290
+        200 If success 
291
+        403 if forbidden
292
+        400 if bad request
293
+        404 if repository isn't found
294
+
295
+6. (Docker -> Index) DELETE /v1/repositories/foo/bar/
296
+
297
+    **Headers**:
298
+        Authorization: Basic 123oislifjsldfj==
299
+        X-Docker-Endpoints: registry-1.docker.io (no validation on this right now)
300
+
301
+    **Body**:
302
+        Empty
303
+
304
+    **Return** HTTP 200
305
+
306
+
307
+3. How to use the Registry in standalone mode
308
+=============================================
309
+
310
+The Index has two main purposes (along with its fancy social features):
311
+
312
+- Resolve short names (to avoid passing absolute URLs all the time)
313
+   - username/projectname -> \https://registry.docker.io/users/<username>/repositories/<projectname>/
314
+   - team/projectname -> \https://registry.docker.io/team/<team>/repositories/<projectname>/
315
+- Authenticate a user as a repos owner (for a central referenced repository)
316
+
317
+3.1 Without an Index
318
+--------------------
319
+Using the Registry without the Index can be useful to store the images on a private network without having to rely on an external entity controlled by dotCloud.
320
+
321
+In this case, the registry will be launched in a special mode (--standalone? --no-index?). In this mode, the only thing which changes is that Registry will never contact the Index to verify a token. It will be the Registry owner responsibility to authenticate the user who pushes (or even pulls) an image using any mechanism (HTTP auth, IP based, etc...).
322
+
323
+In this scenario, the Registry is responsible for the security in case of data corruption since the checksums are not delivered by a trusted entity.
324
+
325
+As hinted previously, a standalone registry can also be implemented by any HTTP server handling GET/PUT requests (or even only GET requests if no write access is necessary).
326
+
327
+3.2 With an Index
328
+-----------------
329
+
330
+The Index data needed by the Registry are simple:
331
+- Serve the checksums
332
+- Provide and authorize a Token
333
+
334
+In the scenario of a Registry running on a private network with the need of centralizing and authorizing, it’s easy to use a custom Index.
335
+
336
+The only challenge will be to tell Docker to contact (and trust) this custom Index. Docker will be configurable at some point to use a specific Index, it’ll be the private entity responsibility (basically the organization who uses Docker in a private environment) to maintain the Index and the Docker’s configuration among its consumers.
337
+
338
+4. The API
339
+==========
340
+
341
+The first version of the api is available here: https://github.com/jpetazzo/docker/blob/acd51ecea8f5d3c02b00a08176171c59442df8b3/docs/images-repositories-push-pull.md
342
+
343
+4.1 Images
344
+----------
345
+
346
+The format returned in the images is not defined here (for layer and json), basically because Registry stores exactly the same kind of information as Docker uses to manage them.
347
+
348
+The format of ancestry is a line-separated list of image ids, in age order. I.e. the image’s parent is on the last line, the parent of the parent on the next-to-last line, etc.; if the image has no parent, the file is empty.
349
+
350
+GET /v1/images/<image_id>/layer
351
+PUT /v1/images/<image_id>/layer
352
+GET /v1/images/<image_id>/json
353
+PUT /v1/images/<image_id>/json
354
+GET /v1/images/<image_id>/ancestry
355
+PUT /v1/images/<image_id>/ancestry
356
+
357
+4.2 Users
358
+---------
359
+
360
+4.2.1 Create a user (Index)
361
+^^^^^^^^^^^^^^^^^^^^^^^^^^^
362
+
363
+POST /v1/users
364
+
365
+**Body**:
366
+    {"email": "sam@dotcloud.com", "password": "toto42", "username": "foobar"'}
367
+
368
+**Validation**:
369
+    - **username** : min 4 character, max 30 characters, must match the regular expression [a-z0-9_].
370
+    - **password**: min 5 characters
371
+
372
+**Valid**: return HTTP 200
373
+
374
+Errors: HTTP 400 (we should create error codes for possible errors)
375
+- invalid json
376
+- missing field
377
+- wrong format (username, password, email, etc)
378
+- forbidden name
379
+- name already exists
380
+
381
+.. note::
382
+
383
+    A user account will be valid only if the email has been validated (a validation link is sent to the email address).
384
+
385
+4.2.2 Update a user (Index)
386
+^^^^^^^^^^^^^^^^^^^^^^^^^^^
387
+
388
+PUT /v1/users/<username>
389
+
390
+**Body**:
391
+    {"password": "toto"}
392
+
393
+.. note::
394
+
395
+    We can also update email address, if they do, they will need to reverify their new email address.
396
+
397
+4.2.3 Login (Index)
398
+^^^^^^^^^^^^^^^^^^^
399
+Does nothing else but asking for a user authentication. Can be used to validate credentials. HTTP Basic Auth for now, maybe change in future.
400
+
401
+GET /v1/users
402
+
403
+**Return**:
404
+    - Valid: HTTP 200
405
+    - Invalid login: HTTP 401
406
+    - Account inactive: HTTP 403 Account is not Active
407
+
408
+4.3 Tags (Registry)
409
+-------------------
410
+
411
+The Registry does not know anything about users. Even though repositories are under usernames, it’s just a namespace for the registry. Allowing us to implement organizations or different namespaces per user later, without modifying the Registry’s API.
412
+
413
+The following naming restrictions apply:
414
+
415
+- Namespaces must match the same regular expression as usernames (See 4.2.1.)
416
+- Repository names must match the regular expression [a-zA-Z0-9-_.]
417
+
418
+4.3.1 Get all tags
419
+^^^^^^^^^^^^^^^^^^
420
+
421
+GET /v1/repositories/<namespace>/<repository_name>/tags
422
+
423
+**Return**: HTTP 200
424
+    {
425
+    "latest": "9e89cc6f0bc3c38722009fe6857087b486531f9a779a0c17e3ed29dae8f12c4f",
426
+    “0.1.1”:  “b486531f9a779a0c17e3ed29dae8f12c4f9e89cc6f0bc3c38722009fe6857087”
427
+    }
428
+
429
+4.3.2 Read the content of a tag (resolve the image id)
430
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
431
+
432
+GET /v1/repositories/<namespace>/<repo_name>/tags/<tag>
433
+
434
+**Return**:
435
+    "9e89cc6f0bc3c38722009fe6857087b486531f9a779a0c17e3ed29dae8f12c4f"
436
+
437
+4.3.3 Delete a tag (registry)
438
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
439
+
440
+DELETE /v1/repositories/<namespace>/<repo_name>/tags/<tag>
441
+
442
+4.4 Images (Index)
443
+------------------
444
+
445
+For the Index to “resolve” the repository name to a Registry location, it uses the X-Docker-Endpoints header. In other terms, this requests always add a “X-Docker-Endpoints” to indicate the location of the registry which hosts this repository.
446
+
447
+4.4.1 Get the images
448
+^^^^^^^^^^^^^^^^^^^^^
449
+
450
+GET /v1/repositories/<namespace>/<repo_name>/images
451
+
452
+**Return**: HTTP 200
453
+    [{“id”: “9e89cc6f0bc3c38722009fe6857087b486531f9a779a0c17e3ed29dae8f12c4f”, “checksum”: “md5:b486531f9a779a0c17e3ed29dae8f12c4f9e89cc6f0bc3c38722009fe6857087”}]
454
+
455
+
456
+4.4.2 Add/update the images
457
+^^^^^^^^^^^^^^^^^^^^^^^^^^^
458
+
459
+You always add images, you never remove them.
460
+
461
+PUT /v1/repositories/<namespace>/<repo_name>/images
462
+
463
+**Body**:
464
+    [ {“id”: “9e89cc6f0bc3c38722009fe6857087b486531f9a779a0c17e3ed29dae8f12c4f”, “checksum”: “sha256:b486531f9a779a0c17e3ed29dae8f12c4f9e89cc6f0bc3c38722009fe6857087”} ]
465
+
466
+**Return** 204
467
+
468
+4.5 Repositories
469
+----------------
470
+
471
+4.5.1 Remove a Repository (Registry)
472
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
473
+
474
+DELETE /v1/repositories/<namespace>/<repo_name>
475
+
476
+Return 200 OK
477
+
478
+4.5.2 Remove a Repository (Index)
479
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
480
+This starts the delete process. see 2.3 for more details.
481
+
482
+DELETE /v1/repositories/<namespace>/<repo_name>
483
+
484
+Return 202 OK
485
+
486
+5. Chaining Registries
487
+======================
488
+
489
+It’s possible to chain Registries server for several reasons:
490
+- Load balancing
491
+- Delegate the next request to another server
492
+
493
+When a Registry is a reference for a repository, it should host the entire images chain in order to avoid breaking the chain during the download.
494
+
495
+The Index and Registry use this mechanism to redirect on one or the other.
496
+
497
+Example with an image download:
498
+On every request, a special header can be returned:
499
+
500
+X-Docker-Endpoints: server1,server2
501
+
502
+On the next request, the client will always pick a server from this list.
503
+
504
+6. Authentication & Authorization
505
+=================================
506
+
507
+6.1 On the Index
508
+-----------------
509
+
510
+The Index supports both “Basic” and “Token” challenges. Usually when there is a “401 Unauthorized”, the Index replies this::
511
+
512
+    401 Unauthorized
513
+    WWW-Authenticate: Basic realm="auth required",Token
514
+
515
+You have 3 options:
516
+
517
+1. Provide user credentials and ask for a token
518
+
519
+    **Header**:
520
+        - Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==
521
+        - X-Docker-Token: true
522
+
523
+    In this case, along with the 200 response, you’ll get a new token (if user auth is ok):
524
+    If authorization isn't correct you get a 401 response.
525
+    If account isn't active you will get a 403 response.
526
+
527
+    **Response**:
528
+        - 200 OK
529
+        - X-Docker-Token: Token signature=123abc,repository=”foo/bar”,access=read
530
+
531
+2. Provide user credentials only
532
+
533
+    **Header**:
534
+        Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==
535
+
536
+3. Provide Token
537
+
538
+    **Header**:
539
+        Authorization: Token signature=123abc,repository=”foo/bar”,access=read
540
+
541
+6.2 On the Registry
542
+-------------------
543
+
544
+The Registry only supports the Token challenge::
545
+
546
+    401 Unauthorized
547
+    WWW-Authenticate: Token
548
+
549
+The only way is to provide a token on “401 Unauthorized” responses::
550
+
551
+    Authorization: Token signature=123abc,repository=”foo/bar”,access=read
552
+
553
+Usually, the Registry provides a Cookie when a Token verification succeeded. Every time the Registry passes a Cookie, you have to pass it back the same cookie.::
554
+
555
+    200 OK
556
+    Set-Cookie: session="wD/J7LqL5ctqw8haL10vgfhrb2Q=?foo=UydiYXInCnAxCi4=&timestamp=RjEzNjYzMTQ5NDcuNDc0NjQzCi4="; Path=/; HttpOnly
557
+
558
+Next request::
559
+
560
+    GET /(...)
561
+    Cookie: session="wD/J7LqL5ctqw8haL10vgfhrb2Q=?foo=UydiYXInCnAxCi4=&timestamp=RjEzNjYzMTQ5NDcuNDc0NjQzCi4="
562
+
563
+
564
+7.0 Document Version
565
+---------------------
566
+
567
+- 1.0 : May 6th 2013 : initial release 
568
+- 1.1 : June 1st 2013 : Added Delete Repository and way to handle new source namespace.
0 569
\ No newline at end of file
... ...
@@ -5,5 +5,5 @@
5 5
 Contributing to Docker
6 6
 ======================
7 7
 
8
-Want to hack on Docker? Awesome! The repository includes `all the instructions you need to get started <https://github.com/dotcloud/docker/blob/master/CONTRIBUTING.md>`.
8
+Want to hack on Docker? Awesome! The repository includes `all the instructions you need to get started <https://github.com/dotcloud/docker/blob/master/CONTRIBUTING.md>`_.
9 9
 
... ...
@@ -5,11 +5,35 @@
5 5
 Setting Up a Dev Environment
6 6
 ============================
7 7
 
8
-Instructions that have been verified to work on Ubuntu 12.10,
8
+Instructions that have been verified to work on Ubuntu Precise 12.04 (LTS) (64-bit),
9
+
10
+
11
+Dependencies
12
+------------
13
+
14
+**Linux kernel 3.8**
15
+
16
+Due to a bug in LXC docker works best on the 3.8 kernel. Precise comes with a 3.2 kernel, so we need to upgrade it. The kernel we install comes with AUFS built in.
17
+
9 18
 
10 19
 .. code-block:: bash
11 20
 
12
-    sudo apt-get -y install lxc wget bsdtar curl golang git
21
+   # install the backported kernel
22
+   sudo apt-get update && sudo apt-get install linux-image-generic-lts-raring
23
+
24
+   # reboot
25
+   sudo reboot
26
+
27
+
28
+Installation
29
+------------
30
+
31
+.. code-block:: bash
32
+		
33
+    sudo apt-get install python-software-properties
34
+    sudo add-apt-repository ppa:gophers/go
35
+    sudo apt-get update
36
+    sudo apt-get -y install lxc wget bsdtar curl golang-stable git
13 37
 
14 38
     export GOPATH=~/go/
15 39
     export PATH=$GOPATH/bin:$PATH
... ...
@@ -35,13 +35,16 @@ Most frequently asked questions.
35 35
 
36 36
     You can find more answers on:
37 37
 
38
-    * `IRC: docker on freenode`_
38
+    * `Docker club mailinglist`_
39
+    * `IRC, docker on freenode`_
39 40
     * `Github`_
40 41
     * `Ask questions on Stackoverflow`_
41 42
     * `Join the conversation on Twitter`_
42 43
 
44
+
45
+    .. _Docker club mailinglist: https://groups.google.com/d/forum/docker-club
43 46
     .. _the repo: http://www.github.com/dotcloud/docker
44
-    .. _IRC: docker on freenode: docker on freenode: irc://chat.freenode.net#docker
47
+    .. _IRC, docker on freenode: irc://chat.freenode.net#docker
45 48
     .. _Github: http://www.github.com/dotcloud/docker
46 49
     .. _Ask questions on Stackoverflow: http://stackoverflow.com/search?q=docker
47 50
     .. _Join the conversation on Twitter: http://twitter.com/getdocker
... ...
@@ -18,7 +18,7 @@ steps and commit them along the way, giving you a final image.
18 18
 To use Docker Builder, assemble the steps into a text file (commonly referred to
19 19
 as a Dockerfile) and supply this to `docker build` on STDIN, like so:
20 20
 
21
-    ``docker build < Dockerfile``
21
+    ``docker build - < Dockerfile``
22 22
 
23 23
 Docker will run your steps one-by-one, committing the result if necessary, 
24 24
 before finally outputting the ID of your new image.
... ...
@@ -64,14 +64,15 @@
64 64
 
65 65
             <div style="float: right" class="pull-right">
66 66
                 <ul class="nav">
67
-                    <li><a href="http://www.docker.io/">Introduction</a></li>
68
-                    <li><a href="http://www.docker.io/gettingstarted/">Getting started</a></li>
69
-                    <li class="active"><a href="http://docs.docker.io/en/latest/">Documentation</a></li>
67
+                    <li id="nav-introduction"><a href="http://www.docker.io/">Introduction</a></li>
68
+                    <li id="nav-gettingstarted"><a href="http://www.docker.io/gettingstarted/">Getting started</a></li>
69
+                    <li id="nav-documentation" class="active"><a href="http://docs.docker.io/en/latest/">Documentation</a></li>
70
+                    <li id="nav-blog"><a href="http://blog.docker.io/">Blog</a></li>
70 71
                 </ul>
71
-                <div class="social links" style="float: right; margin-top: 14px; margin-left: 12px">
72
-                    <a class="twitter" href="http://twitter.com/getdocker">Twitter</a>
73
-                    <a class="github" href="https://github.com/dotcloud/docker/">GitHub</a>
74
-                </div>
72
+                <!--<div class="social links" style="float: right; margin-top: 14px; margin-left: 12px">-->
73
+                    <!--<a class="twitter" href="http://twitter.com/getdocker">Twitter</a>-->
74
+                    <!--<a class="github" href="https://github.com/dotcloud/docker/">GitHub</a>-->
75
+                <!--</div>-->
75 76
             </div>
76 77
 
77 78
             <div style="margin-left: -12px; float: left;">
... ...
@@ -86,8 +87,13 @@
86 86
 
87 87
 <div class="container">
88 88
     <div class="row">
89
-        <div class="span12 titlebar"><h1 class="pageheader">DOCUMENTATION</h1>
89
+        <div class="span12 titlebar">
90 90
             <!--<span class="pull-right" style="margin-left: 20px; font-size: 20px">{{version}}</span>-->
91
+            <div class="pull-right" id="fork-us" style="margin-top: 16px; margin-right: 16px;">
92
+                <a  href="http://github.com/dotcloud/docker/"><img src="{{ pathto('_static/img/fork-us.png', 1) }}"> Fork us on Github</a>
93
+            </div>
94
+            <h1 class="pageheader">DOCUMENTATION</h1>
95
+
91 96
         </div>
92 97
     </div>
93 98
 
... ...
@@ -123,8 +129,14 @@
123 123
     <div class="row">
124 124
 
125 125
         <div class="span12 footer">
126
+            <div class="tbox textright forceleftmargin social links pull-right">
127
+                <a class="twitter" href="http://twitter.com/getdocker">Twitter</a>
128
+                <a class="github" href="https://github.com/dotcloud/docker/">GitHub</a>
129
+            </div>
126 130
 
127 131
             Docker is a project by <a href="http://www.dotcloud.com">dotCloud</a>
132
+
133
+
128 134
 {#            {%- if show_source and has_source and sourcename %}#}
129 135
 {#            ·#}
130 136
 {#            <a href="{{ pathto('_sources/' + sourcename, true)|e }}"#}
... ...
@@ -157,7 +169,7 @@
157 157
   <!-- script which should be loaded after everything else -->
158 158
 <script type="text/javascript">
159 159
 
160
-
160
+    // Function to make the sticky header possible
161 161
     var shiftWindow = function() {
162 162
         scrollBy(0, -70);
163 163
         console.log("window shifted")
... ...
@@ -285,6 +285,40 @@ section.header {
285 285
 .social .github {
286 286
   background-position: -59px 2px;
287 287
 }
288
+#fork-us {
289
+  /*font-family: 'Maven Pro';*/
290
+
291
+  /*font-weight: bold;*/
292
+
293
+  font-size: 12px;
294
+  /*text-transform: uppercase;*/
295
+
296
+  display: block;
297
+  padding: 0px 1em;
298
+  height: 28px;
299
+  line-height: 28px;
300
+  background-color: #43484c;
301
+  filter: progid:dximagetransform.microsoft.gradient(gradientType=0, startColorstr='#FFFF6E56', endColorstr='#FFED4F35');
302
+  background-image: -webkit-gradient(linear, 50% 0%, 50% 100%, color-stop(0%, #747474), color-stop(100%, #43484c));
303
+  background-image: -webkit-linear-gradient(top, #747474 0%, #43484c 100%);
304
+  background-image: -moz-linear-gradient(top, #747474 0%, #43484c 100%);
305
+  background-image: -o-linear-gradient(top, #747474 0%, #43484c 100%);
306
+  background-image: linear-gradient(top, #747474 0%, #43484c 100%);
307
+  border: 1px solid #43484c;
308
+  -webkit-border-radius: 4px;
309
+  -moz-border-radius: 4px;
310
+  -ms-border-radius: 4px;
311
+  -o-border-radius: 4px;
312
+  border-radius: 4px;
313
+  -webkit-box-shadow: inset rgba(255, 255, 255, 0.17) 0 1px 1px;
314
+  -moz-box-shadow: inset rgba(255, 255, 255, 0.17) 0 1px 1px;
315
+  box-shadow: inset rgba(255, 255, 255, 0.17) 0 1px 1px;
316
+  margin: 8px;
317
+}
318
+#fork-us a {
319
+  color: #faf2ee;
320
+  text-shadow: rgba(0, 0, 0, 0.3) 0px 1px 0px;
321
+}
288 322
 /* =======================
289 323
    Media size overrides
290 324
 ======================= */
... ...
@@ -325,10 +359,15 @@ section.header {
325 325
   
326 326
     padding-top: 600px;
327 327
   }
328
+  #fork-us {
329
+    display: none;
330
+  }
328 331
 }
329 332
 /* Landscape phones and down */
330 333
 @media (max-width: 480px) {
331
-  
334
+  #nav-gettingstarted {
335
+    display: none;
336
+  }
332 337
 }
333 338
 /* Misc fixes */
334 339
 table th {
... ...
@@ -391,6 +391,38 @@ section.header {
391 391
 }
392 392
 
393 393
 
394
+#fork-us {
395
+  /*font-family: 'Maven Pro';*/
396
+  /*font-weight: bold;*/
397
+  font-size: 12px;
398
+  /*text-transform: uppercase;*/
399
+  display: block;
400
+  padding: 0px 1em;
401
+  height: 28px;
402
+  line-height: 28px;
403
+  background-color: #43484c;
404
+  filter: progid:DXImageTransform.Microsoft.gradient(gradientType=0, startColorstr='#FFFF6E56', endColorstr='#FFED4F35');
405
+  background-image: -webkit-gradient(linear, 50% 0%, 50% 100%, color-stop(0%, #747474), color-stop(100%, #43484c));
406
+  background-image: -webkit-linear-gradient(top, #747474 0%, #43484c 100%);
407
+  background-image: -moz-linear-gradient(top, #747474 0%, #43484c 100%);
408
+  background-image: -o-linear-gradient(top, #747474 0%, #43484c 100%);
409
+  background-image: linear-gradient(top, #747474 0%, #43484c 100%);
410
+  border: 1px solid #43484c;
411
+  -webkit-border-radius: 4px;
412
+  -moz-border-radius: 4px;
413
+  -ms-border-radius: 4px;
414
+  -o-border-radius: 4px;
415
+  border-radius: 4px;
416
+  -webkit-box-shadow: inset rgba(255, 255, 255, 0.17) 0 1px 1px;
417
+  -moz-box-shadow: inset rgba(255, 255, 255, 0.17) 0 1px 1px;
418
+  box-shadow: inset rgba(255, 255, 255, 0.17) 0 1px 1px;
419
+  margin: 8px;
420
+
421
+  a {
422
+    color: #faf2ee;
423
+    text-shadow: rgba(0, 0, 0, 0.3) 0px 1px 0px;
424
+  }
425
+}
394 426
 /* =======================
395 427
    Media size overrides
396 428
 ======================= */
... ...
@@ -441,14 +473,17 @@ section.header {
441 441
   /* TODO: Fix this to be relative to the navigation size */
442 442
     padding-top: 600px;
443 443
   }
444
-
444
+  #fork-us {
445
+    display: none;
446
+  }
445 447
 }
446 448
 
447 449
 
448 450
 /* Landscape phones and down */
449 451
 @media (max-width: 480px) {
450
-
451
-
452
+  #nav-gettingstarted {
453
+    display: none;
454
+  }
452 455
 }
453 456
 
454 457
 /* Misc fixes */
... ...
@@ -34,15 +34,11 @@
34 34
 
35 35
             <div style="float: right" class="pull-right">
36 36
                 <ul class="nav">
37
-                    <li><a href="../">Introduction</a></li>
38
-                    <li class="active"><a href="">Getting started</a></li>
39
-                    <li class=""><a href="http://docs.docker.io/en/latest/">Documentation</a></li>
37
+                    <li id="nav-introduction"><a href="../">Introduction</a></li>
38
+                    <li id="nav-gettingstarted" class="active"><a href="">Getting started</a></li>
39
+                    <li id="nav-documentation" class=""><a href="http://docs.docker.io/en/latest/">Documentation</a></li>
40
+                    <li id="nav-blog"><a href="http://blog.docker.io/">Blog</a></li>
40 41
                 </ul>
41
-
42
-                <div class="social links" style="float: right; margin-top: 14px; margin-left: 12px">
43
-                    <a class="twitter" href="http://twitter.com/getdocker">Twitter</a>
44
-                    <a class="github" href="https://github.com/dotcloud/docker/">GitHub</a>
45
-                </div>
46 42
             </div>
47 43
 
48 44
             <div style="margin-left: -12px; float: left;">
... ...
@@ -55,8 +51,16 @@
55 55
 
56 56
 <div class="container">
57 57
     <div class="row">
58
-        <div class="span12 titlebar"><h1 class="pageheader">GETTING STARTED</h1>
58
+
59
+        <div class="span12 titlebar">
60
+
61
+            <div class="pull-right" id="fork-us" style="margin-top: 16px; margin-right: 16px;">
62
+                <a  href="http://github.com/dotcloud/docker/"><img src="../static/img/fork-us.png"> Fork us on Github</a>
63
+            </div>
64
+
65
+            <h1 class="pageheader"> GETTING STARTED</h1>
59 66
         </div>
67
+
60 68
     </div>
61 69
 
62 70
 </div>
... ...
@@ -172,7 +176,10 @@
172 172
     <footer id="footer" class="footer">
173 173
         <div class="row">
174 174
             <div class="span12 social">
175
-
175
+                <div class="tbox textright forceleftmargin social links pull-right">
176
+                    <a class="twitter" href="http://twitter.com/getdocker">Twitter</a>
177
+                    <a class="github" href="https://github.com/dotcloud/docker/">GitHub</a>
178
+                </div>
176 179
                 Docker is a project by <a href="http://www.dotcloud.com">dotCloud</a>
177 180
 
178 181
             </div>
... ...
@@ -44,9 +44,18 @@
44 44
         .debug {
45 45
             border: 1px red dotted;
46 46
         }
47
+        .twitterblock {
48
+            min-height: 75px;
49
+        }
50
+
51
+        .twitterblock img {
52
+            float: left;
53
+            margin-right: 10px;
54
+        }
47 55
 
48 56
     </style>
49 57
 
58
+
50 59
 </head>
51 60
 
52 61
 
... ...
@@ -56,17 +65,18 @@
56 56
     <div class="navbar-dotcloud">
57 57
         <div class="container" style="text-align: center;">
58 58
 
59
+
60
+            <div class="pull-left" id="fork-us" style="margin-top: 16px;">
61
+                <a  href="http://github.com/dotcloud/docker/"><img src="static/img/fork-us.png" alt="fork-icon"> Fork us on Github</a>
62
+            </div>
63
+
59 64
             <div class="pull-right" >
60 65
                 <ul class="nav">
61
-                    <li class="active"><a href="/">Introduction</a></li>
62
-                    <li ><a href="gettingstarted">Getting started</a></li>
63
-                    <li class=""><a href="http://docs.docker.io/en/latest/">Documentation</a></li>
66
+                    <li id="nav-introduction" class="active"><a href="/">Introduction</a></li>
67
+                    <li id="nav-gettingstarted"><a href="gettingstarted">Getting started</a></li>
68
+                    <li id="nav-documentation" class=""><a href="http://docs.docker.io/en/latest/">Documentation</a></li>
69
+                    <li id="nav-blog"><a href="http://blog.docker.io/">Blog</a></li>
64 70
                 </ul>
65
-
66
-                <div class="social links" style="float: right; margin-top: 14px; margin-left: 12px">
67
-                    <a class="twitter" href="http://twitter.com/getdocker">Twitter</a>
68
-                    <a class="github" href="https://github.com/dotcloud/docker/">GitHub</a>
69
-                </div>
70 71
             </div>
71 72
         </div>
72 73
     </div>
... ...
@@ -81,7 +91,7 @@
81 81
 
82 82
                 <div class="span5" style="margin-bottom: 15px;">
83 83
                     <div style="text-align: center;" >
84
-                        <img src="static/img/docker_letters_500px.png">
84
+                        <img src="static/img/docker_letters_500px.png" alt="docker letters">
85 85
 
86 86
                         <h2>The Linux container engine</h2>
87 87
                     </div>
... ...
@@ -130,7 +140,7 @@
130 130
             <section class="contentblock">
131 131
                 <div class="container">
132 132
                 <div class="span2" style="margin-left: 0" >
133
-                    <a href="http://dotcloud.theresumator.com/apply/mWjkD4/Software-Engineer.html" title="Job description"><img src="static/img/hiring_graphic.png" width="140px" style="margin-top: 25px"></a>
133
+                    <a href="http://dotcloud.theresumator.com/apply/mWjkD4/Software-Engineer.html" title="Job description"><img src="static/img/hiring_graphic.png" alt="we're hiring" width="140" style="margin-top: 25px"></a>
134 134
                 </div>
135 135
                 <div class="span4" style="margin-left: 0">
136 136
                     <h4>Do you think it is cool to hack on docker? Join us!</h4>
... ...
@@ -156,7 +166,7 @@
156 156
                     </div>
157 157
                 </a>
158 158
                 &nbsp;
159
-                <input type="button" class="searchbutton" type="submit" value="Search images"
159
+                <input type="button" class="searchbutton" value="Search images"
160 160
                        onClick="window.open('https://index.docker.io')" />
161 161
 
162 162
             </section>
... ...
@@ -184,32 +194,19 @@
184 184
 
185 185
 </div>
186 186
 
187
-<style>
188
-    .twitterblock {
189
-        min-height: 75px;
190
-    }
191
-
192
-    .twitterblock img {
193
-        float: left;
194
-        margin-right: 10px;
195
-    }
196
-
197
-</style>
198
-
199
-
200 187
 <div class="container">
201 188
 
202 189
     <div class="row">
203 190
         <div class="span6">
204 191
             <section class="contentblock twitterblock">
205 192
                 <img src="https://si0.twimg.com/profile_images/2707460527/252a64411a339184ff375a96fb68dcb0_bigger.png">
206
-                <em>Mitchell Hashimoto‏@mitchellh:</em> Docker launched today. It is incredible. They’re also working RIGHT NOW on a Vagrant provider. LXC is COMING!!
193
+                <em>Mitchell Hashimoto ‏@mitchellh:</em> Docker launched today. It is incredible. They’re also working RIGHT NOW on a Vagrant provider. LXC is COMING!!
207 194
             </section>
208 195
         </div>
209 196
         <div class="span6">
210 197
             <section class="contentblock twitterblock">
211 198
                 <img src="https://si0.twimg.com/profile_images/1108290260/Adam_Jacob-114x150_original_bigger.jpg">
212
-                <em>Adam Jacob‏@adamhjk:</em> Docker is clearly the right idea. @solomonstre absolutely killed it. Containerized app deployment is the future, I think.
199
+                <em>Adam Jacob ‏@adamhjk:</em> Docker is clearly the right idea. @solomonstre absolutely killed it. Containerized app deployment is the future, I think.
213 200
             </section>
214 201
         </div>
215 202
     </div>
... ...
@@ -217,13 +214,13 @@
217 217
         <div class="span6">
218 218
             <section class="contentblock twitterblock">
219 219
                 <img src="https://si0.twimg.com/profile_images/14872832/twitter_pic_bigger.jpg">
220
-                <em>Matt Townsend‏@mtownsend:</em> I have a serious code crush on docker.io - it's Lego for PaaS. Motherfucking awesome Lego.
220
+                <em>Matt Townsend ‏@mtownsend:</em> I have a serious code crush on docker.io - it's Lego for PaaS. Motherfucking awesome Lego.
221 221
             </section>
222 222
         </div>
223 223
         <div class="span6">
224 224
             <section class="contentblock twitterblock">
225 225
                 <img src="https://si0.twimg.com/profile_images/1312352395/rupert-259x300_bigger.jpg">
226
-                <em>Rob Harrop‏@robertharrop:</em> Impressed by @getdocker - it's all kinds of magic. Serious rethink of AWS architecture happening @skillsmatter.
226
+                <em>Rob Harrop ‏@robertharrop:</em> Impressed by @getdocker - it's all kinds of magic. Serious rethink of AWS architecture happening @skillsmatter.
227 227
             </section>
228 228
         </div>
229 229
     </div>
... ...
@@ -317,7 +314,10 @@
317 317
     <footer id="footer" class="footer">
318 318
         <div class="row">
319 319
             <div class="span12">
320
-
320
+                <div class="tbox textright forceleftmargin social links pull-right">
321
+                    <a class="twitter" href="http://twitter.com/getdocker">Twitter</a>
322
+                    <a class="github" href="https://github.com/dotcloud/docker/">GitHub</a>
323
+                </div>
321 324
                 Docker is a project by <a href="http://www.dotcloud.com">dotCloud</a>
322 325
 
323 326
             </div>
324 327
new file mode 100644
... ...
@@ -0,0 +1,19 @@
0
+# Docker principles
1
+
2
+In the design and development of Docker we try to follow these principles:
3
+
4
+(Work in progress)
5
+
6
+* Don't try to replace every tool. Instead, be an ingredient to improve them.
7
+* Less code is better.
8
+* Less components is better. Do you really need to add one more class?
9
+* 50 lines of straightforward, readable code is better than 10 lines of magic that nobody can understand.
10
+* Don't do later what you can do now. "//FIXME: refactor" is not acceptable in new code.
11
+* When hesitating between 2 options, choose the one that is easier to reverse.
12
+* No is temporary, Yes is forever. If you're not sure about a new feature, say no. You can change your mind later.
13
+* Containers must be portable to the greatest possible number of machines. Be suspicious of any change which makes machines less interchangeable.
14
+* The less moving parts in a container, the better.
15
+* Don't merge it unless you document it.
16
+* Don't document it unless you can keep it up-to-date.
17
+* Don't merge it unless you test it!
18
+* Everyone's problem is slightly different. Focus on the part that is the same for everyone, and solve that.
0 19
new file mode 100644
... ...
@@ -0,0 +1,88 @@
0
+# Docker: what's next?
1
+
2
+This document is a high-level overview of where we want to take Docker next.
3
+It is a curated selection of planned improvements which are either important, difficult, or both.
4
+
5
+For a more complete view of planned and requested improvements, see [the Github issues](https://github.com/dotcloud/docker/issues).
6
+
7
+Tu suggest changes to the roadmap, including additions, please write the change as if it were already in effect, and make a pull request.
8
+
9
+Broader kernel support
10
+----------------------
11
+
12
+Our goal is to make Docker run everywhere, but currently Docker requires [Linux version 3.8 or higher with lxc and aufs support](http://docs.docker.io/en/latest/installation/kernel.html). If you're deploying new machines for the purpose of running Docker, this is a fairly easy requirement to meet.
13
+However, if you're adding Docker to an existing deployment, you may not have the flexibility to update and patch the kernel.
14
+
15
+Expanding Docker's kernel support is a priority. This includes running on older kernel versions,
16
+but also on kernels with no AUFS support, or with incomplete lxc capabilities.
17
+
18
+
19
+Cross-architecture support
20
+--------------------------
21
+
22
+Our goal is to make Docker run everywhere. However currently Docker only runs on x86_64 systems.
23
+We plan on expanding architecture support, so that Docker containers can be created and used on more architectures.
24
+
25
+
26
+Even more integrations
27
+----------------------
28
+
29
+We want Docker to be the secret ingredient that makes your existing tools more awesome.
30
+Thanks to this philosophy, Docker has already been integrated with
31
+[Puppet](http://forge.puppetlabs.com/garethr/docker),  [Chef](http://www.opscode.com/chef),
32
+[Openstack Nova](https://github.com/dotcloud/openstack-docker), [Jenkins](https://github.com/georgebashi/jenkins-docker-plugin),
33
+[DotCloud sandbox](http://github.com/dotcloud/sandbox), [Pallet](https://github.com/pallet/pallet-docker),
34
+[Strider CI](http://blog.frozenridge.co/next-generation-continuous-integration-deployment-with-dotclouds-docker-and-strider/)
35
+and even [Heroku buildpacks](https://github.com/progrium/buildstep).
36
+
37
+Expect Docker to integrate with even more of your favorite tools going forward, including:
38
+
39
+* Alternative storage backends such as ZFS, LVM or [BTRFS](github.com/dotcloud/docker/issues/443)
40
+* Alternative containerization backends such as [OpenVZ](http://openvz.org), Solaris Zones, BSD Jails and even plain Chroot.
41
+* Process managers like [Supervisord](http://supervisord.org/), [Runit](http://smarden.org/runit/), [Gaffer](https://gaffer.readthedocs.org/en/latest/#gaffer) and [Systemd](http://www.freedesktop.org/wiki/Software/systemd/)
42
+* Build and integration tools like Make, Maven, Scons, Jenkins, Buildbot and Cruise Control.
43
+* Configuration management tools like [Puppet](http://puppetlabs.com), [Chef](http://www.opscode.com/chef/) and [Salt](http://saltstack.org)
44
+* Personal development environments like [Vagrant](http://vagrantup.com), [Boxen](http://boxen.github.com/), [Koding](http://koding.com) and [Cloud9](http://c9.io).
45
+* Orchestration tools like [Zookeeper](http://zookeeper.apache.org/), [Mesos](http://incubator.apache.org/mesos/) and [Galaxy](https://github.com/ning/galaxy)
46
+* Infrastructure deployment tools like [Openstack](http://openstack.org), [Apache Cloudstack](http://apache.cloudstack.org), [Ganeti](https://code.google.com/p/ganeti/)
47
+
48
+
49
+Plugin API
50
+----------
51
+
52
+We want Docker to run everywhere, and to integrate with every devops tool.
53
+Those are ambitious goals, and the only way to reach them is with the Docker community.
54
+For the community to participate fully, we need an API which allows Docker to be deeply and easily customized.
55
+
56
+We are working on a plugin API which will make Docker very, very customization-friendly.
57
+We believe it will facilitate the integrations listed above - and many more we didn't even think about.
58
+
59
+Let us know if you want to start playing with the API before it's generally available.
60
+
61
+
62
+Externally mounted volumes
63
+--------------------------
64
+
65
+In 0.3 we [introduced data volumes](https://github.com/dotcloud/docker/wiki/Docker-0.3.0-release-note%2C-May-6-2013#data-volumes),
66
+a great mechanism for manipulating persistent data such as database files, log files, etc.
67
+
68
+Data volumes can be shared between containers, a powerful capability [which allows many advanced use cases](http://docs.docker.io/en/latest/examples/couchdb_data_volumes.html). In the future it will also be possible to share volumes between a container and the underlying host. This will make certain scenarios much easier, such as using a high-performance storage backend for your production database,
69
+making live development changes available to a container, etc.
70
+
71
+
72
+Better documentation
73
+--------------------
74
+
75
+We believe that great documentation is worth 10 features. We are often told that "Docker's documentation is great for a 2-month old project".
76
+Our goal is to make it great, period.
77
+
78
+If you have feedback on how to improve our documentation, please get in touch by replying to this email,
79
+or by [filing an issue](https://github.com/dotcloud/docker/issues). We always appreciate it!
80
+
81
+
82
+Production-ready
83
+----------------
84
+
85
+Docker is still alpha software, and not suited for production.
86
+We are working hard to get there, and we are confident that it will be possible within a few months.
87
+
0 88
new file mode 100644
... ...
@@ -0,0 +1 @@
0
+Daniel Mizyrycki <daniel@dotcloud.com>
... ...
@@ -485,20 +485,38 @@ type Nat struct {
485 485
 
486 486
 func parseNat(spec string) (*Nat, error) {
487 487
 	var nat Nat
488
-	// If spec starts with ':', external and internal ports must be the same.
489
-	// This might fail if the requested external port is not available.
490
-	var sameFrontend bool
491
-	if spec[0] == ':' {
492
-		sameFrontend = true
493
-		spec = spec[1:]
494
-	}
495
-	port, err := strconv.ParseUint(spec, 10, 16)
496
-	if err != nil {
497
-		return nil, err
498
-	}
499
-	nat.Backend = int(port)
500
-	if sameFrontend {
501
-		nat.Frontend = nat.Backend
488
+
489
+	if strings.Contains(spec, ":") {
490
+		specParts := strings.Split(spec, ":")
491
+		if len(specParts) != 2 {
492
+			return nil, fmt.Errorf("Invalid port format.")
493
+		}
494
+		// If spec starts with ':', external and internal ports must be the same.
495
+		// This might fail if the requested external port is not available.
496
+		var sameFrontend bool
497
+		if len(specParts[0]) == 0 {
498
+			sameFrontend = true
499
+		} else {
500
+			front, err := strconv.ParseUint(specParts[0], 10, 16)
501
+			if err != nil {
502
+				return nil, err
503
+			}
504
+			nat.Frontend = int(front)
505
+		}
506
+		back, err := strconv.ParseUint(specParts[1], 10, 16)
507
+		if err != nil {
508
+			return nil, err
509
+		}
510
+		nat.Backend = int(back)
511
+		if sameFrontend {
512
+			nat.Frontend = nat.Backend
513
+		}
514
+	} else {
515
+		port, err := strconv.ParseUint(spec, 10, 16)
516
+		if err != nil {
517
+			return nil, err
518
+		}
519
+		nat.Backend = int(port)
502 520
 	}
503 521
 	nat.Proto = "tcp"
504 522
 	return &nat, nil
... ...
@@ -18,6 +18,32 @@ func TestIptables(t *testing.T) {
18 18
 	}
19 19
 }
20 20
 
21
+func TestParseNat(t *testing.T) {
22
+	if nat, err := parseNat("4500"); err == nil {
23
+		if nat.Frontend != 0 || nat.Backend != 4500 {
24
+			t.Errorf("-p 4500 should produce 0->4500, got %d->%d", nat.Frontend, nat.Backend)
25
+		}
26
+	} else {
27
+		t.Fatal(err)
28
+	}
29
+
30
+	if nat, err := parseNat(":4501"); err == nil {
31
+		if nat.Frontend != 4501 || nat.Backend != 4501 {
32
+			t.Errorf("-p :4501 should produce 4501->4501, got %d->%d", nat.Frontend, nat.Backend)
33
+		}
34
+	} else {
35
+		t.Fatal(err)
36
+	}
37
+
38
+	if nat, err := parseNat("4502:4503"); err == nil {
39
+		if nat.Frontend != 4502 || nat.Backend != 4503 {
40
+			t.Errorf("-p 4502:4503 should produce 4502->4503, got %d->%d", nat.Frontend, nat.Backend)
41
+		}
42
+	} else {
43
+		t.Fatal(err)
44
+	}
45
+}
46
+
21 47
 func TestPortAllocation(t *testing.T) {
22 48
 	allocator, err := newPortAllocator()
23 49
 	if err != nil {
... ...
@@ -63,9 +63,6 @@ func (srv *Server) ImagesSearch(term string) ([]APISearch, error) {
63 63
 	for _, repo := range results.Results {
64 64
 		var out APISearch
65 65
 		out.Description = repo["description"]
66
-		if len(out.Description) > 45 {
67
-			out.Description = utils.Trunc(out.Description, 42) + "..."
68
-		}
69 66
 		out.Name = repo["name"]
70 67
 		outs = append(outs, out)
71 68
 	}
... ...
@@ -330,8 +327,8 @@ func (srv *Server) pullImage(r *registry.Registry, out io.Writer, imgId, endpoin
330 330
 	return nil
331 331
 }
332 332
 
333
-func (srv *Server) pullRepository(r *registry.Registry, out io.Writer, remote, askedTag string, sf *utils.StreamFormatter) error {
334
-	out.Write(sf.FormatStatus("Pulling repository %s from %s", remote, auth.IndexServerAddress()))
333
+func (srv *Server) pullRepository(r *registry.Registry, out io.Writer, local, remote, askedTag string, sf *utils.StreamFormatter) error {
334
+	out.Write(sf.FormatStatus("Pulling repository %s from %s", local, auth.IndexServerAddress()))
335 335
 	repoData, err := r.GetRepositoryData(remote)
336 336
 	if err != nil {
337 337
 		return err
... ...
@@ -358,7 +355,7 @@ func (srv *Server) pullRepository(r *registry.Registry, out io.Writer, remote, a
358 358
 		// Otherwise, check that the tag exists and use only that one
359 359
 		id, exists := tagsList[askedTag]
360 360
 		if !exists {
361
-			return fmt.Errorf("Tag %s not found in repositoy %s", askedTag, remote)
361
+			return fmt.Errorf("Tag %s not found in repositoy %s", askedTag, local)
362 362
 		}
363 363
 		repoData.ImgList[id].Tag = askedTag
364 364
 	}
... ...
@@ -386,7 +383,7 @@ func (srv *Server) pullRepository(r *registry.Registry, out io.Writer, remote, a
386 386
 		if askedTag != "" && tag != askedTag {
387 387
 			continue
388 388
 		}
389
-		if err := srv.runtime.repositories.Set(remote, tag, id, true); err != nil {
389
+		if err := srv.runtime.repositories.Set(local, tag, id, true); err != nil {
390 390
 			return err
391 391
 		}
392 392
 	}
... ...
@@ -406,8 +403,12 @@ func (srv *Server) ImagePull(name, tag, endpoint string, out io.Writer, sf *util
406 406
 		}
407 407
 		return nil
408 408
 	}
409
-
410
-	if err := srv.pullRepository(r, out, name, tag, sf); err != nil {
409
+	remote := name
410
+	parts := strings.Split(name, "/")
411
+	if len(parts) > 2 {
412
+		remote = fmt.Sprintf("src/%s", url.QueryEscape(strings.Join(parts, "/")))
413
+	}
414
+	if err := srv.pullRepository(r, out, name, remote, tag, sf); err != nil {
411 415
 		return err
412 416
 	}
413 417
 
... ...
@@ -489,7 +490,13 @@ func (srv *Server) pushRepository(r *registry.Registry, out io.Writer, name stri
489 489
 	}
490 490
 	out.Write(sf.FormatStatus("Sending image list"))
491 491
 
492
-	repoData, err := r.PushImageJSONIndex(name, imgList, false)
492
+	srvName := name
493
+	parts := strings.Split(name, "/")
494
+	if len(parts) > 2 {
495
+		srvName = fmt.Sprintf("src/%s", url.QueryEscape(strings.Join(parts, "/")))
496
+	}
497
+
498
+	repoData, err := r.PushImageJSONIndex(srvName, imgList, false)
493 499
 	if err != nil {
494 500
 		return err
495 501
 	}
... ...
@@ -506,14 +513,14 @@ func (srv *Server) pushRepository(r *registry.Registry, out io.Writer, name stri
506 506
 				// FIXME: Continue on error?
507 507
 				return err
508 508
 			}
509
-			out.Write(sf.FormatStatus("Pushing tags for rev [%s] on {%s}", elem.ID, ep+"/users/"+name+"/"+elem.Tag))
510
-			if err := r.PushRegistryTag(name, elem.ID, elem.Tag, ep, repoData.Tokens); err != nil {
509
+			out.Write(sf.FormatStatus("Pushing tags for rev [%s] on {%s}", elem.ID, ep+"/users/"+srvName+"/"+elem.Tag))
510
+			if err := r.PushRegistryTag(srvName, elem.ID, elem.Tag, ep, repoData.Tokens); err != nil {
511 511
 				return err
512 512
 			}
513 513
 		}
514 514
 	}
515 515
 
516
-	if _, err := r.PushImageJSONIndex(name, imgList, true); err != nil {
516
+	if _, err := r.PushImageJSONIndex(srvName, imgList, true); err != nil {
517 517
 		return err
518 518
 	}
519 519
 	return nil
... ...
@@ -869,7 +876,7 @@ func (srv *Server) ImageInspect(name string) (*Image, error) {
869 869
 	return nil, fmt.Errorf("No such image: %s", name)
870 870
 }
871 871
 
872
-func NewServer(autoRestart bool) (*Server, error) {
872
+func NewServer(autoRestart, enableCors bool) (*Server, error) {
873 873
 	if runtime.GOARCH != "amd64" {
874 874
 		log.Fatalf("The docker runtime currently only supports amd64 (not %s). This will change in the future. Aborting.", runtime.GOARCH)
875 875
 	}
... ...
@@ -878,12 +885,14 @@ func NewServer(autoRestart bool) (*Server, error) {
878 878
 		return nil, err
879 879
 	}
880 880
 	srv := &Server{
881
-		runtime: runtime,
881
+		runtime:    runtime,
882
+		enableCors: enableCors,
882 883
 	}
883 884
 	runtime.srv = srv
884 885
 	return srv, nil
885 886
 }
886 887
 
887 888
 type Server struct {
888
-	runtime *Runtime
889
+	runtime    *Runtime
890
+	enableCors bool
889 891
 }