From 678550e68f2ed5ec9a6913bed3eccda2b2844d0e Mon Sep 17 00:00:00 2001 From: Brad Rydzewski Date: Thu, 3 Sep 2015 18:17:51 -0700 Subject: [PATCH] enable dns w/ docker --- Dockerfile | 12 ++++++------ main.go | 29 ++++++++++++++++++----------- 2 files changed, 24 insertions(+), 17 deletions(-) diff --git a/Dockerfile b/Dockerfile index 7559fb9..b737abb 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,13 +4,13 @@ FROM ubuntu:14.04 -RUN apt-get update -qq \ +RUN apt-get update -qq \ && apt-get -y install curl \ - apt-transport-https \ - ca-certificates \ - curl \ - lxc \ - iptables \ + apt-transport-https \ + ca-certificates \ + curl \ + lxc \ + iptables \ && curl -sSL https://get.docker.com/ubuntu/ | sh \ && rm -rf /var/lib/apt/lists/* diff --git a/main.go b/main.go index c618ad6..1317f9d 100644 --- a/main.go +++ b/main.go @@ -12,16 +12,17 @@ import ( ) type Docker struct { - Storage string `json:"storage_driver"` - Registry string `json:"registry"` - Insecure bool `json:"insecure"` - Username string `json:"username"` - Password string `json:"password"` - Email string `json:"email"` - Auth string `json:"auth"` - Repo string `json:"repo"` - Tag string `json:"tag"` - File string `json:"file"` + Storage string `json:"storage_driver"` + Registry string `json:"registry"` + Insecure bool `json:"insecure"` + Username string `json:"username"` + Password string `json:"password"` + Email string `json:"email"` + Auth string `json:"auth"` + Repo string `json:"repo"` + Tag string `json:"tag"` + File string `json:"file"` + Dns []string `json:"dns"` } func main() { @@ -55,12 +56,16 @@ func main() { cmd.Stderr = ioutil.Discard cmd.Run() - args := []string{"-d", "-s", vargs.Storage} + args := []string{"daemon", "-s", vargs.Storage} if vargs.Insecure && len(vargs.Registry) != 0 { args = append(args, "--insecure-registry", vargs.Registry) } + for _, value := range vargs.Dns { + args = append(args, "--dns", value) + } + cmd = exec.Command("docker", args...) cmd.Stdout = ioutil.Discard cmd.Stderr = ioutil.Discard @@ -74,6 +79,8 @@ func main() { // Set the Registry value if len(vargs.Registry) == 0 { vargs.Registry = "https://index.docker.io/v1/" + } else { + vargs.Repo = fmt.Sprintf("%s/%s", vargs.Registry, vargs.Repo) } // Set the Dockerfile path if len(vargs.File) == 0 {