Allow docker API location to be specified or blanked
This commit is contained in:
1 parent
0af2111535
commit
0c23e47124
1 file changed
+21
-5
+21
-5
@@ -28,14 +28,22 @@ var Log = common.Log
|
|||||||
func main() {
|
func main() {
|
||||||
var (
|
var (
|
||||||
justVersion bool
|
justVersion bool
|
||||||
|
dockerAPI string
|
||||||
address string
|
address string
|
||||||
meshAddress string
|
meshAddress string
|
||||||
logLevel string
|
logLevel string
|
||||||
noMulticastRoute bool
|
noMulticastRoute bool
|
||||||
|
|
||||||
|
defaultDockerHost = "unix:///var/run/docker.sock"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if val := os.Getenv("DOCKER_HOST"); val != "" {
|
||||||
|
defaultDockerHost = val
|
||||||
|
}
|
||||||
|
|
||||||
flag.BoolVar(&justVersion, "version", false, "print version and exit")
|
flag.BoolVar(&justVersion, "version", false, "print version and exit")
|
||||||
flag.StringVar(&logLevel, "log-level", "info", "logging level (debug, info, warning, error)")
|
flag.StringVar(&logLevel, "log-level", "info", "logging level (debug, info, warning, error)")
|
||||||
|
flag.StringVar(&dockerAPI, "docker-api", defaultDockerHost, "Docker API endpoint")
|
||||||
flag.StringVar(&address, "socket", "/run/docker/plugins/weave.sock", "socket on which to listen")
|
flag.StringVar(&address, "socket", "/run/docker/plugins/weave.sock", "socket on which to listen")
|
||||||
flag.StringVar(&meshAddress, "meshsocket", "/run/docker/plugins/weavemesh.sock", "socket on which to listen in mesh mode")
|
flag.StringVar(&meshAddress, "meshsocket", "/run/docker/plugins/weavemesh.sock", "socket on which to listen in mesh mode")
|
||||||
flag.BoolVar(&noMulticastRoute, "no-multicast-route", false, "deprecated (this is now the default)")
|
flag.BoolVar(&noMulticastRoute, "no-multicast-route", false, "deprecated (this is now the default)")
|
||||||
@@ -51,17 +59,25 @@ func main() {
|
|||||||
|
|
||||||
weave := weaveapi.NewClient(os.Getenv("WEAVE_HTTP_ADDR"), Log)
|
weave := weaveapi.NewClient(os.Getenv("WEAVE_HTTP_ADDR"), Log)
|
||||||
|
|
||||||
// API 1.21 is the first version that supports docker network commands
|
var dockerClient *docker.Client
|
||||||
dockerClient, err := docker.NewVersionedClientFromEnv("1.21")
|
var err error
|
||||||
if err != nil {
|
if dockerAPI != "" {
|
||||||
Log.Fatalf("unable to connect to docker: %s", err)
|
// API 1.21 is the first version that supports docker network commands
|
||||||
|
dockerClient, err = docker.NewVersionedClient(dockerAPI, "1.21")
|
||||||
|
if err != nil {
|
||||||
|
Log.Fatalf("unable to connect to docker: %s", err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Log.Println("Weave plugin", version, "Command line options:", os.Args[1:])
|
Log.Println("Weave plugin", version, "Command line options:", os.Args[1:])
|
||||||
if noMulticastRoute {
|
if noMulticastRoute {
|
||||||
Log.Warning("--no-multicast-route option has been removed; multicast is off by default")
|
Log.Warning("--no-multicast-route option has been removed; multicast is off by default")
|
||||||
}
|
}
|
||||||
Log.Info(dockerClient.Info())
|
if dockerClient == nil {
|
||||||
|
Log.Info("Running without Docker API connection")
|
||||||
|
} else {
|
||||||
|
Log.Info(dockerClient.Info())
|
||||||
|
}
|
||||||
|
|
||||||
err = run(dockerClient, weave, address, meshAddress)
|
err = run(dockerClient, weave, address, meshAddress)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
Reference in new issue
Block a user