docs: add reference for "docker config" commands

This is mostly a copy of the equivalent `docker secret` commands,
which uses the same mechanisms behind the hood (hence, are 90% the
same).

We can make further refinements to these docs, but this gives us
a starting point.

Adding these documents, because there were some links pointing to
these pages in the docs, but there was no markdown file to link to
on GitHub.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn 2021-04-30 14:49:14 +02:00
parent 68284ff591
commit 276e7180f2
No known key found for this signature in database
GPG Key ID: 76698F39D527CE8C
5 changed files with 439 additions and 0 deletions

View File

@ -0,0 +1,35 @@
---
title: "config"
description: "The config command description and usage"
keywords: "config"
---
# config
```markdown
Usage: docker config COMMAND
Manage Docker configs
Options:
--help Print usage
Commands:
create Create a config from a file or STDIN
inspect Display detailed information on one or more configs
ls List configs
rm Remove one or more configs
Run 'docker config COMMAND --help' for more information on a command.
```
## Description
Manage configs.
## Related commands
* [config create](config_create.md)
* [config inspect](config_inspect.md)
* [config list](config_ls.md)
* [config rm](config_rm.md)

View File

@ -0,0 +1,99 @@
---
title: "config create"
description: "The config create command description and usage"
keywords: ["config, create"]
---
# config create
```Markdown
Usage: docker config create [OPTIONS] CONFIG [file|-]
Create a config from a file or STDIN as content
Options:
-l, --label list Config labels
--template-driver string Template driver
```
## Description
Creates a config using standard input or from a file for the config content.
For detailed information about using configs, refer to [store configuration data using Docker Configs](https://docs.docker.com/engine/swarm/configs/).
> **Note**
>
> This is a cluster management command, and must be executed on a swarm
> manager node. To learn about managers and workers, refer to the
> [Swarm mode section](https://docs.docker.com/engine/swarm/) in the
> documentation.
## Examples
### Create a config
```bash
$ printf <config> | docker config create my_config -
onakdyv307se2tl7nl20anokv
$ docker config ls
ID NAME CREATED UPDATED
onakdyv307se2tl7nl20anokv my_config 6 seconds ago 6 seconds ago
```
### Create a config with a file
```bash
$ docker config create my_config ./config.json
dg426haahpi5ezmkkj5kyl3sn
$ docker config ls
ID NAME CREATED UPDATED
dg426haahpi5ezmkkj5kyl3sn my_config 7 seconds ago 7 seconds ago
```
### Create a config with labels
```bash
$ docker config create \
--label env=dev \
--label rev=20170324 \
my_config ./config.json
eo7jnzguqgtpdah3cm5srfb97
```
```bash
$ docker config inspect my_config
[
{
"ID": "eo7jnzguqgtpdah3cm5srfb97",
"Version": {
"Index": 17
},
"CreatedAt": "2017-03-24T08:15:09.735271783Z",
"UpdatedAt": "2017-03-24T08:15:09.735271783Z",
"Spec": {
"Name": "my_config",
"Labels": {
"env": "dev",
"rev": "20170324"
},
"Data": "aGVsbG8K"
}
}
]
```
## Related commands
* [config inspect](config_inspect.md)
* [config ls](config_ls.md)
* [config rm](config_rm.md)

View File

@ -0,0 +1,97 @@
---
title: "config inspect"
description: "The config inspect command description and usage"
keywords: ["config, inspect"]
---
# config inspect
```Markdown
Usage: docker config inspect [OPTIONS] CONFIG [CONFIG...]
Display detailed information on one or more configs
Options:
-f, --format string Format the output using the given Go template
--help Print usage
```
## Description
Inspects the specified config.
By default, this renders all results in a JSON array. If a format is specified,
the given template will be executed for each result.
Go's [text/template](http://golang.org/pkg/text/template/) package
describes all the details of the format.
For detailed information about using configs, refer to [store configuration data using Docker Configs](https://docs.docker.com/engine/swarm/configs/).
> **Note**
>
> This is a cluster management command, and must be executed on a swarm
> manager node. To learn about managers and workers, refer to the
> [Swarm mode section](https://docs.docker.com/engine/swarm/) in the
> documentation.
## Examples
### Inspect a config by name or ID
You can inspect a config, either by its *name*, or *ID*
For example, given the following config:
```bash
$ docker config ls
ID NAME CREATED UPDATED
eo7jnzguqgtpdah3cm5srfb97 my_config 3 minutes ago 3 minutes ago
```
```bash
$ docker config inspect config.json
```
The output is in JSON format, for example:
```json
[
{
"ID": "eo7jnzguqgtpdah3cm5srfb97",
"Version": {
"Index": 17
},
"CreatedAt": "2017-03-24T08:15:09.735271783Z",
"UpdatedAt": "2017-03-24T08:15:09.735271783Z",
"Spec": {
"Name": "my_config",
"Labels": {
"env": "dev",
"rev": "20170324"
},
"Data": "aGVsbG8K"
}
}
]
```
### Formatting
You can use the --format option to obtain specific information about a
config. The following example command outputs the creation time of the
config.
```bash
$ docker config inspect --format='{{.CreatedAt}}' eo7jnzguqgtpdah3cm5srfb97
2017-03-24 08:15:09.735271783 +0000 UTC
```
## Related commands
* [config create](config_create.md)
* [config ls](config_ls.md)
* [config rm](config_rm.md)

View File

@ -0,0 +1,155 @@
---
title: "config ls"
description: "The config ls command description and usage"
keywords: ["config, ls"]
---
# config ls
```Markdown
Usage: docker config ls [OPTIONS]
List configs
Aliases:
ls, list
Options:
-f, --filter filter Filter output based on conditions provided
--format string Pretty-print configs using a Go template
--help Print usage
-q, --quiet Only display IDs
```
## Description
Run this command on a manager node to list the configs in the swarm.
For detailed information about using configs, refer to [store configuration data using Docker Configs](https://docs.docker.com/engine/swarm/configs/).
> **Note**
>
> This is a cluster management command, and must be executed on a swarm
> manager node. To learn about managers and workers, refer to the
> [Swarm mode section](https://docs.docker.com/engine/swarm/) in the
> documentation.
## Examples
```bash
$ docker config ls
ID NAME CREATED UPDATED
6697bflskwj1998km1gnnjr38 q5s5570vtvnimefos1fyeo2u2 6 weeks ago 6 weeks ago
9u9hk4br2ej0wgngkga6rp4hq my_config 5 weeks ago 5 weeks ago
mem02h8n73mybpgqjf0kfi1n0 test_config 3 seconds ago 3 seconds ago
```
### Filtering
The filtering flag (`-f` or `--filter`) format is a `key=value` pair. If there is more
than one filter, then pass multiple flags (e.g., `--filter "foo=bar" --filter "bif=baz"`)
The currently supported filters are:
- [id](#id) (config's ID)
- [label](#label) (`label=<key>` or `label=<key>=<value>`)
- [name](#name) (config's name)
#### id
The `id` filter matches all or prefix of a config's id.
```bash
$ docker config ls -f "id=6697bflskwj1998km1gnnjr38"
ID NAME CREATED UPDATED
6697bflskwj1998km1gnnjr38 q5s5570vtvnimefos1fyeo2u2 6 weeks ago 6 weeks ago
```
#### label
The `label` filter matches configs based on the presence of a `label` alone or
a `label` and a value.
The following filter matches all configs with a `project` label regardless of
its value:
```bash
$ docker config ls --filter label=project
ID NAME CREATED UPDATED
mem02h8n73mybpgqjf0kfi1n0 test_config About an hour ago About an hour ago
```
The following filter matches only services with the `project` label with the
`project-a` value.
```bash
$ docker service ls --filter label=project=test
ID NAME CREATED UPDATED
mem02h8n73mybpgqjf0kfi1n0 test_config About an hour ago About an hour ago
```
#### name
The `name` filter matches on all or prefix of a config's name.
The following filter matches config with a name containing a prefix of `test`.
```bash
$ docker config ls --filter name=test_config
ID NAME CREATED UPDATED
mem02h8n73mybpgqjf0kfi1n0 test_config About an hour ago About an hour ago
```
### Format the output
The formatting option (`--format`) pretty prints configs output
using a Go template.
Valid placeholders for the Go template are listed below:
| Placeholder | Description |
| ------------ | ------------------------------------------------------------------------------------ |
| `.ID` | Config ID |
| `.Name` | Config name |
| `.CreatedAt` | Time when the config was created |
| `.UpdatedAt` | Time when the config was updated |
| `.Labels` | All labels assigned to the config |
| `.Label` | Value of a specific label for this config. For example `{{.Label "my-label"}}` |
When using the `--format` option, the `config ls` command will either
output the data exactly as the template declares or, when using the
`table` directive, will include column headers as well.
The following example uses a template without headers and outputs the
`ID` and `Name` entries separated by a colon (`:`) for all images:
```bash
$ docker config ls --format "{{.ID}}: {{.Name}}"
77af4d6b9913: config-1
b6fa739cedf5: config-2
78a85c484f71: config-3
```
To list all configs with their name and created date in a table format you
can use:
```bash
$ docker config ls --format "table {{.ID}}\t{{.Name}}\t{{.CreatedAt}}"
ID NAME CREATED
77af4d6b9913 config-1 5 minutes ago
b6fa739cedf5 config-2 3 hours ago
78a85c484f71 config-3 10 days ago
```
## Related commands
* [config create](config_create.md)
* [config inspect](config_inspect.md)
* [config rm](config_rm.md)

View File

@ -0,0 +1,53 @@
---
title: "config rm"
description: "The config rm command description and usage"
keywords: ["config, rm"]
---
# config rm
```Markdown
Usage: docker config rm CONFIG [CONFIG...]
Remove one or more configs
Aliases:
rm, remove
Options:
--help Print usage
```
## Description
Removes the specified configs from the swarm.
For detailed information about using configs, refer to [store configuration data using Docker Configs](https://docs.docker.com/engine/swarm/configs/).
> **Note**
>
> This is a cluster management command, and must be executed on a swarm
> manager node. To learn about managers and workers, refer to the
> [Swarm mode section](https://docs.docker.com/engine/swarm/) in the
> documentation.
## Examples
This example removes a config:
```bash
$ docker config rm my_config
sapth4csdo5b6wz2p5uimh5xg
```
> **Warning**
>
> Unlike `docker rm`, this command does not ask for confirmation before removing
> a config.
## Related commands
* [config create](config_create.md)
* [config inspect](config_inspect.md)
* [config ls](config_ls.md)