Docker-Patch
Patch docker images to fit your purposes and organization requirements
Installation
pip install docker-patch
Usage
Add your own patch function like this:
import docker_patch
@docker_patch.register_patcher
def patcher_func(container):
print(f'patch container "{container}"')
container.exec_run('/bin/sh -c \'echo "hi from module 1" >> patched.txt\'')
You can register multiple patchers, and then use it in one of these options:
cli
docker-patch <IMAGE_NAME> -m <module_name>
You can add additional -m <module> as you like and make a patchers chain that work on your image (in order of appearance). If you would like to import a module that not in your current path or installed in the interpreter libraries, you can add --add-path like this:
# assume my_patcher is in /path/to/my_patcher.py
docker-patch <IMAGE_NAME> -m my_patcher --add-path /path/to
This will add /path/to to sys.path so the patcher can import the my_module
In code
Use it directly from code
import docker
import docker_patch
# assume you registered patchers as shown above
client = docker.DockerClient()
image = client.images.get('some-image')
result_image = docker_patch.patch_image(image)
Metadata
Release files for docker-patch 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| docker-patch-0.1.2.tar.gz | 3.7 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| docker_patch-0.1.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 9.8 kB
Release files / docker-patch-0.1.2.tar.gz
| Download URL | docker-patch-0.1.2.tar.gz |
|---|---|
| Size | 3.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9f4146c8d33115974b64867b80de7599c63c38610bb66ffa7cc4e44c1019156c
|
|
BLAKE2b-256 checksum How to use checksums |
3e14310920c16e94688698df83c9d407f7b3fc766c43c83945f744c6f94796dc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/4.4.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.0 CPython/3.9.5
|
Release files / docker_patch-0.1.2-py3-none-any.whl
| Download URL | docker_patch-0.1.2-py3-none-any.whl |
|---|---|
| Size | 6.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
eb94be1418d5121577964c28c6bcafad0c47a62e37907e94c299a14df9c7c4f6
|
|
BLAKE2b-256 checksum How to use checksums |
af1a86991540d5f676f457c4c66deacb812ba2ac059ac0f13107582a1e855fe1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/4.4.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.0 CPython/3.9.5
|
Security for docker-patch 0.1.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.