0
# Config Management
1
2
Docker swarm configuration management for securely storing non-sensitive configuration data like application settings, environment-specific values, and template files. Configs are stored in the swarm cluster and can be mounted to services without exposing sensitive information.
3
4
## Capabilities
5
6
### Config Creation
7
8
Create configurations from files or data with labeling and template support.
9
10
```python { .api }
11
def create(
12
name: str,
13
file: Optional[str] = None,
14
labels: Optional[Dict[str, str]] = None,
15
template_driver: Optional[str] = None
16
) -> Config:
17
"""
18
Create a configuration object.
19
20
Parameters:
21
- name: Configuration name
22
- file: Path to file containing configuration data
23
- labels: Metadata labels for the configuration
24
- template_driver: Template driver to use for processing
25
26
Returns:
27
Config object
28
"""
29
```
30
31
**Usage Examples:**
32
33
```python
34
from python_on_whales import docker
35
36
# Create config from file
37
config = docker.config.create(
38
"app-config",
39
file="./config/app.conf",
40
labels={"environment": "production", "version": "1.0"}
41
)
42
43
# Create config from string data
44
with open("temp_config.txt", "w") as f:
45
f.write("debug=false\nport=8080")
46
47
config = docker.config.create("server-config", file="temp_config.txt")
48
```
49
50
### Config Inspection
51
52
Inspect configuration details including metadata, creation time, and specification.
53
54
```python { .api }
55
def inspect(x: Union[str, List[str]]) -> Union[Config, List[Config]]:
56
"""
57
Inspect one or more configurations.
58
59
Parameters:
60
- x: Configuration name(s) or ID(s)
61
62
Returns:
63
Config object(s) with detailed information
64
"""
65
```
66
67
### Config Listing
68
69
List all configurations with optional filtering.
70
71
```python { .api }
72
def list(filters: Optional[Dict[str, str]] = None) -> List[Config]:
73
"""
74
List all configurations.
75
76
Parameters:
77
- filters: Filter results (e.g., {"name": "app-*"})
78
79
Returns:
80
List of Config objects
81
"""
82
```
83
84
### Config Removal
85
86
Remove configurations from the swarm.
87
88
```python { .api }
89
def remove(x: Union[str, List[str]]) -> None:
90
"""
91
Remove one or more configurations.
92
93
Parameters:
94
- x: Configuration name(s) or ID(s)
95
"""
96
```
97
98
## Types
99
100
```python { .api }
101
class Config:
102
id: str
103
version: DockerObjectVersion
104
created_at: datetime
105
updated_at: datetime
106
spec: ConfigSpec
107
108
def remove(self) -> None:
109
"""Remove this configuration."""
110
111
class ConfigSpec:
112
name: str
113
labels: Dict[str, str]
114
data: Optional[str]
115
template_driver: Optional[str]
116
117
class DockerObjectVersion:
118
index: int
119
```