Skip to main content

A python package that makes it easier for you to use local docker.

Project description

easier_docker

Repository Introduction

A python package that makes it easier for you to use local docker.

💕 If it's helpful to you or cloning it, please star it. This is maximum encouragement for open-source contributors💕

Install

pip install easier_docker

Usage

Please check config parameters in Docker SDK for Python

run example.py

# example.py
import os

from easierdocker import EasierDocker

if __name__ == '__main__':
    host_script = os.path.dirname(os.path.abspath(__file__))
    container_script = '/path/to/container'
    config = {
        'image': 'python:3.9',
        'name': 'python_test',
        'volumes': {
            f'{host_script}': {'bind': container_script, 'mode': 'rw'}
        },
        'detach': True,
        'command': ["sh", "-c", f'cd {container_script} &&'
                                'python docker_example.py'],
    }
    easier_docker = EasierDocker(config)
    easier_docker.start()
    """
    >>> Finding python:3.9 docker image in local
    >>> Finding python_test docker container in local
    >>> ContainerNotFound: python_test
    >>> container id: d9233f82e9a17627d51d294091b43295fdcf3e2fae204f2d8e2bb7080b88c0b0 is running
    """

docker_example.py

# docker_example.py
def main():
    import logging
    import time
    for i in range(1, 101):
        logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
        logging.info(f'sleep 30s, times:{i}')
        time.sleep(30)


if __name__ == '__main__':
    main()
containers.png
containers_log.png

Related Repository

  • docker-py — A Python library for the Docker Engine API.

Related materials

Maintainers

@weiensong

Contributing

How I wish I could add more content in this repo !

Feel free to dive in! Open an issue or submit PRs.

Standard Python follows the Python PEP-8 Code of Conduct.

Contributors

This project exists thanks to all the people who contribute.

License

MIT © weiensong

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

easier_docker-1.0.0.tar.gz (4.6 kB view hashes)

Uploaded Source

Built Distribution

easier_docker-1.0.0-py3-none-any.whl (4.7 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page