From 25e9b06ac0750396f35d3f52f71c44b1072f0972 Mon Sep 17 00:00:00 2001 From: Daniel Nephin Date: Mon, 20 Jun 2016 16:33:53 -0400 Subject: [PATCH] Set Long text for volume commands so they can be used to generate man pages. Signed-off-by: Daniel Nephin --- api/client/volume/cmd.go | 21 ++++++++++- api/client/volume/create.go | 32 +++++++++++++++++ api/client/volume/inspect.go | 9 +++++ api/client/volume/list.go | 9 +++++ api/client/volume/remove.go | 11 ++++++ man/docker-volume-create.1.md | 65 ---------------------------------- man/docker-volume-inspect.1.md | 29 --------------- man/docker-volume-ls.1.md | 33 ----------------- man/docker-volume-rm.1.md | 26 -------------- man/docker-volume.1.md | 51 -------------------------- 10 files changed, 81 insertions(+), 205 deletions(-) delete mode 100644 man/docker-volume-create.1.md delete mode 100644 man/docker-volume-inspect.1.md delete mode 100644 man/docker-volume-ls.1.md delete mode 100644 man/docker-volume-rm.1.md delete mode 100644 man/docker-volume.1.md diff --git a/api/client/volume/cmd.go b/api/client/volume/cmd.go index bc8f55ccca..7a18a8b64a 100644 --- a/api/client/volume/cmd.go +++ b/api/client/volume/cmd.go @@ -12,8 +12,9 @@ import ( // NewVolumeCommand returns a cobra command for `volume` subcommands func NewVolumeCommand(dockerCli *client.DockerCli) *cobra.Command { cmd := &cobra.Command{ - Use: "volume", + Use: "volume COMMAND", Short: "Manage Docker volumes", + Long: volumeDescription, Args: cli.NoArgs, Run: func(cmd *cobra.Command, args []string) { fmt.Fprintf(dockerCli.Err(), "\n"+cmd.UsageString()) @@ -27,3 +28,21 @@ func NewVolumeCommand(dockerCli *client.DockerCli) *cobra.Command { ) return cmd } + +var volumeDescription = ` +The **docker volume** command has subcommands for managing data volumes. A data +volume is a specially-designated directory that by-passes storage driver +management. + +Data volumes persist data independent of a container's life cycle. When you +delete a container, the Engine daemon does not delete any data volumes. You can +share volumes across multiple containers. Moreover, you can share data volumes +with other computing resources in your system. + +To see help for a subcommand, use: + + docker volume CMD help + +For full details on using docker volume visit Docker's online documentation. + +` diff --git a/api/client/volume/create.go b/api/client/volume/create.go index 80fa56fda5..f53eb30d22 100644 --- a/api/client/volume/create.go +++ b/api/client/volume/create.go @@ -28,6 +28,7 @@ func newCreateCommand(dockerCli *client.DockerCli) *cobra.Command { cmd := &cobra.Command{ Use: "create [OPTIONS]", Short: "Create a volume", + Long: createDescription, Args: cli.NoArgs, RunE: func(cmd *cobra.Command, args []string) error { return runCreate(dockerCli, opts) @@ -60,3 +61,34 @@ func runCreate(dockerCli *client.DockerCli, opts createOptions) error { fmt.Fprintf(dockerCli.Out(), "%s\n", vol.Name) return nil } + +var createDescription = ` +Creates a new volume that containers can consume and store data in. If a name is not specified, Docker generates a random name. You create a volume and then configure the container to use it, for example: + + $ docker volume create --name hello + hello + $ docker run -d -v hello:/world busybox ls /world + +The mount is created inside the container's **/src** directory. Docker doesn't not support relative paths for mount points inside the container. + +Multiple containers can use the same volume in the same time period. This is useful if two containers need access to shared data. For example, if one container writes and the other reads the data. + +## Driver specific options + +Some volume drivers may take options to customize the volume creation. Use the **-o** or **--opt** flags to pass driver options: + + $ docker volume create --driver fake --opt tardis=blue --opt timey=wimey + +These options are passed directly to the volume driver. Options for different volume drivers may do different things (or nothing at all). + +The built-in **local** driver on Windows does not support any options. + +The built-in **local** driver on Linux accepts options similar to the linux **mount** command: + + $ docker volume create --driver local --opt type=tmpfs --opt device=tmpfs --opt o=size=100m,uid=1000 + +Another example: + + $ docker volume create --driver local --opt type=btrfs --opt device=/dev/sda2 + +` diff --git a/api/client/volume/inspect.go b/api/client/volume/inspect.go index db36926f1a..5cf8fb4423 100644 --- a/api/client/volume/inspect.go +++ b/api/client/volume/inspect.go @@ -20,6 +20,7 @@ func newInspectCommand(dockerCli *client.DockerCli) *cobra.Command { cmd := &cobra.Command{ Use: "inspect [OPTIONS] VOLUME [VOLUME...]", Short: "Display detailed information on one or more volumes", + Long: inspectDescription, Args: cli.RequiresMinArgs(1), RunE: func(cmd *cobra.Command, args []string) error { opts.names = args @@ -44,3 +45,11 @@ func runInspect(dockerCli *client.DockerCli, opts inspectOptions) error { return inspect.Inspect(dockerCli.Out(), opts.names, opts.format, getVolFunc) } + +var inspectDescription = ` +Returns information about one or more volumes. By default, this command renders +all results in a JSON array. You can specify an alternate format to execute a +given template is executed for each result. Go's http://golang.org/pkg/text/template/ +package describes all the details of the format. + +` diff --git a/api/client/volume/list.go b/api/client/volume/list.go index b114b52c00..8e5f51fc76 100644 --- a/api/client/volume/list.go +++ b/api/client/volume/list.go @@ -34,6 +34,7 @@ func newListCommand(dockerCli *client.DockerCli) *cobra.Command { Use: "ls [OPTIONS]", Aliases: []string{"list"}, Short: "List volumes", + Long: listDescription, Args: cli.NoArgs, RunE: func(cmd *cobra.Command, args []string) error { return runList(dockerCli, opts) @@ -84,3 +85,11 @@ func runList(dockerCli *client.DockerCli, opts listOptions) error { w.Flush() return nil } + +var listDescription = ` + +Lists all the volumes Docker knows about. You can filter using the **-f** or **--filter** flag. The filtering format is a **key=value** pair. To specify more than one filter, pass multiple flags (for example, **--filter "foo=bar" --filter "bif=baz"**) + +There is a single supported filter **dangling=value** which takes a boolean of **true** or **false**. + +` diff --git a/api/client/volume/remove.go b/api/client/volume/remove.go index f47c93ba46..f406a88bdd 100644 --- a/api/client/volume/remove.go +++ b/api/client/volume/remove.go @@ -15,6 +15,8 @@ func newRemoveCommand(dockerCli *client.DockerCli) *cobra.Command { Use: "rm VOLUME [VOLUME]...", Aliases: []string{"remove"}, Short: "Remove a volume", + Long: removeDescription, + Example: removeExample, Args: cli.RequiresMinArgs(1), RunE: func(cmd *cobra.Command, args []string) error { return runRemove(dockerCli, args) @@ -41,3 +43,12 @@ func runRemove(dockerCli *client.DockerCli, volumes []string) error { } return nil } + +var removeDescription = ` +Removes one or more volumes. You cannot remove a volume that is in use by a container. +` + +var removeExample = ` +$ docker volume rm hello +hello +` diff --git a/man/docker-volume-create.1.md b/man/docker-volume-create.1.md deleted file mode 100644 index e71a2f1df1..0000000000 --- a/man/docker-volume-create.1.md +++ /dev/null @@ -1,65 +0,0 @@ -% DOCKER(1) Docker User Manuals -% Docker Community -% JULY 2015 -# NAME -docker-volume-create - Create a new volume - -# SYNOPSIS -**docker volume create** -[**-d**|**--driver**[=*DRIVER*]] -[**--help**] -[**--label**[=*[]*]] -[**--name**[=*NAME*]] -[**-o**|**--opt**[=*[]*]] - -# DESCRIPTION - -Creates a new volume that containers can consume and store data in. If a name is not specified, Docker generates a random name. You create a volume and then configure the container to use it, for example: - - $ docker volume create --name hello - hello - $ docker run -d -v hello:/world busybox ls /world - -The mount is created inside the container's `/src` directory. Docker doesn't not support relative paths for mount points inside the container. - -Multiple containers can use the same volume in the same time period. This is useful if two containers need access to shared data. For example, if one container writes and the other reads the data. - -## Driver specific options - -Some volume drivers may take options to customize the volume creation. Use the `-o` or `--opt` flags to pass driver options: - - $ docker volume create --driver fake --opt tardis=blue --opt timey=wimey - -These options are passed directly to the volume driver. Options for -different volume drivers may do different things (or nothing at all). - -The built-in `local` driver on Windows does not support any options. - -The built-in `local` driver on Linux accepts options similar to the linux `mount` -command: - - $ docker volume create --driver local --opt type=tmpfs --opt device=tmpfs --opt o=size=100m,uid=1000 - -Another example: - - $ docker volume create --driver local --opt type=btrfs --opt device=/dev/sda2 - - -# OPTIONS -**-d**, **--driver**="*local*" - Specify volume driver name - -**--help** - Print usage statement - -**--label**=*label* - Set metadata for a volume - -**--name**="" - Specify volume name - -**-o**, **--opt**=[] - Set driver specific options - -# HISTORY -July 2015, created by Brian Goff diff --git a/man/docker-volume-inspect.1.md b/man/docker-volume-inspect.1.md deleted file mode 100644 index 6097e96e13..0000000000 --- a/man/docker-volume-inspect.1.md +++ /dev/null @@ -1,29 +0,0 @@ -% DOCKER(1) Docker User Manuals -% Docker Community -% JULY 2015 -# NAME -docker-volume-inspect - Get low-level information about a volume - -# SYNOPSIS -**docker volume inspect** -[**-f**|**--format**[=*FORMAT*]] -[**--help**] -VOLUME [VOLUME...] - -# DESCRIPTION - -Returns information about one or more volumes. By default, this command renders all results -in a JSON array. You can specify an alternate format to execute a given template -is executed for each result. Go's -http://golang.org/pkg/text/template/ package describes all the details of the -format. - -# OPTIONS -**-f**, **--format**="" - Format the output using the given go template. - -**--help** - Print usage statement - -# HISTORY -July 2015, created by Brian Goff diff --git a/man/docker-volume-ls.1.md b/man/docker-volume-ls.1.md deleted file mode 100644 index c045e43bd5..0000000000 --- a/man/docker-volume-ls.1.md +++ /dev/null @@ -1,33 +0,0 @@ -% DOCKER(1) Docker User Manuals -% Docker Community -% JULY 2015 -# NAME -docker-volume-ls - List all volumes - -# SYNOPSIS -**docker volume ls** -[**-f**|**--filter**[=*FILTER*]] -[**--help**] -[**-q**|**--quiet**[=*true*|*false*]] - -# DESCRIPTION - -Lists all the volumes Docker knows about. You can filter using the `-f` or `--filter` flag. The filtering format is a `key=value` pair. To specify more than one filter, pass multiple flags (for example, `--filter "foo=bar" --filter "bif=baz"`) - -There is a single supported filter `dangling=value` which takes a boolean of `true` or `false`. - -# OPTIONS -**-f**, **--filter**="" - Filter output based on these conditions: - - dangling= a volume if referenced or not - - driver= a volume's driver name - - name= a volume's name - -**--help** - Print usage statement - -**-q**, **--quiet**=*true*|*false* - Only display volume names - -# HISTORY -July 2015, created by Brian Goff diff --git a/man/docker-volume-rm.1.md b/man/docker-volume-rm.1.md deleted file mode 100644 index 876700d4d4..0000000000 --- a/man/docker-volume-rm.1.md +++ /dev/null @@ -1,26 +0,0 @@ -% DOCKER(1) Docker User Manuals -% Docker Community -% JULY 2015 -# NAME -docker-volume-rm - Remove a volume - -# SYNOPSIS -**docker volume rm** -[**--help**] -VOLUME [VOLUME...] - -# DESCRIPTION - -Removes one or more volumes. You cannot remove a volume that is in use by a container. - - ``` - $ docker volume rm hello - hello - ``` - -# OPTIONS -**--help** - Print usage statement - -# HISTORY -July 2015, created by Brian Goff diff --git a/man/docker-volume.1.md b/man/docker-volume.1.md deleted file mode 100644 index ebbf2c488e..0000000000 --- a/man/docker-volume.1.md +++ /dev/null @@ -1,51 +0,0 @@ -% DOCKER(1) Docker User Manuals -% Docker Community -% Feb 2016 -# NAME -docker-volume - Create a new volume - -# SYNOPSIS -**docker volume** [OPTIONS] COMMAND -[**--help**] - -# DESCRIPTION - -docker volume has subcommands for managing data volumes. - -## Data volumes - -The `docker volume` command has subcommands for managing data volumes. A data volume is a specially-designated directory that by-passes storage driver management. - -Data volumes persist data independent of a container's life cycle. When you delete a container, the Engine daemon does not delete any data volumes. You can share volumes across multiple containers. Moreover, you can share data volumes with other computing resources in your system. - -To see help for a subcommand, use: - -``` -docker volume CMD help -``` - -For full details on using docker volume visit Docker's online documentation. - -# OPTIONS -**--help** - Print usage statement - -# COMMANDS -**create** - Create a volume - See **docker-volume-create(1)** for full documentation on the **create** command. - -**inspect** - Display detailed information on one or more volumes - See **docker-volume-inspect(1)** for full documentation on the **inspect** command. - -**ls** - List volumes - See **docker-volume-ls(1)** for full documentation on the **ls** command. - -**rm** - Remove a volume - See **docker-volume-rm(1)** for full documentation on the **rm** command. - -# HISTORY -Feb 2016, created by Dan Walsh