prefect-docker


Nameprefect-docker JSON
Version 0.5.0 PyPI version JSON
download
home_pageNone
SummaryPrefect integrations for interacting with Docker.
upload_time2024-04-25 19:21:33
maintainerNone
docs_urlNone
authorNone
requires_python>=3.8
licenseApache License 2.0
keywords prefect
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # prefect-docker

<p align="center">
    <a href="https://pypi.python.org/pypi/prefect-docker/" alt="PyPI version">
        <img alt="PyPI" src="https://img.shields.io/pypi/v/prefect-docker?color=26272B&labelColor=090422"></a>
    <a href="https://pepy.tech/badge/prefect-docker/" alt="Downloads">
        <img src="https://img.shields.io/pypi/dm/prefect-docker?color=26272B&labelColor=090422" /></a>
</p>

## Welcome!

Prefect integrations for working with Docker.

Note! The `DockerRegistryCredentials` in `prefect-docker` is a unique block, separate from the `DockerRegistry` in `prefect` core. While `DockerRegistry` implements a few functionality from both `DockerHost` and `DockerRegistryCredentials` for convenience, it does not allow much configuration to interact with a Docker host.

Do not use `DockerRegistry` with this collection. Instead, use `DockerHost` and `DockerRegistryCredentials`.

## Getting Started

### Python setup

Requires an installation of Python 3.8+.

We recommend using a Python virtual environment manager such as pipenv, conda, or virtualenv.

