{"id":38513821,"url":"https://github.com/dmonroy/docker-services","last_synced_at":"2026-01-17T06:25:10.963Z","repository":{"id":57423320,"uuid":"120260390","full_name":"dmonroy/docker-services","owner":"dmonroy","description":"Uses docker to spawn containers for services required during tests","archived":false,"fork":false,"pushed_at":"2020-05-30T02:22:28.000Z","size":27,"stargazers_count":4,"open_issues_count":2,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-11-29T22:18:19.158Z","etag":null,"topics":["docker","pytest","python"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dmonroy.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-02-05T05:45:30.000Z","updated_at":"2020-05-30T02:20:50.000Z","dependencies_parsed_at":"2022-09-05T09:50:13.098Z","dependency_job_id":null,"html_url":"https://github.com/dmonroy/docker-services","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/dmonroy/docker-services","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dmonroy%2Fdocker-services","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dmonroy%2Fdocker-services/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dmonroy%2Fdocker-services/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dmonroy%2Fdocker-services/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dmonroy","download_url":"https://codeload.github.com/dmonroy/docker-services/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dmonroy%2Fdocker-services/sbom","scorecard":{"id":348236,"data":{"date":"2025-08-11","repo":{"name":"github.com/dmonroy/docker-services","commit":"53c80c63a975c435dba711cc3ab12d72cf183416"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3,"checks":[{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Code-Review","score":0,"reason":"Found 1/26 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 6 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-18T07:41:32.115Z","repository_id":57423320,"created_at":"2025-08-18T07:41:32.115Z","updated_at":"2025-08-18T07:41:32.115Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28502221,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-17T04:31:57.058Z","status":"ssl_error","status_checked_at":"2026-01-17T04:31:45.816Z","response_time":85,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["docker","pytest","python"],"created_at":"2026-01-17T06:25:10.821Z","updated_at":"2026-01-17T06:25:10.951Z","avatar_url":"https://github.com/dmonroy.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"Uses docker to spawn containers for services required during tests\n\n[![Build Status](https://travis-ci.org/dmonroy/docker-services.svg?branch=master)](https://travis-ci.org/dmonroy/docker-services)\n\n# Install\n\nThis project is available on pypi, so you can use _pip_ to install it:\n\n```\npip install docker-services\n```\n\nOr include it as a dependency on `setup.py` or a `requirements.txt` file, whatever you prefer.\n\n\n# Use it\n\n## 1. Configure your project services\n\nYou need to start listing all services that your project depends on and leverage on _docker-services_ to maintain the lifecycle of those services during test runs.\n\nThis must happen using either the `docker_services` config option on any pytest _.cfg/.ini_ file or on a `.services.yaml` file, the value for that option requires a yaml structure where top level members are the service names and their values can be either an empty value, image name or a or an object.\n\nDue to limitations of ini files, full support for yaml is not available on .cfg/.ini files, if you need complex config then usage of the `.services.yaml` file is encouraged.\n\nThis is a basic example for a project that depends on a `postgres` service:\n\n```\n[pytest]\ndocker_services=postgres:\n```\n\nThis is the same:\n\n```\n[pytest]\ndocker_services=\n    postgres:\n```\n\nAnd this:\n\n```\n[pytest]\ndocker_services=\n    postgres: postgres\n```\n\nAnd this too (on .services.yaml):\n\n```yaml\npostgres:\n    image: postgres\n```\n\nAnd guess what?... this too!\n\n```yaml\ndatabase:\n    name: postgres\n    image: postgres\n```\n\nIf the projects depends different services, list all of them:\n\n```\n[pytest]\ndocker_services=\n    postgres:\n    redis:\n```\n\nWhen image name is not specified (and I bet you already noticed this) it falls back to use the service name as image name, but it is possible to specify the image name and version to use:\n\n```\n[pytest]\ndocker_services=\n    postgres: postgres:10\n```\n\nAlso this way:\n\n```yaml\npostgres:\n    image: postgres:10\n```\n\nNow the service name is `postgres` and image name is `postgres:10`.\n\nAnother option is to use a different name for the service, something like:\n\n```\n[pytest]\ndocker_services=\n    db: postgres:10\n```\n\n```yaml\ndb:\n    image: postgres:10\n```\n\nNow service name is `db` and image name is `postgres:10`.\n\nIf you don't want (or need) to set a specific image version, just ignore the version part like this:\n\n```\n[pytest]\ndocker_services=\n    db: postgres\n```\n\nAlso you are able to use images from a private registry:\n\n```\n[pytest]\ndocker_services=\n    db: my.registry.com/custom/postgres\n```\n\n### 1.1. Configure environment variables for your services\n\nYou may want to customize the behaviour of your services by setting environment variables, it is also possible by adding to the config (valid only when using the `.services.yaml` file).\n\n```yaml\ndb:\n    image: postgres:10\n    environment:\n        POSTGRES_USERNAME: myuser\n        POSTGRES_PASSWORD: $3cr3t\n        POSTGRES_DB: mydb\n```\n\nUsing that config above the _db_ service is now initialized with `POSTGRES_USERNAME`, `POSTGRES_PASSWORD` and `POSTGRES_DB` environment variables.\n\nThose variables are also exposed to the actual session, so you can consume those values from within your app or tests too.\n\n### 1.2. Configure dynamic variables too\n\nAre you planning to configure a `DATABASE_URL` environment variable based on service's port number?... then don't wait and configure a variable template ;).\n\nTalking about the `DATABASE_URL` for postgres one usually expects something like `postgres://user:password@host:port/dbname`, and that can be achieved by replacing\n\n```yaml\npostgres:\n    image: postgres:10\n    environment:\n        POSTGRES_USERNAME: myuser\n        POSTGRES_PASSWORD: $3cr3t\n        POSTGRES_DB: mydb\n        _templates:\n            POSTGRES_PORT: \"{env[POSTGRES_PORT_5432_TCP_PORT]}\"\n            DATABASE_URL: \"postgres://myuser:$s3cr3t@localhost:{env[POSTGRES_PORT_5432_TCP_PORT]}/mydb\"\n```\n\nIt is also possible to use environment variables defined for the service, so you don't repeat the same:\n\n```\nDATABASE_URL: \"postgres://{env[POSTGRES_USERNAME]}:{env[POSTGRES_PASSWORD]}@localhost:{env[POSTGRES_PORT_5432_TCP_PORT]}/{env[POSTGRES_DB]}\"\n```\n\nThe parameters on the template are replaced using python's `.format()` method and at the moment only `env` parameter is passed and it references actually to the content of `os.environ`, so all environment variables are available.\n\n## 2. Run tests with docker-services enabled\n\n_docker-services_ adds the `--use-docker-services` command line option for _py.test_, when setting this option it enables service's spawning using docker, run it like this:\n\n```\npy.test --docker-services\n```\n\n## 3. Communicate with the services\n\nWe spawn our services because we need to communicate with them during test sessions, either to consume data from or publish data to. For that `docker_services` rely on service's exposed ports to create unique environment variables for each port and protocol exposed on each of the services.\n\nThe variable names follows the same conventions as in environment variables created from [links](https://docs.docker.com/network/links/#environment-variables), but for now we only create the `*_PORT` environment variables, assuming docker is running on local machine and ports exposed to localhost.\n\nSo, if we have a `postgres` service we expect to communicate using port 5432, now looking at the [Dockerfile](https://github.com/docker-library/postgres/blob/674466e0d47517f4e05ec2025ae996e71b26cae9/10/Dockerfile) we can confirm that it [exposes port 5432](https://github.com/docker-library/postgres/blob/674466e0d47517f4e05ec2025ae996e71b26cae9/10/Dockerfile#L132).\n\nPlease note that _docker_services_ creates environment variables for exposed ports only, if service's image doesn't expose any port then no `*_PORT` variable would be reated.\n\nFor the `postgres` service use case, variable name for port `5432` would be: `POSTGRES_PORT_5432_TCP_PORT`, this variable name is built using this template: `{service_name}_PORT_{port}_{protocol}_PORT`.\n\nAlso remember that environment variables configured for a service are also available within the context of the pytest session, this applies to both static and dynamic variables!\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdmonroy%2Fdocker-services","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdmonroy%2Fdocker-services","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdmonroy%2Fdocker-services/lists"}