A Docker client for Python, designed to be fun and intuitive!
—
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.
Create configurations from files or data with labeling and template support.
def create(
name: str,
file: Optional[str] = None,
labels: Optional[Dict[str, str]] = None,
template_driver: Optional[str] = None
) -> Config:
"""
Create a configuration object.
Parameters:
- name: Configuration name
- file: Path to file containing configuration data
- labels: Metadata labels for the configuration
- template_driver: Template driver to use for processing
Returns:
Config object
"""Usage Examples:
from python_on_whales import docker
# Create config from file
config = docker.config.create(
"app-config",
file="./config/app.conf",
labels={"environment": "production", "version": "1.0"}
)
# Create config from string data
with open("temp_config.txt", "w") as f:
f.write("debug=false\nport=8080")
config = docker.config.create("server-config", file="temp_config.txt")Inspect configuration details including metadata, creation time, and specification.
def inspect(x: Union[str, List[str]]) -> Union[Config, List[Config]]:
"""
Inspect one or more configurations.
Parameters:
- x: Configuration name(s) or ID(s)
Returns:
Config object(s) with detailed information
"""List all configurations with optional filtering.
def list(filters: Optional[Dict[str, str]] = None) -> List[Config]:
"""
List all configurations.
Parameters:
- filters: Filter results (e.g., {"name": "app-*"})
Returns:
List of Config objects
"""Remove configurations from the swarm.
def remove(x: Union[str, List[str]]) -> None:
"""
Remove one or more configurations.
Parameters:
- x: Configuration name(s) or ID(s)
"""class Config:
id: str
version: DockerObjectVersion
created_at: datetime
updated_at: datetime
spec: ConfigSpec
def remove(self) -> None:
"""Remove this configuration."""
class ConfigSpec:
name: str
labels: Dict[str, str]
data: Optional[str]
template_driver: Optional[str]
class DockerObjectVersion:
index: intInstall with Tessl CLI
npx tessl i tessl/pypi-python-on-whales