Patch docker images to fit your purposes and organization requirements
Project description
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)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
docker-patch-0.1.2.tar.gz
(3.7 kB
view hashes)
Built Distribution
Close
Hashes for docker_patch-0.1.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | eb94be1418d5121577964c28c6bcafad0c47a62e37907e94c299a14df9c7c4f6 |
|
MD5 | 190478042433b2ec20061b09c61da469 |
|
BLAKE2b-256 | af1a86991540d5f676f457c4c66deacb812ba2ac059ac0f13107582a1e855fe1 |