fill in help, add hint when running in docker
This commit is contained in:
parent
7b58366a10
commit
b911e69180
4 changed files with 33 additions and 4 deletions
|
@ -1,3 +1,4 @@
|
|||
FROM scratch
|
||||
COPY dockviz /
|
||||
ENV IN_DOCKER true
|
||||
ENTRYPOINT ["/dockviz"]
|
||||
|
|
|
@ -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 <args>\nFor more help, run 'dockviz help'")
|
||||
} else {
|
||||
return fmt.Errorf("Unable to connect: %s\nFor help, run 'dockviz help'", err)
|
||||
}
|
||||
}
|
||||
|
||||
var conts []Container
|
||||
|
|
24
help.go
24
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)
|
||||
}
|
||||
|
|
|
@ -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 <args>\nFor more help, run 'dockviz help'")
|
||||
} else {
|
||||
return fmt.Errorf("Unable to connect: %s\nFor help, run 'dockviz help'", err)
|
||||
}
|
||||
}
|
||||
|
||||
var ims []Image
|
||||
|
|
Loading…
Reference in a new issue