Index
wrknv.container.operations
¶
TODO: Add module docstring.
Classes¶
ContainerBuilder
¶
Handles container build operations.
Functions¶
build
¶
build(
dockerfile: str,
tag: str,
context: str,
build_args: dict[str, str] | None,
stream_output: bool,
**extra_options: Any
) -> bool
Build a container image.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dockerfile
|
str
|
Path to Dockerfile |
required |
tag
|
str
|
Image tag |
required |
context
|
str
|
Build context directory |
required |
build_args
|
dict[str, str] | None
|
Build arguments |
required |
stream_output
|
bool
|
Whether to stream build output |
required |
**extra_options
|
Any
|
Runtime-specific build options |
{}
|
Returns:
| Type | Description |
|---|---|
bool
|
True if build successful |
Source code in wrknv/container/operations/build.py
generate_dockerfile
¶
Generate Dockerfile content from configuration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
container_config
|
ContainerConfig
|
Container configuration |
required |
Returns:
| Type | Description |
|---|---|
str
|
Dockerfile content as string |
Source code in wrknv/container/operations/build.py
203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 | |
image_exists
¶
Check if an image exists locally.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tag
|
str
|
Image tag to check |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if image exists |
Source code in wrknv/container/operations/build.py
push_image
¶
Push image to registry.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tag
|
str
|
Image tag to push |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if successful |
Source code in wrknv/container/operations/build.py
tag_image
¶
Tag an existing image.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
source_tag
|
str
|
Source image tag |
required |
target_tag
|
str
|
Target image tag |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if successful |
Source code in wrknv/container/operations/build.py
ContainerExec
¶
Handles container exec operations.
Functions¶
enter
¶
exec
¶
exec(
command: list[str] | None = None,
shell: str | None = None,
interactive: bool = False,
tty: bool = False,
user: str | None = None,
workdir: str | None = None,
environment: dict[str, str] | None = None,
) -> bool
Execute a command in the container.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
command
|
list[str] | None
|
Command to execute (defaults to shell) |
None
|
shell
|
str | None
|
Shell to use (defaults to /bin/bash or /bin/sh) |
None
|
interactive
|
bool
|
Keep STDIN open |
False
|
tty
|
bool
|
Allocate pseudo-TTY |
False
|
user
|
str | None
|
User to run as |
None
|
workdir
|
str | None
|
Working directory |
None
|
environment
|
dict[str, str] | None
|
Environment variables |
None
|
Returns:
| Type | Description |
|---|---|
bool
|
True if successful |
Source code in wrknv/container/operations/exec.py
run_command
¶
Run a command in the container and return output.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
command
|
list[str]
|
Command to run |
required |
capture_output
|
bool
|
Whether to capture output |
required |
**kwargs
|
Any
|
Additional exec options |
{}
|
Returns:
| Type | Description |
|---|---|
str | None
|
Command output if capture_output is True, else None |
Source code in wrknv/container/operations/exec.py
ContainerLifecycle
¶
Manages container lifecycle operations.
Functions¶
exists
¶
is_running
¶
remove
¶
Remove the container.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
force
|
bool
|
Force removal even if running |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if successful |
Source code in wrknv/container/operations/lifecycle.py
restart
¶
Restart the container.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
timeout
|
int
|
Seconds to wait before force stopping |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if successful |
Source code in wrknv/container/operations/lifecycle.py
start
¶
Start the container.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
create_if_missing
|
bool
|
Create container if it doesn't exist |
required |
**run_options
|
Any
|
Options for container creation |
{}
|
Returns:
| Type | Description |
|---|---|
bool
|
True if successful |
Source code in wrknv/container/operations/lifecycle.py
status
¶
Get container status.
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Status information dictionary |
Source code in wrknv/container/operations/lifecycle.py
stop
¶
Stop the container.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
timeout
|
int
|
Seconds to wait before force stopping |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if successful |
Source code in wrknv/container/operations/lifecycle.py
ContainerLogs
¶
Handles container log operations.
Functions¶
clear_logs
¶
Clear container logs (if supported by runtime).
Returns:
| Type | Description |
|---|---|
bool
|
True if successful |
Source code in wrknv/container/operations/logs.py
get_logs
¶
Get container logs.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
follow
|
bool
|
Follow log output |
required |
tail
|
int | None
|
Number of lines to tail |
required |
since
|
str | None
|
Show logs since timestamp (e.g., "2023-01-01T00:00:00") |
required |
timestamps
|
bool
|
Show timestamps |
required |
Returns:
| Type | Description |
|---|---|
str | None
|
Log output if not following, None if following |
Source code in wrknv/container/operations/logs.py
show_logs
¶
Show container logs with filtering.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
lines
|
int | None
|
Number of recent lines to show |
required |
since_minutes
|
int | None
|
Show logs from last N minutes |
required |
grep
|
str | None
|
Filter logs by pattern |
required |
Source code in wrknv/container/operations/logs.py
stream_logs
¶
Stream container logs.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tail
|
int | None
|
Number of lines to tail |
required |
since
|
str | None
|
Show logs since timestamp |
required |
timestamps
|
bool
|
Show timestamps |
required |
Yields:
| Type | Description |
|---|---|
str
|
Log lines |
Source code in wrknv/container/operations/logs.py
VolumeManager
¶
Manages container volume operations.
Functions¶
backup
¶
backup(
backup_path: Path | None = None,
volumes: list[str] | None = None,
compress: bool = True,
) -> bool
Convenience method for backing up volumes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
backup_path
|
Path | None
|
Path to save backup |
None
|
volumes
|
list[str] | None
|
List of volume names to backup |
None
|
compress
|
bool
|
Whether to compress the backup |
True
|
Returns:
| Type | Description |
|---|---|
bool
|
True if successful |
Source code in wrknv/container/operations/volumes.py
backup_volume
¶
Backup a volume to a tar file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
volume_name
|
str
|
Volume to backup |
required |
container_name
|
str
|
Container using the volume |
required |
mount_path
|
str
|
Mount path inside container |
required |
Returns:
| Type | Description |
|---|---|
Path | None
|
Path to backup file if successful |
Source code in wrknv/container/operations/volumes.py
clean
¶
create_volume
¶
Create a named volume.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Volume name |
required |
driver
|
str | None
|
Volume driver (e.g., "local") |
required |
options
|
dict[str, str] | None
|
Driver options |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if successful |
Source code in wrknv/container/operations/volumes.py
inspect_volume
¶
Get detailed volume information.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Volume name |
required |
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Volume information |
Source code in wrknv/container/operations/volumes.py
list_volumes
¶
List all volumes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filter_label
|
str | None
|
Filter by label |
required |
Returns:
| Type | Description |
|---|---|
list[dict[str, Any]]
|
List of volume information |
Source code in wrknv/container/operations/volumes.py
remove_volume
¶
Remove a named volume.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Volume name |
required |
force
|
bool
|
Force removal |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if successful |
Source code in wrknv/container/operations/volumes.py
restore
¶
Convenience method for restoring volumes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
backup_path
|
Path
|
Path to backup file |
required |
force
|
bool
|
Force restore even if volume exists |
False
|
Returns:
| Type | Description |
|---|---|
bool
|
True if successful |
Source code in wrknv/container/operations/volumes.py
restore_volume
¶
Restore a volume from a tar file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
volume_name
|
str
|
Volume to restore to |
required |
backup_file
|
Path
|
Backup tar file |
required |
mount_path
|
str
|
Mount path inside container |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if successful |
Source code in wrknv/container/operations/volumes.py
show_volumes
¶
Display volumes in a table.