Saravanan666/pypi-org huggingface dataset:
Package: dockerfixtures
This package was inspired by others, but after trying to make heads and tails
of them when faced with bugs, I ended-up finding simpler to start over.Using dockerfixtures with pytestTo spawn a container in your tests, proceed as follow:importdockerfromdockerfixturesimportimage,containerimportpytest@pytest.fixture(scope='session')defdocker_client():returndocker.from_env()@pytest.fixture(scope='session')defpg_image()->image.Image:returnimage.Image('postgres',tags='12')@pytest.fixture(scope='function')defpg_container(docker_client:docker.client.DockerClient,pg_image:image.Image)->container.Container:yield fromcontainer.fixture(docker_client,some_image)# If you don't need to reuse the image@pytest.fixture(scope='session')defpg_container(docker_client)->container.Container:some_image=image.Image('postgres',tags='12')yield fromcontainer.fixture(docker_client,some_image)Why not a pytest plugin ?Other implementation of this have been provinding a pytest
plugin, so you might wonder why this one doesn’t ?First reason is I have not looked into it that much, yet.But anyhow, you would still need to import thedockerfixtures.imagemodule. So I am not very sure what the
benefits would be ?Also I found those plugins to provide somewhat bizarre API, for
example to define the fixtures’ scope. I haven’t looked into
why they do that, yet. Here there are no surprises, a container
fixture looks like any other fixture.Pytest plugins are global: they have to be imported in yourtop-levelconftest.py(see note). I think it is good
practice to keep your tests properly partitioned based on their
external dependencies. It can help split workload if the need
arises. In a collaborative environment, having to importdockerfixtures, may help prevent breaking that partitioning
during reviews.
Package: docker-games
Docker Game ServersConfigurationInstall Docker: you can find the instructions for
installing Docker on theofficial website.Ensure you havePython3.x on your system by runningpython --version.Running a Game ServerInstall this package$pipinstalldocker-gamesCreate your server's configuration in a new Python fileEnjoy!Minecraftfromdocker_gamesimportMinecraftminecraft=Minecraft('creepers_go_boom','2GB','/home/stefano/mc_data')minecraft.add_ports(25565,25565)minecraft.accept_license()# <-- accept Minecraft's EULAminecraft.online_mode()# <-- server checks connecting players against Minecraft account databaseminecraft.start()Docker image:https://hub.docker.com/r/itzg/minecraft-serverFactoriofromdocker_gamesimportFactoriofactorio=Factorio('flying_robots','/home/stefano/factorio_data')factorio.add_ports(34197,'34197/udp')factorio.add_ports(27015,'27015/tcp')factorio.start()Docker image:https://hub.docker.com/r/factoriotools/factorioTeamSpeakfromdocker_gamesimportTeamSpeakteamspeak=TeamSpeak('tsserver','/tmp/ts_data')teamspeak.add_ports(9987,'9987/udp')teamspeak.add_ports(10011,10011)teamspeak.add_ports(30033,30033)teamspeak.accept_license()# <-- accept TeamSpeak's licenseteamspeak.start()Docker image:https://hub.docker.com/_/teamspeakContributingContributions are very welcome!If you want to improve this project, or add more server, fork the repo and submit a pull request.
Package: docker-harbormaster
HarbormasterDo you have apps you want to deploy to a server, but Kubernetes is way too much?
Harbormaster is for you.Harbormaster is a small and simple container orchestrator that lets you easily deploy
multiple Docker-Compose applications on a single host.It does this by taking a list of git repository URLs that contain Docker
Compose files and running the Compose apps they contain. It will also handle
updating/restarting the apps when the repositories change.Pleasevisit the documentationfor
more details.RationaleDo you have a home server you want to run a few apps on, but don't want everything to
break every time you upgrade the OS? Do you want automatic updates but don't want to buy
an extra 4 servers so you can run Kubernetes?Do you have a work server that you want to run a few small services on, but don't want
to have to manually manage it? Do you find that having every deployment action be in
a git repo more tidy?Harbormaster is for you.At its core, Harbormaster takes a YAML config file with a list of git repository URLs
containing Docker Compose files, clones/pulls them, and starts the services they
describe.You run Harbormaster on a timer, pointing it to a directory, and it updates all the
repositories in its configuration, and restarts the Compose services if they have
changed. That's it!It also cleanly stores data for all apps in a singledata/directory, so you always
have one directory that holds all the state, which you can easily back up and restore.See more details inthe documentation.Changelogv0.3.4 (2023-07-31)FeaturesAdd theHM_vars to the environment so they can be used in Compose v2 files. [Stavros Korokithakis]FixesFix wrong paths when launching Docker Compose. [Stavros Korokithakis]v0.3.3 (2023-07-23)FixesAdd missing crond invocation back. [Stavros Korokithakis]Don't complain about the directory if we restart the container. [Stavros Korokithakis]v0.3.2 (2023-07-23)FixesFix tests. [Stavros Korokithakis]Fix the Harbormaster Docker container. [Stavros Korokithakis]Fix issue with the Harbormaster Docker image not being able to find the data dir. [Stavros Korokithakis]Add docker-cli-compose to the Dockerfile. [Stavros Korokithakis]v0.3.1 (2023-07-22)FeaturesAdd git-crypt to the Docker image. [Stavros Korokithakis]FixesChange Compose filename. [Stavros Korokithakis]Don't restart apps when their configuration hasn't been updated. [葛上昌司]Move the --version command to the right place. [Stavros Korokithakis]v0.3.0 (2023-03-01)FeaturesAdd docker image with webhook support. [Jonas Seydel]FixesUpgrade Click (fixes #9) [Stavros Korokithakis]Be more defensive when loading the config. [Stavros Korokithakis]Fix the configuration directory having the wrong relative path base (fixes #12) [Stavros Korokithakis]
Package: docker-harpoon
An opinionated wrapper around the docker-py API that lets you use YAML to define
images and run tasks.Seehttp://harpoon.readthedocs.iofor the full documentation.InstallationJust use pip:$ pip install docker-harpoonConfigurationBefore Harpoon can be used, it must be configured. Configuration is obtained
from the following locations in the following order of precedence:Provided –harpoon-config valueHARPOON_CONFIG environment variable./harpoon.ymlFurther, you can also define user-wide settings in your home directory at~/.harpoonrc.yml. For example if you want the “dark” theme for the logging:---term_colors:darkThe contents of the harpoon config has only one mandatory option,images.
This must be a dictionary ofimage_aliastoimage_options:---images:cacafire:commands:-FROM ubuntu:14.04-RUN apt-get update && apt-get -y install caca-utils-CMD cacafireA rough overview of all the options available can be found athttp://harpoon.readthedocs.org/en/latest/docs/configuration.htmlUsageOnce harpoon is installed, there will be a new program calledharpoon.When you call harpoon without any arguments it will print out the tasks you
have available.Unless you don’t have a config file, in which case it’ll complain you have no
configuration file.Once you have a valid configuration file and have chosen a task you wish to
invoke, you may use the--taskcli option to invoke that task:$ harpoon --task <task>Most tasks will also require you to specify an image to work with:$ harpoon --task <task> --image <image_alias>Simpler UsageTo save typing--taskand--imagetoo much, the first positional argument
is treated astask(unless it is prefixed with a dash) and the second
positional argument (if also not prefixed with a dash) is taken as theimage.So:$ harpoon --task run --image my_amazing_imageIs equivalent to:$ harpoon run my_amazing_imageChangeloghttps://harpoon.readthedocs.io/en/latest/docs/changelog.htmlTestsRun:> ./test.sh
Package: docker-helper
# Docker HelperConvenience utilities for Python applications in Docker containers.## Functions- Get current container ID```pythonget_current_container_id()```Returns the ID of the container the application is currently running in,otherwise returns `None` if not running in a container.> This is done on a best-effort basis, guessed from the information in `/proc/self/cgroup`- Read configuration values```pythonread_configuration(key, path=None, default=None,single_config=False, fallback_to_env=True)```A convenient way to read configuration values from files with an optionto fall back to using environment variables.This can come handy to pass in multiple configuration options as key-value pairsusing Docker configs or secrets when working with Swarm services.When `single_config` is `True`, the configuration file is treated as a single text valuewhich is useful to read JSON configuration for example for an application.## LicenseMIT
Package: docker-hica
HICA (Host Integrated Container Applications) v0.5.1----------------------------------------------------[hɑɪkː]The goal of this project is to define a set of image label metadataand launcher tooling that understands said metadata to provide forsmooth experience running containerized applications with tightintegration with the host operating system.### Installation```pip install docker-hica```### DocsVersioned specification of all labels can be found in [docs/labels.md](docs/labels.md)Guidelines for Dockerfiles can be found in [docs/dockerfile-guidelines.md](docs/dockerfile-guidelines.md)SELinux usage is documented in [docs/selinux.md](docs/selinux.md)### ExamplesExamples directory currently contains several example Dockerfiles:* `jq`* `firefox-testing`* `signify`* `opengl-testing`* `test-description`Please refer to `README.md` in each particular subdirectory for more information.The straightforward way is to simply:```bash$ cd examples/example$ docker build -t example .$ docker-hica example```### Advanced usageLet's overview the basic stuff:```bash$ docker-hica --helpusage: docker-hica [-h] [--show-args] [--test-injectors] [--verbose] [--yes][--selinux-label SELINUX_LABEL] [--user USER]hica_app_name ...positional arguments:hica_app_namenamed_actionoptional arguments:-h, --help            show this help message and exit--show-args           show possible arguments for the specified"hica_app_name"--test-injectors      executes injector tests for specified "hica_app_name"--verbose             print additional information--yes                 bypass the capability review check--selinux-label SELINUX_LABELprovide a confinement context--user USER           user:group to run as (1000:1000)```The `--show-args` flag allows for displaying configurable parameters for image injectors, soto see what parameters can be passed to the `examples/firefox` image, execute:```bash$ docker-hica --show-args firefox:1.0usage: docker-hica [-h] [--show-args] [--verbose] [--yes][--machine-id-path MACHINE_ID_PATH][--xsocket-path XSOCKET_PATH][--x-display-num X_DISPLAY_NUM]hica_app_name ...```When `--verbose` is specified, the Docker command is also printed out during execution:```bash$ docker-hica --verbose firefox:1.0The container requests the following capabilities:- Bind mounts current working directory (/Repos/docker-hica) into the container- Bind mounts machine-id into the container- Bind mounts XSocket into the containerProceed? [y/Y/n]: yExecuting: docker run -i -u 1000:1000 --volume /Repos/docker-hica:/Repos/docker-hica -w /Repos/docker-hica --volume /etc/machine-id:/etc/machine-id --volume /tmp/.X11-unix:/tmp/.X11-unix -e DISPLAY=:0 firefox:1.0```And finally the `--yes` flag allows for skipping the initial prompt for confirmation as seen on the example above.This option is dangerous, future versions will treat 'Y' in the prompt response as 'Yes and remmber', so thatthe initial capability request is reviewed at least once.
Package: dockerhub-client
Dockerhub ClientClient library to interact with dockerhub API. Shipped with a CLI that enables high level access to main features.Installationpipinstalldockerhub-clientUsage from CLIUsing CLI, dockerhub credentials must be provided as environment variables.export DOCKERHUB_USERNAME=<username>
export DOCKERHUB_PASSWORD=<password or token>Library referenceInstanciate client with dockerhub credentials...fromdockerhub.clientimportDockerhubClientdockerhub=DockerhubClient("<username>","<password or token>")Get repository informationdockerhub.get_repository("<namespace>/<repo>")
Package: dockerhub-webhook
dockerhub-webhooklistens to HTTP POST requests from dockerhub and
triggers your scripts to update when a new container is available.FeaturesPython 3.3+ support.Pip installion availbleLightweight - built usingFlask.Supports unlimited number of triggers.Full logging support including script errors.Installation (Option 1: from Git)Dockerhub-webhook is supported on python 3.3, 3.4, 3.5, and 3.6.  To install
from the github repository, the first step is to clone it.gitclonehttps://github.com/Praisebetoscience/dockerhub-webhook.gitThen install dependencies.pipinstall-rrequirements.txtNext we need to create the config file which contains our apikey, maps scripts
to incoming repository hooks.  We can start from the example config.py and
filling in the variables listed.cpconfig.py.exampleconfig.pyTo generate an apikey you can use tools such as openssl or pwgen.opensslrand-base6430|sed's=/=\\/=g'pwgen301Alternatively you can set the$DOCKERHOOK_TOKENenvironment variable with your
key.  This will override anything in config.py.TheHOOKSdict in config.py maps respository names to serverside deploy
scripts.  Keys are the names of repositories (no namespace), and values are
the full path to the script to be called, or a relative path to the current
working directory.HOOKS={'repo1':'/full/path/to/script.sh','repo2':'relative_path_to_script.sh'}WSGI server (exGunicorn)It ishighlyrecommened you install a production ready WSGI server and
not use the server packaged with Flask (Werkzeug) because it’s geared
towards development. Here’s a quick example of how to start the
application with Gunicorn. Gunicorn is typically reversed proxied by
nginx.NOTE: dockerhub-webhook looks forconfig.pyin the current
working directory.pipinstallgunicorngunicorndockerhook:app-w1-b<host_ip>:<port>Installation (Option 2: pip)The biggest devation from installing from github is the directory stucture
where the config file, logs, and optionally scripts needs to be createdmkdir-pdockerhook/logmkdir-pdockerhook/scriptsYou create your config file just as above, but instead of coming with the
source, you have to download the example directly.cddockerhookwget-oconfig.pyhttps://raw.githubusercontent.com/Praisebetoscience/dockerhub-webhook/master/config.py.exampleInstall using pippipinstalldockerhub-webhookConfigureDocker HubGo tohttps://hub.docker.comClick the repository you wish to autodeployUnder the Webhooks tab add a webhookChoose any name you pleaseFor the Webhook URL use the following:http://example.com/hubhook?key=secretAdjust the domain and endpoint to your reverse proxy setting, and replacesecretwith your API key.Licensedockerhub-webhook source code is provided under theApachi 2.0 License.Copyright (c), 2017, PrasieBeToScience.DevelopmentWebhook usesgithub-flowfor managing branches and followsPEP8as much as
possible.To start Flask’s development Werkzeug server you can userun.py.You can run pytest unittests usingpython setup.py test.
Package: dockerignore-generate
Python (>=3.6) cli tool to automatically generate.dockerignorefilesInstallpipinstalldockerignore-generateUsageIn a directory with aDockerfiledockerignore-generatewill print out the contents of the generated.dockerignorefile.
Without arguments the docker build context is assumed to be the curret
working directory.Contexts and DockerfilesTo speciify a specific context use the-cflag, and-fto
speciify aDockerfile, e.g.,dockerignore-generate-fDockerfile.custom-c../To save a the.dockerignorefile, use the-sflag, and-oto
overwrite an existing file (file will be stored in the docker build
context)dockerignore-generate-fDockerfile.custom-c../-swrote../.dockerignore
Package: docker-image-size-limit
docker-image-size-limitLimit yourdockerimage size with a simple CLI command.
Perfect to be used inside your CI process.Read theannouncing post.Installationpipinstalldocker-image-size-limitOr use ourGithub Actionorpre-built docker image.UsageWe support just a single command:$dislyour-image-name:label300MiB
your-image-name:labelexceeds300MiBlimitby114.4MiBOptionsYou can specify your image as:Image name:pythonImage name with tag:python:3.6.6-alpineYou can specify your size as:Raw number of bytes:1024Human-readable megabytes:30 MBor30 MiBHuman-readable gigabytes:1 GBor1 GiBAny other size supported byhumanfriendlyProgrammatic usageYou can also import and use this library aspythoncode:fromdockerimportfrom_envfromdocker_image_size_limitimportcheck_image_sizeoversize=check_image_size(from_env(),'image-name:latest','1 GiB')assertoversize<0,'Too big image!'# negative oversize - is a good thing!We also shipPEP-561compatible type annotations with this library.Github ActionYou can also use this check as aGihub Action:-uses:wemake-services/docker-image-size-limit@masterwith:image:"$YOUR_IMAGE_NAME"size:"$YOUR_SIZE_LIMIT"Here'san example.Docker ImageWe have apre-built imageavailable.First, pull our pre-built docker image:dockerpullwemakeservices/docker-image-size-limitThen you can use it like so:dockerrun-v/var/run/docker.sock:/var/run/docker.sock--rm\-eINPUT_IMAGE="$YOUR_IMAGE_NAME"\-eINPUT_SIZE="$YOUR_SIZE_LIMIT"\wemakeservices/docker-image-size-limitShould I use it?You can use this script instead:LIMIT=1024# adjust at your willIMAGE='your-image-name:latest'SIZE="$(dockerimageinspect"$IMAGE"--format='{{.Size}}')"test"$SIZE"-gt"$LIMIT"&&echo'Limit exceeded';exit1||echo'Ok!'But I prefer to reuse tools over
custombashscripts here and there.LicenseMIT.
Package: docker-injector
Docker Namespace InjectorThis Python script allows you to inject commands into specified Docker namespaces of a running or healthy Docker container. It is operated through various command-line options.OverviewThe Docker Namespace Injector script offers the following functionalities:Identifying a target Docker container using labels.Validation checks to ensure that the Docker container state is either 'healthy' or 'running'.The ability to setSIGINTandSIGTERMsignal handlers for graceful shutdown upon user request.Command injections into specified Docker namespaces of the target Docker container.Monitoring the running state of the Docker container and the injected process, and terminating the process when necessary.UsageYou can control the script execution via the command line:--label: Specify the label used to identify the target Docker container. This parameter can be defined in either the 'label' or 'label=value' or 'label:value' formats.--require: Set the requirement for the Docker container’s state. This should be either 'healthy' or 'running'.--ns: Specify the namespaces to inject. These should be divided by a comma (e.g., '--ns=net,uts').--proc: Path to the proc filesystem. The default setting is '/proc'.--cmd: Define the command to run in the Docker container’s namespace.Most of the command-line parameters can be defined using environment variables:INJECTOR_LABELINJECTOR_REQUIREINJECTOR_NSINJECTOR_PROCINJECTOR_CMDCode StructureThe script comprises several functions, each one providing a specific operational feature:target_valid(target: docker.models.containers.Container, require: str) -> bool: This function checks if the Docker container meets the specified requirement.handle_stop(sig_num, frame): Handles the stop signal (SIGINT or SIGTERM) and triggers the required processes.setup_signals(): Sets up signal handlers for SIGINT and SIGTERM signals.shutdown_child(process: subprocess.Popen): Ensures a graceful shutdown of a child process that has been triggered by the script.Theinject(label, require, ns, proc, cmd)function initiates the main functionality of the script, using all the helper functions defined above.Running the CodeRun the script using the following command:```bash
python3 script.py --label=label=value --require=healthy --ns=net --proc=/proc --cmd="command_to_run"
```Make sure to replace thelabel=valueparameter with the label of your target Docker container,netwith the namespace to inject the commands, andcommand_to_runwith the specific command you want to run in the selected namespace.
Package: docker-interface
Docker InterfaceDocker Interface (DI) is a declarative interface for building images and running commands in containers using Docker. At Spotify, we use Docker Interface to minimise environment drift by running all of our code in containers–during development, production, or to train machine learning models.Installing Docker InterfaceYou can install Docker Interface using the followingpipcommand (you need a python3 interpreter).pip install docker-interfaceTo check that Docker Interface was installed successfully, rundi --helpUsing Docker InterfaceDocker Interface can be invoked from the command line. By default, it reads the configuration from the filedi.ymlin the current working directory, a basic version of which is shown below.build:tag:name-of-your-imageDocker interface supports two commands:buildbuilds and tags Docker image using the current working directory as the build context.runruns a Docker command in a container and mounts the current working directory with appropriate permissions at/workspaceso you can access your local files without having to rebuild the image.You can find more extensive examples in theexamplesfolderin this repository. You can find more detailed informationhere. Check theschemato get a comprehensive overview of the declarative syntax supported by Docker Interface.Contributing to Docker InterfaceTo contribute to the development of Docker Interface, please create aforkof the repository and send any changes as a pull request.You can test your local installation of Docker Interface as follows.# 0. Set up a virtual environment (optional but recommended)
# 1. Install development requirements
pip install -r requirements.txt
# 2. Run the tests
make testsSeevirtualenvorcondafor details on how to set up a virtual environment in step 0.Code of conductThis project adheres to theOpen Code of Conduct. By participating, you are expected to honour this code.
Package: dockerize
# DockerizeDockerize will pack up your dynamically linked ELF binaries and alltheir dependencies and turn them into a Docker image.Some example images built with this tool are available from:- https://hub.docker.com/u/dockerizeme/## Synopsisusage: dockerize [-h] [--tag TAG] [--cmd CMD] [--entrypoint ENTRYPOINT][--no-build] [--output-dir OUTPUT_DIR] [--add-file SRC DST][--user USER] [--group GROUP] [--filetools] [--verbose][--debug]...positional arguments:pathsoptional arguments:-h, --help            show this help message and exit--add-file SRC DST, -a SRC DSTAdd file <src> to image at <dst>--user USER, -u USER  Add user to /etc/passwd in image--group GROUP, -g GROUPAdd group to /etc/group in image--filetools           Add common file manipulation toolsDocker options:--tag TAG, -t TAG     Tag to apply to Docker image--cmd CMD, -c CMD--entrypoint ENTRYPOINT, -e ENTRYPOINTOutput options:--no-build, -n        Do not build Docker image--output-dir OUTPUT_DIR, -o OUTPUT_DIRLogging options:--verbose--debug## A simple exampleCreate a `sed` image:dockerize -t sed /bin/sedUse it:$ echo hello world | docker run -i sed s/world/jupiterhello jupiter## A more complicated exampleCreate an image named `thttpd`:dockerize -t thttpd \-a /var/www/thttpd /var/www \--entrypoint '/usr/sbin/thttpd -D' \--cmd '-d /var/www' \/usr/sbin/thttpdServe default content:docker run thttpdServe your own content:docker run -v /my/content:/var/www thttpd