# Docker Config Not Found: How to Create and Manage Swarm Configs
Your Swarm service fails to deploy because a referenced config doesn't exist:
Error response from daemon: rpc error: code = 2 desc = config nginx_config not foundOr:
service myapp: failed to update service: config not found: app_settingsDocker Swarm configs store non-sensitive configuration data. Services fail if referenced configs aren't created first. Let me show you how to fix this.
Introduction
This article covers troubleshooting steps and solutions for Docker Config Not Found: How to Create and Manage Swarm Configs. The error typically occurs in production environments and can cause service disruptions if not addressed promptly.
Symptoms
Common error messages include:
Error response from daemon: rpc error: code = 2 desc = config nginx_config not foundservice myapp: failed to update service: config not found: app_settings```bash # List all configs docker config ls
# Output: # ID NAME CREATED # abc123 nginx_config 2 hours ago
# Inspect a config docker config inspect nginx_config
# Show config content (base64 encoded) docker config inspect nginx_config --format '{{.Spec.Data}}' | base64 -d ```
Common Causes
- Configuration misconfiguration
- Missing or incorrect credentials
- Network connectivity issues
- Version compatibility problems
- Resource exhaustion or limits
- Permission or access denied
Step-by-Step Fix
Understanding Docker Swarm Configs
Configs are similar to secrets but:
- Not encrypted at rest
- Mounted in / by default (configurable)
- Can be updated without creating new versions
- Suitable for non-sensitive configuration files
Step 1: List Existing Configs
Check what configs exist in your Swarm:
```bash # List all configs docker config ls
# Output: # ID NAME CREATED # abc123 nginx_config 2 hours ago
# Inspect a config docker config inspect nginx_config
# Show config content (base64 encoded) docker config inspect nginx_config --format '{{.Spec.Data}}' | base64 -d ```
Step 2: Create Missing Configs
If the config doesn't exist, create it:
```bash # Create from file docker config create nginx_config ./nginx.conf
# Create from stdin cat <<EOF | docker config create app_config - server { listen 80; root /var/www/html; } EOF
# Create from existing file with specific name docker config create myapp_config_v1 ./config.json
# Verify creation docker config ls | grep nginx_config ```
Unlike secrets, configs can be viewed after creation:
# View config content
docker config inspect nginx_config --prettyStep 3: Update Service to Use Config
Add configs to your service:
```bash # Add config to service docker service update --config-add nginx_config mywebapp
# Add with custom target path docker service update \ --config-add source=nginx_config,target=/etc/nginx/nginx.conf \ mywebapp
# Add with specific permissions docker service update \ --config-add source=nginx_config,target=/etc/nginx/nginx.conf,uid=1000,gid=1000,mode=0644 \ mywebapp ```
Create service with config:
docker service create \
--name mywebapp \
--config nginx_config \
nginx:latestStep 4: Use Configs in Docker Compose
Define configs in your stack file:
```yaml version: '3.8' configs: nginx_config: external: true # Must exist before deployment
services: web: image: nginx:latest configs: - source: nginx_config target: /etc/nginx/nginx.conf ```
Or create from file:
```yaml version: '3.8' configs: nginx_config: file: ./nginx.conf # Created during deployment
services: web: image: nginx:latest configs: - nginx_config ```
Deploy the stack:
```bash # For external configs, create first docker config create nginx_config ./nginx.conf
# Deploy stack docker stack deploy -c docker-compose.yml myapp
# For file-based configs, just deploy docker stack deploy -c docker-compose.yml myapp ```
Step 5: Update Config Values
Configs are immutable once created. To change a config:
```bash # Create new config version docker config create nginx_config_v2 ./nginx-new.conf
# Update service to use new config docker service update \ --config-rm nginx_config \ --config-add nginx_config_v2 \ mywebapp
# Remove old config docker config rm nginx_config ```
Or use the same name pattern:
```bash # Create with timestamp suffix docker config create nginx_config_$(date +%Y%m%d) ./nginx.conf
# Update service docker service update --config-add nginx_config_20260403 mywebapp ```
Step 6: Remove Unused Configs
Clean up configs no longer in use:
```bash # List configs docker config ls
# Remove unused config docker config rm nginx_config_old
# Cannot remove if in use # Error: config 'nginx_config' is in use by service 'mywebapp' ```
Check config usage:
# Find services using a config
docker service ls --format "{{.Name}}" | while read s; do
if docker service inspect $s --format '{{range .Spec.TaskTemplate.ContainerSpec.Configs}}{{.ConfigName}}{{"\n"}}{{end}}' | grep -q nginx_config; then
echo "$s uses nginx_config"
fi
doneStep 7: Access Configs in Containers
Inside containers, configs appear as files:
```bash # Check config mount location docker exec <container> ls -la /
# For default location docker exec <container> cat /nginx_config
# For custom target docker exec <container> cat /etc/nginx/nginx.conf
# Check file ownership and permissions docker exec <container> ls -la /etc/nginx/nginx.conf ```
Step 8: Debug Config Issues
If services fail due to config problems:
```bash # Check service logs docker service logs mywebapp
# Inspect service task state docker service ps mywebapp --no-trunc
# Look for "config not found" errors docker service inspect mywebapp --format '{{json .Spec.TaskTemplate.ContainerSpec.Configs}}'
# Verify config exists docker config ls | grep nginx_config ```
Step 9: Config vs Secret Decision
Choose between configs and secrets appropriately:
| Use Configs for | Use Secrets for |
|---|---|
| nginx.conf | Database passwords |
| application.yml | API keys |
| JSON configuration | TLS certificates |
| Non-sensitive settings | Authentication tokens |
Both are immutable and require new versions for updates.
Step 10: Multiple Configs per Service
Services can use multiple configs:
docker service create \
--name myapp \
--config nginx_config \
--config app_config \
--config log_config \
myimage:latestIn compose:
services:
app:
configs:
- nginx_config
- app_config
- source: log_config
target: /etc/logging.confComplete Config Workflow
```bash # 1. Create config from file docker config create nginx_config ./nginx.conf
# 2. Verify docker config ls docker config inspect nginx_config --pretty
# 3. Create service with config docker service create --name web --config nginx_config nginx
# 4. Verify config in container docker exec $(docker ps -q -f name=web) cat /nginx_config
# 5. Update config (create new version) docker config create nginx_config_v2 ./nginx-updated.conf
# 6. Update service docker service update --config-rm nginx_config --config-add nginx_config_v2 web
# 7. Clean up old config docker config rm nginx_config ```
Common Error Patterns
| Error | Cause | Fix |
|---|---|---|
config not found | Config doesn't exist | Create config first |
config in use | Cannot remove active config | Remove from service first |
invalid config reference | Wrong config name | Update service with correct name |
Prevention
- 1.Version configs with meaningful suffixes
- 2.Document config changes before updating services
- 3.Use configs for non-sensitive data only
- 4.Test config changes in staging first
- 5.Clean up old config versions periodically
Verification
| Task | Command |
|---|---|
| List configs | docker config ls |
| Create config | docker config create NAME file |
| Inspect config | docker config inspect NAME |
| View config content | docker config inspect NAME --pretty |
| Remove config | docker config rm NAME |
| Add to service | docker service update --config-add NAME service |
| Remove from service | docker service update --config-rm NAME service |
Config errors are resolved by creating the config before deploying services that reference it. Remember configs are immutable—create new versions for updates.
Related Articles
- [Fix docker build cache invalidated unnecessary layers Issue in Docker-Errors](docker-build-cache-invalidated-unnecessary-layers)
- [Fix Docker Build Cache Invalidation Optimization Issue in Docker](docker-build-cache-invalidation-optimization)
- [Fix docker build context slow large files Issue in Docker-Errors](docker-build-context-slow-large-files)
- [Fix docker build multi stage copy from not found Issue in Docker-Errors](docker-build-multi-stage-copy-from-not-found)
- [Fix docker buildkit export local tar layer missing Issue in Docker-Errors](docker-buildkit-export-local-tar-layer-missing)
<script type="application/ld+json"> { "@context": "https://schema.org", "@type": "TechArticle", "headline": "Docker Config Not Found: How to Create and Manage Swarm Configs", "description": "Troubleshoot Docker Swarm config errors. Learn to create configs, update services, and manage configuration files properly.", "url": "https://www.fixwikihub.com/fix-docker-config-not-found", "publisher": { "@type": "Organization", "name": "FixWikiHub", "url": "https://www.fixwikihub.com" }, "author": { "@type": "Person", "name": "FixWikiHub Editorial Team" }, "datePublished": "2025-11-13T05:14:40.264Z", "dateModified": "2025-11-13T05:14:40.264Z" } </script>