This error occurs when a Docker Swarm service references a config that doesn't exist in the swarm. Configs must be created before deploying services that use them. The fix involves creating the missing config or updating your service definition.
The "config not found" error occurs when Docker Swarm tries to deploy or update a service that references a config object that hasn't been created in the swarm. Docker configs are a swarm-mode feature that allows you to store non-sensitive configuration data (like config files) outside of service images. Unlike secrets (which are encrypted at rest), configs are stored unencrypted and mounted directly into containers. They're useful for storing configuration files, environment-specific settings, or any data up to 500KB that your services need. This error commonly happens when: - You deploy a stack or service that references a config before creating it - The config was deleted but services still reference it - There's a typo in the config name in your docker-compose.yml or service definition - You're trying to use configs outside of swarm mode (configs only work with swarm services) - The stack file references an external config that was never created Docker configs are only available to swarm services, not standalone containers. If you're not running in swarm mode, you'll need to initialize a swarm first or use a different approach like bind mounts or environment variables.
First, check if the config actually exists in the swarm:
docker config lsLook for your config name in the output. You can also filter by name:
docker config ls --filter name=myconfigIf the config isn't listed, you need to create it before deploying your service.
Create the config from a file:
docker config create myconfig ./config-file.confOr create from stdin:
echo "config content here" | docker config create myconfig -You can also create configs from existing files with specific content:
# From a JSON config file
docker config create app_config ./app-config.json
# From an nginx config
docker config create nginx_conf ./nginx.confAfter creating the config, verify it exists:
docker config ls
docker config inspect myconfigDocker configs only work in swarm mode. Check if your node is part of a swarm:
docker info | grep SwarmIf it shows "Swarm: inactive", initialize a swarm:
docker swarm initOn a multi-node setup, join worker nodes:
# Get the join token on a manager
docker swarm join-token worker
# Run the provided command on worker nodes
docker swarm join --token <token> <manager-ip>:2377When using docker-compose.yml (v3.3+) with stack deploy, configs can be defined as external or created by the stack.
Option 1: Create config first, then reference as external:
# docker-compose.yml
version: "3.8"
services:
app:
image: myapp
configs:
- myconfig
configs:
myconfig:
external: trueCreate the config before deploying:
docker config create myconfig ./config.json
docker stack deploy -c docker-compose.yml mystackOption 2: Let the stack create the config from a file:
version: "3.8"
services:
app:
image: myapp
configs:
- source: myconfig
target: /app/config.json
configs:
myconfig:
file: ./config.jsonDocker configs are immutable - you cannot update them in place. To change a config's content, you must remove and recreate it:
# First, update services to remove the config reference
docker service update --config-rm myconfig myservice
# Remove the old config
docker config rm myconfig
# Create the new config
docker config create myconfig ./new-config.conf
# Re-add the config to the service
docker service update --config-add myconfig myserviceFor stack deployments, use a versioned naming convention:
configs:
myconfig_v2:
file: ./config.json
services:
app:
configs:
- source: myconfig_v2
target: /app/config.jsonIf the config exists but services still fail, inspect the service to verify config attachment:
docker service inspect myservice --prettyCheck the "Configs" section in the output. Verify:
- The config name matches exactly (case-sensitive)
- The target path is correct
- The config UID/GID and mode are appropriate
View service task errors:
docker service ps myservice --no-truncCheck container logs for config-related issues:
docker service logs myserviceConfig mount location: By default, configs are mounted at /<config-name> in Linux containers. Specify a custom target path:
services:
app:
configs:
- source: myconfig
target: /etc/myapp/config.json
uid: '103'
gid: '103'
mode: 0440Config size limit: Configs can be up to 500KB in size. For larger configuration data, consider using bind mounts or storing configs in a shared volume.
Configs vs Secrets: Use configs for non-sensitive data (application configs, feature flags). Use secrets for sensitive data (passwords, API keys). Secrets are encrypted at rest and use tmpfs mounts.
Rotation strategy: Since configs are immutable, implement rotation using versioned names:
docker config create myconfig_20240115 ./config.json
docker service update --config-rm myconfig_20240114 --config-add source=myconfig_20240115,target=/app/config.json myserviceTemplate configs: Docker 19.03+ supports config templating with Go templates:
configs:
my_config:
template_driver: golang
file: ./config.tmplTroubleshooting replicas stuck pending: If service replicas stay pending after fixing the config, force a service update:
docker service update --force myserviceWindows containers: Config file path must use the appropriate Windows path format when targeting Windows containers. Example: target: C:\\ProgramData\\app\\config.json
image operating system "linux" cannot be used on this platform
How to fix 'image operating system linux cannot be used on this platform' in Docker
manifest unknown: manifest unknown
How to fix 'manifest unknown' in Docker
cannot open '/etc/passwd': Permission denied
How to fix 'cannot open: Permission denied' in Docker
Error response from daemon: failed to create the ipvlan port
How to fix 'failed to create the ipvlan port' in Docker
toomanyrequests: Rate exceeded for anonymous users
How to fix 'Rate exceeded for anonymous users' in Docker Hub