dockerblade


Namedockerblade JSON
Version 0.6.3 PyPI version JSON
download
home_pagehttps://github.com/ChrisTimperley/dockerblade
SummaryInteract with Docker containers via Python-like APIs
upload_time2024-07-02 02:31:06
maintainerNone
docs_urlNone
authorChris Timperley
requires_python<4,>=3.11
licenseApache-2.0
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            .. -*-restructuredtext-*-

dockerblade
===========

.. image:: https://badge.fury.io/py/dockerblade.svg
    :target: https://badge.fury.io/py/dockerblade

.. image:: https://img.shields.io/pypi/pyversions/dockerblade.svg
    :target: https://pypi.org/project/dockerblade


Dockerblade makes it easy to interact with Docker containers by providing an
API,
inspired by Python's standard libraries
(e.g.,
`subprocess <https://docs.python.org/3/library/subprocess.html>`_,
`os <https://docs.python.org/3/library/os.html>`_,
and
`io <https://docs.python.org/3/library/io.html>`_)
for executing commands and interacting with filesystems.


Installation
------------

To install the latest release of dockerblade via `pipenv <https://pipenv.pypa.io/en/latest/>`_
or :code:`pip`:

.. code:: console

   $ pipenv install dockerblade


Usage
-----

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

.. code:: python

   import dockerblade

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


To perform filesystem operations on a container:

.. code:: python

   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:


.. code:: python

   # 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

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/ChrisTimperley/dockerblade",
    "name": "dockerblade",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4,>=3.11",
    "maintainer_email": null,
    "keywords": null,
    "author": "Chris Timperley",
    "author_email": "ctimperley@cmu.edu",
    "download_url": "https://files.pythonhosted.org/packages/72/23/1ce36ebfe27b491b90be9ca85758153444c2a08f51d71639e2743bb8e40c/dockerblade-0.6.3.tar.gz",
    "platform": null,
    "description": ".. -*-restructuredtext-*-\n\ndockerblade\n===========\n\n.. image:: https://badge.fury.io/py/dockerblade.svg\n    :target: https://badge.fury.io/py/dockerblade\n\n.. image:: https://img.shields.io/pypi/pyversions/dockerblade.svg\n    :target: https://pypi.org/project/dockerblade\n\n\nDockerblade makes it easy to interact with Docker containers by providing an\nAPI,\ninspired by Python's standard libraries\n(e.g.,\n`subprocess <https://docs.python.org/3/library/subprocess.html>`_,\n`os <https://docs.python.org/3/library/os.html>`_,\nand\n`io <https://docs.python.org/3/library/io.html>`_)\nfor executing commands and interacting with filesystems.\n\n\nInstallation\n------------\n\nTo install the latest release of dockerblade via `pipenv <https://pipenv.pypa.io/en/latest/>`_\nor :code:`pip`:\n\n.. code:: console\n\n   $ pipenv install dockerblade\n\n\nUsage\n-----\n\nTo connect to a Docker daemon on the host machine and attach to a running\ncontainer:\n\n.. code:: python\n\n   import dockerblade\n\n   daemon = dockerblade.DockerDaemon()\n   container = daemon.attach('name-of-the-container')\n\n\nTo perform filesystem operations on a container:\n\n.. code:: python\n\n   filesystem = container.filesystem()\n\n   # write text to a file\n   filesystem.write('/tmp/foo', 'Hello world!')\n\n   # remove a file (inspired by os.remove)\n   filesystem.remove('/tmp/foo')\n\n   # see API docs for more operations\n   ...\n\n\nTo execute commands inside the container:\n\n\n.. code:: python\n\n   # specify the shell that should be used (e.g., /bin/sh, /bin/bash, /bin/zsh)\n   shell = container.shell('/bin/bash')\n\n   # obtain the value of an environment variable\n   val = container.environ('LD_LIBRARY_PATH')\n\n   # create a Popen\n   process = shell.popen('sleep 5')\n   retcode = process.wait()\n\n   # execute a command\n   assert shell.check_output('echo \"Hello World\"') == 'Hello World'\n\n   # see API docs for more operations\n   ...\n\n\nAPI Documentation\n-----------------\n\nAPI documentation is available at: https://www.christimperley.co.uk/dockerblade\n",
    "bugtrack_url": null,
    "license": "Apache-2.0",
    "summary": "Interact with Docker containers via Python-like APIs",
    "version": "0.6.3",
    "project_urls": {
        "Homepage": "https://github.com/ChrisTimperley/dockerblade",
        "Repository": "https://github.com/ChrisTimperley/dockerblade"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "2254f714558cdcd99800a24867b51701d0a987ce228e05844aed20a7a81c373c",
                "md5": "0ac7c246020e0281e34c8a89f8771ac5",
                "sha256": "17721034afce3999efbfa0f9e27292eb1b7dc05b1e43e2075e02250c03a803b0"
            },
            "downloads": -1,
            "filename": "dockerblade-0.6.3-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "0ac7c246020e0281e34c8a89f8771ac5",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4,>=3.11",
            "size": 22864,
            "upload_time": "2024-07-02T02:31:04",
            "upload_time_iso_8601": "2024-07-02T02:31:04.993560Z",
            "url": "https://files.pythonhosted.org/packages/22/54/f714558cdcd99800a24867b51701d0a987ce228e05844aed20a7a81c373c/dockerblade-0.6.3-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "72231ce36ebfe27b491b90be9ca85758153444c2a08f51d71639e2743bb8e40c",
                "md5": "e7cfb238c4d02be719069a97abddd237",
                "sha256": "8250e89ba7d24c26c47641ed4481827d46bc18aae8700e8a17fb76410470d91f"
            },
            "downloads": -1,
            "filename": "dockerblade-0.6.3.tar.gz",
            "has_sig": false,
            "md5_digest": "e7cfb238c4d02be719069a97abddd237",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4,>=3.11",
            "size": 20380,
            "upload_time": "2024-07-02T02:31:06",
            "upload_time_iso_8601": "2024-07-02T02:31:06.531274Z",
            "url": "https://files.pythonhosted.org/packages/72/23/1ce36ebfe27b491b90be9ca85758153444c2a08f51d71639e2743bb8e40c/dockerblade-0.6.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-07-02 02:31:06",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "ChrisTimperley",
    "github_project": "dockerblade",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "dockerblade"
}
        
Elapsed time: 4.68223s