From c015d26e96e1f6ebee2a577468c747bf3d2aeeb9 Mon Sep 17 00:00:00 2001 From: Daniel Mizyrycki Date: Mon, 12 Aug 2013 11:07:58 -0700 Subject: [PATCH 1/8] API, issue 1471: Allow users belonging to the docker group to use the docker client --- api.go | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/api.go b/api.go index 221cabed56..6b692ed984 100644 --- a/api.go +++ b/api.go @@ -13,6 +13,7 @@ import ( "net/http" "os" "os/exec" + "regexp" "strconv" "strings" ) @@ -974,7 +975,20 @@ func ListenAndServe(proto, addr string, srv *Server, logging bool) error { return e } if proto == "unix" { - os.Chmod(addr, 0700) + os.Chmod(addr, 0660) + groups, err := ioutil.ReadFile("/etc/group") + if err != nil { + return err + } + re := regexp.MustCompile("(^|\n)docker:.*?:([0-9]+)") + if gidMatch := re.FindStringSubmatch(string(groups)); gidMatch != nil { + gid, err := strconv.Atoi(gidMatch[2]) + if err != nil { + return err + } + utils.Debugf("docker group found. gid: %d", gid) + os.Chown(addr, 0, gid) + } } httpSrv := http.Server{Addr: addr, Handler: r} return httpSrv.Serve(l) From ef1d1aefa73f71296911b0f5593e46a81c1f5c55 Mon Sep 17 00:00:00 2001 From: Michael Crosby Date: Sat, 10 Aug 2013 03:06:08 +0000 Subject: [PATCH 2/8] Revert "docker.upstart: avoid spawning a `sh` process" This reverts commit 24dd50490a027f01ea086eb90663d53348fa770e. --- packaging/ubuntu/docker.upstart | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packaging/ubuntu/docker.upstart b/packaging/ubuntu/docker.upstart index f4d2fbe922..143be03402 100644 --- a/packaging/ubuntu/docker.upstart +++ b/packaging/ubuntu/docker.upstart @@ -5,4 +5,6 @@ stop on runlevel [!2345] respawn -exec /usr/bin/docker -d +script + /usr/bin/docker -d +end script From 68934878f1e707b126ab754d48ff6c6eb858b37e Mon Sep 17 00:00:00 2001 From: "Guillaume J. Charmes" Date: Wed, 7 Aug 2013 17:23:49 -0700 Subject: [PATCH 3/8] Make sure ENV instruction within build perform a commit each time --- buildfile.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/buildfile.go b/buildfile.go index 33e68c6211..b13643fd8e 100644 --- a/buildfile.go +++ b/buildfile.go @@ -167,9 +167,9 @@ func (b *buildFile) CmdEnv(args string) error { if envKey >= 0 { b.config.Env[envKey] = replacedVar - return nil + } else { + b.config.Env = append(b.config.Env, replacedVar) } - b.config.Env = append(b.config.Env, replacedVar) return b.commit("", b.config.Cmd, fmt.Sprintf("ENV %s", replacedVar)) } From 0ca133dd7681bb3af1d1de18a5ea6ed42142a11e Mon Sep 17 00:00:00 2001 From: Steeve Morin Date: Thu, 1 Aug 2013 02:42:22 +0200 Subject: [PATCH 4/8] Handle ip route showing mask-less IP addresses Sometimes `ip route` will show mask-less IPs, so net.ParseCIDR will fail. If it does we check if we can net.ParseIP, and fail only if we can't. Fixes #1214 Fixes #362 --- network.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/network.go b/network.go index 4e3c7456a0..02268314af 100644 --- a/network.go +++ b/network.go @@ -104,7 +104,11 @@ func checkRouteOverlaps(dockerNetwork *net.IPNet) error { continue } if _, network, err := net.ParseCIDR(strings.Split(line, " ")[0]); err != nil { - return fmt.Errorf("Unexpected ip route output: %s (%s)", err, line) + // is this a mask-less IP address? + if ip := net.ParseIP(strings.Split(line, " ")[0]); ip == nil { + // fail only if it's neither a network nor a mask-less IP address + return fmt.Errorf("Unexpected ip route output: %s (%s)", err, line) + } } else if networkOverlaps(dockerNetwork, network) { return fmt.Errorf("Network %s is already routed: '%s'", dockerNetwork.String(), line) } From c3773740d982d62c5c478d3fb27aa4494383b11b Mon Sep 17 00:00:00 2001 From: Michael Crosby Date: Mon, 12 Aug 2013 23:55:42 +0000 Subject: [PATCH 5/8] Bump to 0.5.3 --- CHANGELOG.md | 6 ++++++ commands.go | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ab145e595e..7a8122416c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## 0.5.3 (2013-08-13) +* Runtime: Use docker group for socket permissions +- Runtime: Spawn shell within upstart script +- Builder: Make sure ENV instruction within build perform a commit each time +- Runtime: Handle ip route showing mask-less IP addresses + ## 0.5.2 (2013-08-08) * Builder: Forbid certain paths within docker build ADD - Runtime: Change network range to avoid conflict with EC2 DNS diff --git a/commands.go b/commands.go index 7f70c8c09b..e1246d588e 100644 --- a/commands.go +++ b/commands.go @@ -27,7 +27,7 @@ import ( "unicode" ) -const VERSION = "0.5.2" +const VERSION = "0.5.3" var ( GITCOMMIT string From 05219d6b52d8448fdad72f89b192d61480483aff Mon Sep 17 00:00:00 2001 From: Nolan Date: Tue, 30 Jul 2013 13:23:34 -0500 Subject: [PATCH 6/8] Add hostname to the container environment. --- container.go | 1 + 1 file changed, 1 insertion(+) diff --git a/container.go b/container.go index d610c3c7d4..ccc7ab3e9f 100644 --- a/container.go +++ b/container.go @@ -652,6 +652,7 @@ func (container *Container) Start(hostConfig *HostConfig) error { "-e", "HOME=/", "-e", "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin", "-e", "container=lxc", + "-e", "HOSTNAME="+container.Config.Hostname, ) for _, elem := range container.Config.Env { From 1a1c89556f3869baded68eb56ae20f8a7e90a708 Mon Sep 17 00:00:00 2001 From: "Guillaume J. Charmes" Date: Fri, 2 Aug 2013 15:58:10 -0700 Subject: [PATCH 7/8] Fix TestEnv --- container_test.go | 1 + 1 file changed, 1 insertion(+) diff --git a/container_test.go b/container_test.go index a1ac0bd33a..f29ae9e4ea 100644 --- a/container_test.go +++ b/container_test.go @@ -960,6 +960,7 @@ func TestEnv(t *testing.T) { "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin", "HOME=/", "container=lxc", + "HOSTNAME=" + container.ShortID(), } sort.Strings(goodEnv) if len(goodEnv) != len(actualEnv) { From 5d25f3232c38d6a7ed31860948058b8ec1d95656 Mon Sep 17 00:00:00 2001 From: Michael Crosby Date: Tue, 13 Aug 2013 17:36:24 +0000 Subject: [PATCH 8/8] Update changelog to include hostname commit --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7a8122416c..cfbd86cd75 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ - Runtime: Spawn shell within upstart script - Builder: Make sure ENV instruction within build perform a commit each time - Runtime: Handle ip route showing mask-less IP addresses +- Runtime: Add hostname to environment ## 0.5.2 (2013-08-08) * Builder: Forbid certain paths within docker build ADD