Docker Config Reference (docker config)

We put out an excellent guide for using docker config!

Docker Config Reference (docker config)

Example 1

docker config create myconfig configfile.txt

This command generates a new Swarm configuration named "myconfig" from the contents of "configfile.txt", enabling the injection of static configuration data into Swarm services for consistent deployment.

Example 2

docker config create --label env=production prodconfig prod.cfg

This command creates a configuration "prodconfig" from "prod.cfg" with a label "env=production", allowing filtered access or organization in production environments within Swarm clusters.

Example 3

echo "key=value" | docker config create envvars -

This command creates a configuration "envvars" from standard input (piped from echo), suitable for dynamically generating configs from scripts or environment variables.

Example 4

docker config inspect myconfig

This command displays detailed information about the configuration "myconfig", including its ID, creation time, and data, in JSON format for inspection or debugging.

Example 5

docker config inspect --pretty myconfig

This command inspects "myconfig" in a human-readable, pretty-printed format, making it easier to review configuration details without parsing JSON.

Example 6

docker config inspect --format '{{ .ID }}' prodconfig

This command extracts and displays only the ID of "prodconfig" using Go template formatting, useful for scripting or automation tasks.

Example 7

docker config ls

This command lists all available Swarm configurations, showing names, IDs, creation times, and labels, providing an overview of managed configs.

Example 8

docker config ls --filter "label=env=production"

This command lists configurations filtered by the label "env=production", helping to isolate specific configs in large Swarm setups.

Example 9

docker config ls --format "table {{.Name}}\t{{.CreatedAt}}"

This command lists configs in a tabular format, displaying only names and creation times, for concise reporting.

Example 10

docker config rm myconfig

This command removes the configuration "myconfig", freeing resources and preventing its use in future service updates.

Example 11

docker config rm prodconfig envvars

This command deletes multiple configurations "prodconfig" and "envvars" in a single operation, streamlining cleanup.

Example 12

docker config create secretconfig <(echo "sensitive=data")

This command creates "secretconfig" from process substitution input, ideal for handling sensitive data without persisting files.

Example 13

docker config create --label type=credentials authconfig creds.json

This command creates "authconfig" from "creds.json" with a label "type=credentials", categorizing it for security-related usages.

Example 14

docker config inspect myconfig prodconfig

This command inspects multiple configs "myconfig" and "prodconfig", outputting combined JSON details for batch review.

Example 15

docker config ls -q

This command lists only the IDs of all configs in quiet mode, suitable for piping into other commands or scripts.

Example 16

docker config create appconfig app.ini

This command creates "appconfig" from "app.ini", for application-specific settings in Swarm services.

Example 17

docker config create --label version=1.0 v1config v1.txt

This command adds a version label to "v1config" created from "v1.txt", supporting version-controlled configurations.

Example 18

cat data.txt | docker config create dataconfig -

This command uses cat to pipe file contents for creating "dataconfig", avoiding direct file references.

Example 19

docker config inspect --format '{{json .Spec}}' secretconfig

This command formats the spec section of "secretconfig" as JSON, extracting structural details.

Example 20

docker config ls --filter "name=app*"

This command filters configs starting with "app", using wildcard for pattern matching.

Example 21

docker config rm -f appconfig

This command forces removal of "appconfig" without confirmation, for automated deletion scripts.

Example 22

docker config create dbconfig db.sql

This command creates "dbconfig" from a SQL script "db.sql", for database initialization in services.

Example 23

docker config create --label priority=high highconfig urgent.cfg

This command labels "highconfig" as high priority from "urgent.cfg", for prioritization in management.

Example 24

printf "line1\nline2" | docker config create multiline -

This command creates "multiline" from printf output, handling multi-line configs.

Example 25

docker config inspect --pretty authconfig v1config

This command pretty-prints details for multiple configs "authconfig" and "v1config".

Example 26

docker config ls --format "{{.ID}} {{.Name}}"

This command lists IDs and names without table headers, for custom parsing.

Example 27

docker config rm dbconfig highconfig

This command removes "dbconfig" and "highconfig", batch deleting unrelated configs.

Example 28

docker config create logconfig logrotate.conf

This command creates "logconfig" from a log rotation file, for logging management in containers.

Example 29

docker config create --label app=web webconfig web.yml

This command labels "webconfig" for web apps from "web.yml".

Example 30

echo "{\"key\":\"value\"}" | docker config create jsonconfig -

This command creates "jsonconfig" from JSON input, for structured data configs.