Hard code root entity name
Remove test from Dockerfile
Name sure container names work across commands
... | ... |
@@ -40,7 +40,7 @@ run curl -s https://go.googlecode.com/files/go1.2rc1.src.tar.gz | tar -v -C /usr |
40 | 40 |
env PATH /usr/local/go/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin |
41 | 41 |
env GOPATH /go:/go/src/github.com/dotcloud/docker/vendor |
42 | 42 |
run cd /usr/local/go/src && ./make.bash && go install -ldflags '-w -linkmode external -extldflags "-static -Wl,--unresolved-symbols=ignore-in-shared-libs"' -tags netgo -a std |
43 |
-run cd /tmp && echo 'package main' > t.go && go test -a -i -v |
|
43 |
+ |
|
44 | 44 |
# Ubuntu stuff |
45 | 45 |
run apt-get install -y -q ruby1.9.3 rubygems libffi-dev |
46 | 46 |
run gem install --no-rdoc --no-ri fpm |
... | ... |
@@ -806,6 +806,7 @@ func wsContainersAttach(srv *Server, version float64, w http.ResponseWriter, r * |
806 | 806 |
return fmt.Errorf("Missing parameter") |
807 | 807 |
} |
808 | 808 |
name := vars["name"] |
809 |
+ name = decodeName(name) |
|
809 | 810 |
|
810 | 811 |
if _, err := srv.ContainerInspect(name); err != nil { |
811 | 812 |
return err |
... | ... |
@@ -828,6 +829,7 @@ func getContainersByName(srv *Server, version float64, w http.ResponseWriter, r |
828 | 828 |
return fmt.Errorf("Missing parameter") |
829 | 829 |
} |
830 | 830 |
name := vars["name"] |
831 |
+ name = decodeName(name) |
|
831 | 832 |
|
832 | 833 |
container, err := srv.ContainerInspect(name) |
833 | 834 |
if err != nil { |
... | ... |
@@ -537,8 +537,8 @@ func (cli *DockerCli) CmdRestart(args ...string) error { |
537 | 537 |
v.Set("t", strconv.Itoa(*nSeconds)) |
538 | 538 |
|
539 | 539 |
for _, name := range cmd.Args() { |
540 |
- name = cleanName(name) |
|
541 |
- _, _, err := cli.call("POST", "/containers/"+name+"/restart?"+v.Encode(), nil) |
|
540 |
+ encName := cleanName(name) |
|
541 |
+ _, _, err := cli.call("POST", "/containers/"+encName+"/restart?"+v.Encode(), nil) |
|
542 | 542 |
if err != nil { |
543 | 543 |
fmt.Fprintf(cli.err, "%s\n", err) |
544 | 544 |
} else { |
... | ... |
@@ -583,11 +583,11 @@ func (cli *DockerCli) CmdInspect(args ...string) error { |
583 | 583 |
} |
584 | 584 |
fmt.Fprintf(cli.out, "[") |
585 | 585 |
for i, name := range args { |
586 |
- name = cleanName(name) |
|
586 |
+ encName := cleanName(name) |
|
587 | 587 |
if i > 0 { |
588 | 588 |
fmt.Fprintf(cli.out, ",") |
589 | 589 |
} |
590 |
- obj, _, err := cli.call("GET", "/containers/"+name+"/json", nil) |
|
590 |
+ obj, _, err := cli.call("GET", "/containers/"+encName+"/json", nil) |
|
591 | 591 |
if err != nil { |
592 | 592 |
obj, _, err = cli.call("GET", "/images/"+name+"/json", nil) |
593 | 593 |
if err != nil { |
... | ... |
@@ -785,8 +785,8 @@ func (cli *DockerCli) CmdKill(args ...string) error { |
785 | 785 |
} |
786 | 786 |
|
787 | 787 |
for _, name := range args { |
788 |
- name = cleanName(name) |
|
789 |
- _, _, err := cli.call("POST", "/containers/"+name+"/kill", nil) |
|
788 |
+ encName := cleanName(name) |
|
789 |
+ _, _, err := cli.call("POST", "/containers/"+encName+"/kill", nil) |
|
790 | 790 |
if err != nil { |
791 | 791 |
fmt.Fprintf(cli.err, "%s\n", err) |
792 | 792 |
} else { |
... | ... |
@@ -1094,6 +1094,10 @@ func (cli *DockerCli) CmdPs(args ...string) error { |
1094 | 1094 |
} |
1095 | 1095 |
|
1096 | 1096 |
for _, out := range outs { |
1097 |
+ for i := 0; i < len(out.Names); i++ { |
|
1098 |
+ out.Names[i] = utils.Trunc(out.Names[i], 10) |
|
1099 |
+ } |
|
1100 |
+ |
|
1097 | 1101 |
names := strings.Join(out.Names, ",") |
1098 | 1102 |
if !*quiet { |
1099 | 1103 |
if *noTrunc { |
... | ... |
@@ -1148,7 +1152,7 @@ func (cli *DockerCli) CmdLs(args ...string) error { |
1148 | 1148 |
return len(i.Path) < len(j.Path) |
1149 | 1149 |
}) |
1150 | 1150 |
for _, link := range links { |
1151 |
- fmt.Fprintf(w, "%s\t%s\t%s", link.Path, link.ContainerID, link.Image) |
|
1151 |
+ fmt.Fprintf(w, "%s\t%s\t%s", link.Path, utils.TruncateID(link.ContainerID), link.Image) |
|
1152 | 1152 |
fmt.Fprintf(w, "\n") |
1153 | 1153 |
} |
1154 | 1154 |
w.Flush() |
... | ... |
@@ -47,12 +47,11 @@ type WalkFunc func(fullPath string, entity *Entity) error |
47 | 47 |
// Graph database for storing entities and their relationships |
48 | 48 |
type Database struct { |
49 | 49 |
dbPath string |
50 |
- rootID string |
|
51 | 50 |
} |
52 | 51 |
|
53 | 52 |
// Create a new graph database initialized with a root entity |
54 |
-func NewDatabase(dbPath, rootId string) (*Database, error) { |
|
55 |
- db := &Database{dbPath, rootId} |
|
53 |
+func NewDatabase(dbPath string) (*Database, error) { |
|
54 |
+ db := &Database{dbPath} |
|
56 | 55 |
if _, err := os.Stat(dbPath); err == nil { |
57 | 56 |
return db, nil |
58 | 57 |
} |
... | ... |
@@ -77,12 +76,12 @@ func NewDatabase(dbPath, rootId string) (*Database, error) { |
77 | 77 |
if _, err := conn.Exec("BEGIN"); err != nil { |
78 | 78 |
return nil, err |
79 | 79 |
} |
80 |
- if _, err := conn.Exec("INSERT INTO entity (id) VALUES (?);", rootId); err != nil { |
|
80 |
+ if _, err := conn.Exec("INSERT INTO entity (id) VALUES (?);", "0"); err != nil { |
|
81 | 81 |
rollback() |
82 | 82 |
return nil, err |
83 | 83 |
} |
84 | 84 |
|
85 |
- if _, err := conn.Exec("INSERT INTO edge (entity_id, name) VALUES(?,?);", rootId, "/"); err != nil { |
|
85 |
+ if _, err := conn.Exec("INSERT INTO edge (entity_id, name) VALUES(?,?);", "0", "/"); err != nil { |
|
86 | 86 |
rollback() |
87 | 87 |
return nil, err |
88 | 88 |
} |
... | ... |
@@ -150,7 +149,7 @@ func (db *Database) setEdge(conn *sql.DB, parentPath, name string, e *Entity) er |
150 | 150 |
// Return the root "/" entity for the database |
151 | 151 |
func (db *Database) RootEntity() *Entity { |
152 | 152 |
return &Entity{ |
153 |
- id: db.rootID, |
|
153 |
+ id: "0", |
|
154 | 154 |
} |
155 | 155 |
} |
156 | 156 |
|
... | ... |
@@ -108,7 +108,7 @@ func (l *Link) Enable() error { |
108 | 108 |
} |
109 | 109 |
|
110 | 110 |
func (l *Link) Disable() { |
111 |
- // We do not care about erros here because the link may not |
|
111 |
+ // We do not care about errors here because the link may not |
|
112 | 112 |
// exist in iptables |
113 | 113 |
l.toggle("-D", true) |
114 | 114 |
|
... | ... |
@@ -577,7 +577,8 @@ func NewRuntimeFromDirectory(config *DaemonConfig) (*Runtime, error) { |
577 | 577 |
if err != nil { |
578 | 578 |
return nil, err |
579 | 579 |
} |
580 |
- graph, err := gograph.NewDatabase(path.Join(config.GraphPath, "linkgraph.db"), "engine") |
|
580 |
+ |
|
581 |
+ graph, err := gograph.NewDatabase(path.Join(config.GraphPath, "linkgraph.db")) |
|
581 | 582 |
if err != nil { |
582 | 583 |
return nil, err |
583 | 584 |
} |
... | ... |
@@ -597,7 +597,7 @@ func TestDefaultContainerName(t *testing.T) { |
597 | 597 |
t.Fatalf("Could not find edges for %s", containerID) |
598 | 598 |
} |
599 | 599 |
edge := paths[0] |
600 |
- if edge.ParentID != "engine" { |
|
600 |
+ if edge.ParentID != "0" { |
|
601 | 601 |
t.Fatalf("Expected engine got %s", edge.ParentID) |
602 | 602 |
} |
603 | 603 |
if edge.EntityID != containerID { |