These tasks are designed to work with Prefect 2. For more information about how to use Prefect, please refer to the [Prefect documentation](https://docs.prefect.io/).

### Installation

Install `prefect-docker` with `pip`:

```bash
pip install prefect-docker
```

Then, register to [view the block](https://docs.prefect.io/concepts/blocks/) on Prefect Cloud:

```bash
prefect block register -m prefect_docker
```

Note, to use the `load` method on Blocks, you must already have a block document [saved through code](https://docs.prefect.io/concepts/blocks/#saving-blocks) or saved through the UI.

### Pull image, and create, start, log, stop, and remove Docker container

```python
from prefect import flow, get_run_logger
from prefect_docker.images import pull_docker_image
from prefect_docker.containers import (
    create_docker_container,
    start_docker_container,
    get_docker_container_logs,
    stop_docker_container,
    remove_docker_container,
)


@flow
def docker_flow():
    logger = get_run_logger()
    pull_docker_image("prefecthq/prefect", "latest")
    container = create_docker_container(
        image="prefecthq/prefect", command="echo 'hello world!' && sleep 60"
    )
    start_docker_container(container_id=container.id)
    logs = get_docker_container_logs(container_id=container.id)
    logger.info(logs)
    stop_docker_container(container_id=container.id)
    remove_docker_container(container_id=container.id)
    return container
```

### Use a custom Docker Host to create a Docker container
```python
from prefect import flow
from prefect_docker import DockerHost
from prefect_docker.containers import create_docker_container

@flow
def create_docker_container_flow():
    docker_host = DockerHost(
        base_url="tcp://127.0.0.1:1234",
        max_pool_size=4
    )
    container = create_docker_container(
        docker_host=docker_host,
        image="prefecthq/prefect",
        command="echo 'hello world!'"
    )

create_docker_container_flow()
```

## Resources

If you encounter any bugs while using `prefect-docker`, feel free to open an issue in the [prefect](https://github.com/PrefectHQ/prefect) repository.

If you have any questions or issues while using `prefect-docker`, you can find help in the [Prefect Slack community](https://prefect.io/slack).

## Development

If you'd like to install a version of `prefect-docker` for development, clone the repository and perform an editable install with `pip`:

```bash
git clone https://github.com/PrefectHQ/prefect-docker.git

cd prefect-docker/

pip install -e ".[dev]"

# Install linting pre-commit hooks
pre-commit install
```

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "prefect-docker",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": "prefect",
    "author": null,
    "author_email": "\"Prefect Technologies, Inc.\" <help@prefect.io>",
    "download_url": "https://files.pythonhosted.org/packages/04/5c/92ea7c5da1d29f5fd8c0612e534d03162ea3b9a55bbc6306ced63e22bb36/prefect_docker-0.5.0.tar.gz",
    "platform": null,
    "description": "# prefect-docker\n\n<p align=\"center\">\n    <a href=\"https://pypi.python.org/pypi/prefect-docker/\" alt=\"PyPI version\">\n        <img alt=\"PyPI\" src=\"https://img.shields.io/pypi/v/prefect-docker?color=26272B&labelColor=090422\"></a>\n    <a href=\"https://pepy.tech/badge/prefect-docker/\" alt=\"Downloads\">\n        <img src=\"https://img.shields.io/pypi/dm/prefect-docker?color=26272B&labelColor=090422\" /></a>\n</p>\n\n## Welcome!\n\nPrefect integrations for working with Docker.\n\nNote! The `DockerRegistryCredentials` in `prefect-docker` is a unique block, separate from the `DockerRegistry` in `prefect` core. While `DockerRegistry` implements a few functionality from both `DockerHost` and `DockerRegistryCredentials` for convenience, it does not allow much configuration to interact with a Docker host.\n\nDo not use `DockerRegistry` with this collection. Instead, use `DockerHost` and `DockerRegistryCredentials`.\n\n## Getting Started\n\n### Python setup\n\nRequires an installation of Python 3.8+.\n\nWe recommend using a Python virtual environment manager such as pipenv, conda, or virtualenv.\n\nThese tasks are designed to work with Prefect 2. For more information about how to use Prefect, please refer to the [Prefect documentation](https://docs.prefect.io/).\n\n### Installation\n\nInstall `prefect-docker` with `pip`:\n\n```bash\npip install prefect-docker\n```\n\nThen, register to [view the block](https://docs.prefect.io/concepts/blocks/) on Prefect Cloud:\n\n```bash\nprefect block register -m prefect_docker\n```\n\nNote, to use the `load` method on Blocks, you must already have a block document [saved through code](https://docs.prefect.io/concepts/blocks/#saving-blocks) or saved through the UI.\n\n### Pull image, and create, start, log, stop, and remove Docker container\n\n```python\nfrom prefect import flow, get_run_logger\nfrom prefect_docker.images import pull_docker_image\nfrom prefect_docker.containers import (\n    create_docker_container,\n    start_docker_container,\n    get_docker_container_logs,\n    stop_docker_container,\n    remove_docker_container,\n)\n\n\n@flow\ndef docker_flow():\n    logger = get_run_logger()\n    pull_docker_image(\"prefecthq/prefect\", \"latest\")\n    container = create_docker_container(\n        image=\"prefecthq/prefect\", command=\"echo 'hello world!' && sleep 60\"\n    )\n    start_docker_container(container_id=container.id)\n    logs = get_docker_container_logs(container_id=container.id)\n    logger.info(logs)\n    stop_docker_container(container_id=container.id)\n    remove_docker_container(container_id=container.id)\n    return container\n```\n\n### Use a custom Docker Host to create a Docker container\n```python\nfrom prefect import flow\nfrom prefect_docker import DockerHost\nfrom prefect_docker.containers import create_docker_container\n\n@flow\ndef create_docker_container_flow():\n    docker_host = DockerHost(\n        base_url=\"tcp://127.0.0.1:1234\",\n        max_pool_size=4\n    )\n    container = create_docker_container(\n        docker_host=docker_host,\n        image=\"prefecthq/prefect\",\n        command=\"echo 'hello world!'\"\n    )\n\ncreate_docker_container_flow()\n```\n\n## Resources\n\nIf you encounter any bugs while using `prefect-docker`, feel free to open an issue in the [prefect](https://github.com/PrefectHQ/prefect) repository.\n\nIf you have any questions or issues while using `prefect-docker`, you can find help in the [Prefect Slack community](https://prefect.io/slack).\n\n## Development\n\nIf you'd like to install a version of `prefect-docker` for development, clone the repository and perform an editable install with `pip`:\n\n```bash\ngit clone https://github.com/PrefectHQ/prefect-docker.git\n\ncd prefect-docker/\n\npip install -e \".[dev]\"\n\n# Install linting pre-commit hooks\npre-commit install\n```\n",
    "bugtrack_url": null,
    "license": "Apache License 2.0",
    "summary": "Prefect integrations for interacting with Docker.",
    "version": "0.5.0",
    "project_urls": {
        "Homepage": "https://github.com/PrefectHQ/prefect/tree/main/src/integrations/prefect-docker"
    },
    "split_keywords": [
        "prefect"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "fa5eae698058b2248390c8415710e3a67af06c38c76fc38530706f065d23f216",
                "md5": "6f52fb17466e814ee940142eef6417a9",
                "sha256": "a78e580c3e6c24e0398376b1c5dc32c53fc80e16e7e1966e548f9105c0872212"
            },
            "downloads": -1,
            "filename": "prefect_docker-0.5.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "6f52fb17466e814ee940142eef6417a9",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 20235,
            "upload_time": "2024-04-25T19:21:23",
            "upload_time_iso_8601": "2024-04-25T19:21:23.818006Z",
            "url": "https://files.pythonhosted.org/packages/fa/5e/ae698058b2248390c8415710e3a67af06c38c76fc38530706f065d23f216/prefect_docker-0.5.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "045c92ea7c5da1d29f5fd8c0612e534d03162ea3b9a55bbc6306ced63e22bb36",
                "md5": "02fbb02d3e29421335e80e9d89886be2",
                "sha256": "8da87048200a75284bc567b0c1dac483483106fd84c7c798c9009bae72156d37"
            },
            "downloads": -1,
            "filename": "prefect_docker-0.5.0.tar.gz",
            "has_sig": false,
            "md5_digest": "02fbb02d3e29421335e80e9d89886be2",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 30450,
            "upload_time": "2024-04-25T19:21:33",
            "upload_time_iso_8601": "2024-04-25T19:21:33.283597Z",
            "url": "https://files.pythonhosted.org/packages/04/5c/92ea7c5da1d29f5fd8c0612e534d03162ea3b9a55bbc6306ced63e22bb36/prefect_docker-0.5.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-04-25 19:21:33",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "PrefectHQ",
    "github_project": "prefect",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "circle": true,
    "requirements": [],
    "lcname": "prefect-docker"
}
        
Elapsed time: 0.24494s