Skip to main content
https://badge.fury.io/py/dockerblade.svg https://img.shields.io/pypi/pyversions/dockerblade.svg

Dockerblade makes it easy to interact with Docker containers by providing an API, inspired by Python’s standard libraries (e.g., subprocess, os, and io) for executing commands and interacting with filesystems.

Installation

To install the latest release of dockerblade via pipenv or pip:

$ pipenv install dockerblade

Usage

To connect to a Docker daemon on the host machine and attach to a running container:

import dockerblade

daemon = dockerblade.DockerDaemon()
container = daemon.attach('name-of-the-container')

To perform filesystem operations on a container:

filesystem = container.filesystem()

# write text to a file
filesystem.write('/tmp/foo', 'Hello world!')

# remove a file (inspired by os.remove)
filesystem.remove('/tmp/foo')

# see API docs for more operations
...

To execute commands inside the container:

# specify the shell that should be used (e.g., /bin/sh, /bin/bash, /bin/zsh)
shell = container.shell('/bin/bash')

# obtain the value of an environment variable
val = container.environ('LD_LIBRARY_PATH')

# create a Popen
process = shell.popen('sleep 5')
retcode = process.wait()

# execute a command
assert shell.check_output('echo "Hello World"') == 'Hello World'

# see API docs for more operations
...

API Documentation

API documentation is available at: https://www.christimperley.co.uk/dockerblade

Release files for dockerblade 0.6.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for dockerblade 0.6.3
File Size Uploaded
dockerblade-0.6.3.tar.gz 20.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for dockerblade 0.6.3
File Interpreter ABI Platform
dockerblade-0.6.3-py3-none-any.whl Python 3 none any Details

Total release size: 43.2 kB

Release files / dockerblade-0.6.3.tar.gz

Download URL dockerblade-0.6.3.tar.gz
Size 20.4 kB
Tags Source
SHA-256 checksum
How to use checksums
8250e89ba7d24c26c47641ed4481827d46bc18aae8700e8a17fb76410470d91f
BLAKE2b-256 checksum
How to use checksums
72231ce36ebfe27b491b90be9ca85758153444c2a08f51d71639e2743bb8e40c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.7.1 CPython/3.12.2 Darwin/23.4.0

Release files / dockerblade-0.6.3-py3-none-any.whl

Download URL dockerblade-0.6.3-py3-none-any.whl
Size 22.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
17721034afce3999efbfa0f9e27292eb1b7dc05b1e43e2075e02250c03a803b0
BLAKE2b-256 checksum
How to use checksums
2254f714558cdcd99800a24867b51701d0a987ce228e05844aed20a7a81c373c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.7.1 CPython/3.12.2 Darwin/23.4.0

Release history Release notifications | RSS feed

This release

0.6.3 This release

2 release files

0.6.2

2 release files

0.6.1

2 release files

0.6.0

2 release files

0.5.7

1 release file

0.5.6

1 release file

0.5.5

1 release file

0.5.4

1 release file

0.5.3

1 release file

0.5.2

1 release file

0.5.1

1 release file

0.5.0

1 release file

0.4.2

1 release file

0.4.1

1 release file

0.4.0

1 release file

0.3.0

1 release file

0.2.3

1 release file

0.2.2

1 release file

0.2.1

1 release file

0.2.0

1 release file

0.0.2

1 release file

0.0.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page