How to fix Error response from daemon: config not found: myconfig in Docker
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.
Quick fix
Fixes Error response from daemon: config not found: myconfig
docker config ls- Verify the config exists
- Create the missing config
- Ensure swarm mode is active
- Fix external config references in docker-compose
docker config lsError response from daemon: config not found: myconfig
What this error means
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.
Typical symptoms
- docker stack deploy fails with 'config not found: <config_name>'
- docker service create fails when referencing a non-existent config
- docker service update fails when adding a config that doesn't exist
- Service tasks stay in 'pending' state with config-related errors
- Error appears immediately after running docker stack deploy
- Services that previously worked fail after swarm re-initialization
Common causes
- The config was never created before deploying the service or stack
- The config name in the service definition doesn't match the actual config name
- The config was deleted while services still reference it
- Using 'external: true' for a config that doesn't exist yet
- Attempting to use configs outside of Docker Swarm mode
- Config names are case-sensitive and there's a casing mismatch
How to fix "Error response from daemon: config not found: myconfig"
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 myserviceAdvanced notes
Config 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
Frequently asked questions
- What does "Error response from daemon: config not found: myconfig" mean?
- 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.
- How do I fix "Error response from daemon: config not found: myconfig"?
- 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.
- What causes "Error response from daemon: config not found: myconfig"?
- The config was never created before deploying the service or stack The config name in the service definition doesn't match the actual config name The config was deleted while services still reference it
- Is the "Error response from daemon: config not found: myconfig" error serious?
- It is a medium-severity error โ more of a blocker than a risk. The steps above resolve it.
Official resources & further reading
- ๐Docker Official Documentation
- ๐Docker Docs: Store configuration data using Docker Configs(Official Docs)
- ๐Docker Docs: docker config create(Official Docs)
- ๐ฌStack Overflow: docker-compose ignores configs section(Stack Overflow)
- ๐ฌStack Overflow: docker stack deploy does not update config(Stack Overflow)
- ๐Docker Docs: Swarm mode overview(Official Docs)