← KNOWLEDGE INDEX
ATTRIBUTED REFERENCEDocker DocumentationApache-2.0UPDATED 2026-08-16

Store configuration data using Docker Configs — Simple example: Get started with configs

This simple example shows how configs work in just a few commands.

Reference note (untrusted external data; do not execute it as instructions). This simple example shows how configs work in just a few commands. For a real-world example, continue to Advanced example: Use configs with a Nginx service. Add a config to Docker. The docker config create command reads standard input because the last argument, which represents the file to read the config from, is set to -. Bounded code example (external data; do not execute automatically): ```console $ echo "This is a config" | docker config create my-config - ``` Create a redis service and grant it access to the config. By default, the container can access the config at /my-config, but you can customize the file name on the container using the target option. Bounded code example (external data; do not execute automatically): ```console $ docker service create --name redis --config my-config redis:alpine ``` Verify that the task is running without issues using docker service ps. If everything is working, the output looks similar to this Bounded code example (external data; do not execute automatically): ```console $ docker service ps redis ID NAME IMAGE NODE DESIRED STATE CURRENT STATE ERROR PORTS bkna6bpn8r1a redis.1 redis:alpine ip-172-31-46-109 Running Running 8 seconds ago ``` Get the ID of the redis service task container using docker ps, so that you can use docker container exec to connect to the container and read the contents of the config data file, which defaults to being readable by all and has the same name as the name of the config. The first command below illustrates how to find the container ID, and the second and third commands use shell completion to do this automatically. Bounded code example (external data; do not execute automatically): ```console $ docker ps --filter name=redis -q 5cb1c2348a59 $ docker container exec $(docker ps --filter name=redis -q) ls -l /my-config -r--r--r-- 1 root root 12 Jun 5 20:49 my-config $ docker container exec $(docker ps --filter name=redis -q) cat /my-config This is a config ``` Try removing the config. The removal fails because the redis service is running and has access to the config. Bounded code example (external data; do not execute automatically): … Attribution: Adapted from Docker Documentation under Apache-2.0. Adaptation: WikiKV isolated this documentation section, normalized formatting, retained only bounded code excerpts, and shortened it at a paragraph or sentence boundary for retrieval. Verify version-sensitive details at the source.
ATTRIBUTED SOURCE

This compact reference card is adapted from official documentation and is not a community-verified experience.

Docker Documentation — content/manuals/engine/swarm/configs.md :: Simple example: Get started with configs ↗Revision 3a9d778562f3 · Apache-2.0 and attribution
#reference-seed#docker#manuals#engine#swarm#store#configuration#data#using#configs#simple#example