From a3ccec197e847a996e725d87177067dba98bcca6 Mon Sep 17 00:00:00 2001 From: Victor Vieux Date: Tue, 21 May 2013 10:14:58 +0000 Subject: [PATCH] add -host and -port --- commands.go | 4 ++-- docker/docker.go | 10 ++++++---- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/commands.go b/commands.go index 5e459a1d94..0d7dc0e8a1 100644 --- a/commands.go +++ b/commands.go @@ -30,8 +30,8 @@ var ( GIT_COMMIT string ) -func ParseCommands(args ...string) error { - cli := NewDockerCli("0.0.0.0", 4243) +func ParseCommands(host string, port int, args ...string) error { + cli := NewDockerCli(host, port) if len(args) > 0 { methodName := "Cmd" + strings.ToUpper(args[0][:1]) + strings.ToLower(args[0][1:]) diff --git a/docker/docker.go b/docker/docker.go index c8c1a65603..800c8f09c0 100644 --- a/docker/docker.go +++ b/docker/docker.go @@ -29,6 +29,8 @@ func main() { flAutoRestart := flag.Bool("r", false, "Restart previously running containers") bridgeName := flag.String("b", "", "Attach containers to a pre-existing network bridge") pidfile := flag.String("p", "/var/run/docker.pid", "File containing process PID") + port := flag.Int("port", 4243, "Port to listen/connect to") + host := flag.String("host", "0.0.0.0", "Host bind/connect to") flag.Parse() if *bridgeName != "" { docker.NetworkBridgeIface = *bridgeName @@ -44,12 +46,12 @@ func main() { flag.Usage() return } - if err := daemon(*pidfile, *flAutoRestart); err != nil { + if err := daemon(*pidfile, *host, *port, *flAutoRestart); err != nil { log.Fatal(err) os.Exit(-1) } } else { - if err := docker.ParseCommands(flag.Args()...); err != nil { + if err := docker.ParseCommands(*host, *port, flag.Args()...); err != nil { log.Fatal(err) os.Exit(-1) } @@ -83,7 +85,7 @@ func removePidFile(pidfile string) { } } -func daemon(pidfile string, autoRestart bool) error { +func daemon(pidfile, host string, port int, autoRestart bool) error { if err := createPidFile(pidfile); err != nil { log.Fatal(err) } @@ -103,5 +105,5 @@ func daemon(pidfile string, autoRestart bool) error { return err } - return docker.ListenAndServe("0.0.0.0:4243", server, true) + return docker.ListenAndServe(fmt.Sprintf("%s:%d", host, port), server, true) }