Docker Config Reference (docker container)

We go over many examples of using the docker container commands!

Docker Config Reference (docker container)

Example 1

docker config create myconfig configfile.txt

This command establishes a new configuration object named "myconfig" in Docker Swarm, utilizing the content from the specified file "configfile.txt". It is applicable for injecting static configuration data into services requiring consistent settings across nodes.

Example 2

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

This command creates a configuration "prodconfig" from "prod.cfg" and assigns a label "env=production", which facilitates organization and filtering in production-oriented Swarm deployments.

Example 3

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

This command generates a configuration "envvars" by piping input from an echo statement, enabling dynamic creation from scripts or command outputs without intermediate files.

Example 4

docker config inspect myconfig

This command retrieves and displays detailed metadata about the configuration "myconfig", including its identifier, creation timestamp, and content, in JSON format for analytical purposes.

Example 5

docker config inspect --pretty myconfig

This command inspects "myconfig" and presents the information in a formatted, human-readable structure, enhancing readability for manual review.

Example 6

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

This command extracts and outputs only the identifier of "prodconfig" using a Go template, supporting integration into automated workflows or scripts.

Example 7

docker config ls

This command enumerates all existing configurations in the Swarm cluster, displaying their names, identifiers, creation times, and labels for comprehensive management.

Example 8

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

This command lists configurations filtered by the label "env=production", allowing targeted retrieval in environments with numerous objects.

Example 9

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

This command lists configurations in a tabular format, restricting output to names and creation times, which aids in concise reporting.

Example 10

docker config rm myconfig

This command deletes the configuration "myconfig", removing it from the Swarm store to free resources or prevent further usage.

Example 11

docker config rm prodconfig envvars

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

Example 12

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

This command creates "secretconfig" using process substitution for input, suitable for handling ephemeral or sensitive data without file persistence.

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-focused applications.

Example 14

docker config inspect myconfig prodconfig

This command inspects multiple configurations, "myconfig" and "prodconfig", outputting combined details for efficient batch analysis.

Example 15

docker config ls -q

This command lists only the identifiers of all configurations in quiet mode, facilitating output piping for further processing.

Example 16

docker config create appconfig app.ini

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

Example 17

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

This command creates "v1config" from "v1.txt" with a version label, supporting managed updates in version-controlled environments.

Example 18

cat data.txt | docker config create dataconfig -

This command creates "dataconfig" by piping content from a file, avoiding direct file paths in scripted scenarios.

Example 19

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

This command formats and displays the specification section of "secretconfig" as JSON, extracting core structural information.

Example 20

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

This command filters and lists configurations with names starting with "app", employing pattern matching for selective queries.

Example 21

docker config rm -f appconfig

This command forces the removal of "appconfig" without prompting for confirmation, applicable in non-interactive automation.

Example 22

docker config create dbconfig db.sql

This command creates "dbconfig" from "db.sql", useful for database initialization scripts in Swarm-managed databases.

Example 23

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

This command creates "highconfig" from "urgent.cfg" with a priority label, aiding in prioritization during service assignments.

Example 24

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

This command creates "multiline" from formatted input, handling configurations with multiple lines.

Example 25

docker config inspect --pretty authconfig v1config

This command inspects and pretty-prints details for "authconfig" and "v1config" in a readable format.

Example 26

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

This command lists identifiers and names without headers, suitable for custom parsing or logging.

Example 27

docker config rm dbconfig highconfig

This command deletes "dbconfig" and "highconfig", performing batch removal for efficiency.

Example 28

docker config create logconfig logrotate.conf

This command creates "logconfig" from "logrotate.conf", for managing logging rotations in services.

Example 29

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

This command creates "webconfig" from "web.yml" with an application label, for web-specific configurations.

Example 30

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

This command creates "jsonconfig" from JSON-formatted input, supporting structured data in configurations.