diff --git a/Dockerfile b/Dockerfile index d1ef506..b35fb5b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,3 +1,4 @@ FROM scratch COPY dockviz / +ENV IN_DOCKER true ENTRYPOINT ["/dockviz"] diff --git a/containers.go b/containers.go index 2db8415..c42f471 100644 --- a/containers.go +++ b/containers.go @@ -57,7 +57,11 @@ func (x *ContainersCommand) Execute(args []string) error { clientContainers, err := client.ListContainers(docker.ListContainersOptions{All: true}) if err != nil { - return fmt.Errorf("Unable to connect: %s\nFor help, run 'dockviz help'", err) + if in_docker := os.Getenv("IN_DOCKER"); len(in_docker) > 0 { + return fmt.Errorf("Unable to access Docker socket, please run like this:\n docker run --rm -v /var/run/docker.sock:/var/run/docker.sock nate/dockviz containers \nFor more help, run 'dockviz help'") + } else { + return fmt.Errorf("Unable to connect: %s\nFor help, run 'dockviz help'", err) + } } var conts []Container diff --git a/help.go b/help.go index a03ad06..6dae6f9 100644 --- a/help.go +++ b/help.go @@ -9,14 +9,34 @@ type HelpCommand struct { var helpCommand HelpCommand func (x *HelpCommand) Execute(args []string) error { - fmt.Println("stub help is here") + fmt.Println(`Dockviz: Visualizing Docker Data + +Connecting to Docker: + +Dockviz supports connecting to the Docker daemon directly. It defaults to +'unix:///var/run/docker.sock', but respects the following as well: + +* The 'DOCKER_HOST', 'DOCKER_CERT_PATH', and 'DOCKER_TLS_VERIFY' environment + variables, as set up by boot2docker or docker-machine. +* Command line arguments (e.g. '--tlscacert'), like those that Docker itself + supports. + +Dockviz also supports receiving Docker image or container json data on standard +input: curl -s http://localhost:4243/images/json?all=1 | dockviz images --tree + +Visualizing: + +Dockviz can visualize both images and containers. For more information on the +options each subcommand supports, run them with the '--help' flag (e.g. +'dockviz images --help'). +`) return nil } func init() { parser.AddCommand("help", - "Help for this tool.", + "Help for dockviz.", "", &helpCommand) } diff --git a/images.go b/images.go index 605f323..018a85b 100644 --- a/images.go +++ b/images.go @@ -59,7 +59,11 @@ func (x *ImagesCommand) Execute(args []string) error { clientImages, err := client.ListImages(docker.ListImagesOptions{All: true}) if err != nil { - return fmt.Errorf("Unable to connect: %s\nFor help, run 'dockviz help'", err) + if in_docker := os.Getenv("IN_DOCKER"); len(in_docker) > 0 { + return fmt.Errorf("Unable to access Docker socket, please run like this:\n docker run --rm -v /var/run/docker.sock:/var/run/docker.sock nate/dockviz images \nFor more help, run 'dockviz help'") + } else { + return fmt.Errorf("Unable to connect: %s\nFor help, run 'dockviz help'", err) + } } var ims []Image