CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/pypi-docker

A Python library for the Docker Engine API.

Pending
Overview
Eval results
Files

volume-management.mddocs/

Volume Management

Docker volume operations for persistent data storage including volume creation, mounting, and lifecycle management with support for volume drivers and custom configurations.

Capabilities

VolumeCollection

class VolumeCollection:
    def create(self, name=None, **kwargs):
        """
        Create a volume.
        
        Args:
            name (str): Volume name (auto-generated if None)
            **kwargs: Volume configuration options
            
        Returns:
            Volume: Created volume instance
            
        Common kwargs:
            driver (str): Volume driver (default: 'local')
            driver_opts (dict): Driver-specific options
            labels (dict): Volume labels
        """

    def get(self, volume_id):
        """
        Get a volume by name.
        
        Args:
            volume_id (str): Volume name
            
        Returns:
            Volume: Volume instance
        """

    def list(self, filters=None):
        """
        List volumes.
        
        Args:
            filters (dict): Filter results by name, driver, label, etc.
            
        Returns:
            list[Volume]: List of volume instances
        """

    def prune(self, filters=None):
        """
        Remove unused volumes.
        
        Args:
            filters (dict): Filters for pruning
            
        Returns:
            dict: Pruning results with space reclaimed
        """

Volume Model

class Volume:
    """
    A Docker volume instance.
    
    Properties:
        id (str): Volume ID  
        name (str): Volume name
        attrs (dict): Raw volume attributes
    """

    def remove(self, force=False):
        """
        Remove the volume.
        
        Args:
            force (bool): Force removal even if volume is in use
        """

Usage Examples

import docker

client = docker.from_env()

# Create named volume
volume = client.volumes.create(
    name='app-data',
    driver='local',
    driver_opts={'type': 'tmpfs', 'device': 'tmpfs', 'o': 'size=100m'}
)

# Use volume in container
container = client.containers.run(
    'postgres:13',
    environment={'POSTGRES_PASSWORD': 'secret'},
    volumes={'app-data': {'bind': '/var/lib/postgresql/data', 'mode': 'rw'}},
    detach=True
)

# List and inspect volumes
for vol in client.volumes.list():
    print(f"Volume: {vol.name}, Driver: {vol.attrs['Driver']}")

Install with Tessl CLI

npx tessl i tessl/pypi-docker

docs

client-management.md

config-secrets.md

container-management.md

context-management.md

error-handling.md

image-management.md

index.md

network-management.md

plugin-management.md

swarm-services.md

system-events.md

volume-management.md

tile.json