GithubHelp home page GithubHelp logo

touer25 / easier-docker Goto Github PK

View Code? Open in Web Editor NEW

This project forked from touero/easier-docker

0.0 0.0 0.0 117 KB

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

License: MIT License

Python 100.00%

easier-docker's Introduction

easier-docker

Repository Introduction

It can create a container based on the local image. If the image does not exist, the image will be pulled down. If the container exists, it will be started directly. Then execute any service you want to execute in the container.

💕 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

Related Uses Repository

  • opsariichthys-bidens — About Building a Basic Information API for Chinese National Universities in the Handheld College Entrance Examination Based on Fastapi.

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

easier-docker's People

Contributors

touero avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.