{"id":14155229,"url":"https://github.com/PDMLab/docker-compose","last_synced_at":"2025-08-06T01:30:42.908Z","repository":{"id":5024538,"uuid":"93658106","full_name":"PDMLab/docker-compose","owner":"PDMLab","description":"Manage Docker-Compose via Node.js","archived":false,"fork":false,"pushed_at":"2024-08-15T13:42:26.000Z","size":1227,"stargazers_count":193,"open_issues_count":28,"forks_count":78,"subscribers_count":6,"default_branch":"master","last_synced_at":"2024-08-16T21:52:14.378Z","etag":null,"topics":["devops-tools","docker","docker-compose","nodejs","testing-tools"],"latest_commit_sha":null,"homepage":"https://pdmlab.github.io/docker-compose/","language":"TypeScript","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/PDMLab.png","metadata":{"files":{"readme":"readme.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-06-07T16:47:18.000Z","updated_at":"2024-08-16T21:52:14.378Z","dependencies_parsed_at":"2024-03-28T14:38:34.134Z","dependency_job_id":"6a59ec45-3370-4d7e-92fb-e1bcc4b2e499","html_url":"https://github.com/PDMLab/docker-compose","commit_stats":{"total_commits":314,"total_committers":34,"mean_commits":9.235294117647058,"dds":0.3853503184713376,"last_synced_commit":"ccc9566a17f512a10d8ae010b380ed49bfd1535a"},"previous_names":[],"tags_count":47,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PDMLab%2Fdocker-compose","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PDMLab%2Fdocker-compose/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PDMLab%2Fdocker-compose/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PDMLab%2Fdocker-compose/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/PDMLab","download_url":"https://codeload.github.com/PDMLab/docker-compose/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":215735785,"owners_count":15923388,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["devops-tools","docker","docker-compose","nodejs","testing-tools"],"created_at":"2024-08-17T08:02:34.117Z","updated_at":"2025-08-06T01:30:42.888Z","avatar_url":"https://github.com/PDMLab.png","language":"TypeScript","readme":"[![Conventional Commits](https://img.shields.io/badge/Conventional%20Commits-1.0.0-yellow.svg)](https://conventionalcommits.org)\n[![Discord](https://img.shields.io/discord/1070453198000767076)](https://discord.gg/pR6duvNHtV)\n\u003cimg src=\"https://img.shields.io/github/actions/workflow/status/pdmlab/docker-compose/ci.yml?branch=master\" /\u003e\n\u003cimg src=\"https://img.shields.io/npm/dm/docker-compose.svg\" /\u003e\n\n# Manage Docker-Compose via Node.js\n\n`docker-compose` is a small library that allows you to run [docker-compose](https://docs.docker.com/compose/) (which is still required) via Node.js. This is useful to bootstrap test environments.\n\nAs of version 1.0, this library supports `docker compose` (v2, the docker \"compose\" plugin) by default. The `docker-compose` (v1) has been removed from recent releases of Docker Desktop and is no longer supported. However, you can still force the use of `docker-compose` by using the [standanlone mode](#standalone-mode).\n\n## Installation\n\n```bash\nyarn add --dev docker-compose\n```\n\n## Documentation\n\nThe documentation can be found [here](https://pdmlab.github.io/docker-compose/).\n\n## Example\n\n### Import for `docker-compose`\n\n```ts\nimport * as compose from 'docker-compose'\n```\n\nYou can also import only the required commands:\n\n```ts\nimport { run, upAll } from 'docker-compose'\n```\n\n### Usage\n\nTo start service containers based on the `docker-compose.yml` file in your current directory, just call `compose.upAll` like this:\n\n```javascript\ncompose.upAll({ cwd: path.join(__dirname), log: true }).then(\n  () =\u003e {\n    console.log('done')\n  },\n  (err) =\u003e {\n    console.log('something went wrong:', err.message)\n  }\n)\n```\n\nStart specific services using `compose.upMany`:\n\n```javascript\nconst services = ['serviceA', 'serviceB']\ncompose.upMany(services, { cwd: path.join(__dirname), log: true })\n```\n\nOr start a single service with `compose.upOne`:\n\n```javascript\nconst service = 'serviceA'\ncompose.upOne(service, { cwd: path.join(__dirname), log: true })\n```\n\nTo execute command inside a running container\n\n```javascript\ncompose.exec('node', 'npm install', { cwd: path.join(__dirname) })\n```\n\nTo list the containers for a compose project\n\n```javascript\nconst result = await compose.ps({ cwd: path.join(__dirname) })\nresult.data.services.forEach((service) =\u003e {\n  console.log(service.name, service.command, service.state, service.ports)\n  // state is e.g. 'Up 2 hours'\n})\n```\n\nThe `--format json` command option can be used to get a better state support:\n\n```javascript\nconst result = await compose.ps({ cwd: path.join(__dirname), commandOptions: [[\"--format\", \"json\"]] })\nresult.data.services.forEach((service) =\u003e {\n  console.log(service.name, service.command, service.state, service.ports)\n  // state is one of the defined states: paused | restarting | removing | running | dead | created | exited\n})\n```\n\n### Standalone mode\n\nWhile the `docker-compose` executable is no longer part of a default docker installation, it is still possible to download its binary [standalone](https://docs.docker.com/compose/install/standalone/). This is useful for example when building docker images, avoiding the need to install the whole docker stack.\n\nTo use a standalone binary, you can set the `executable.standalone` option to `true`. You can also set the `executablePath` option to the path of the `docker-compose` binary.\n\n```js\ncompose.upAll({\n   executable: {\n      standalone: true,\n      executablePath: '/path/to/docker-compose' // optional\n   }\n})\n```\n\n## Known issues\n\n* During testing we noticed that `docker compose` seems to send its exit code also commands don't seem to have finished. This doesn't occur for all commands, but for example with `stop` or `down`. We had the option to wait for stopped / removed containers using third party libraries but this would make bootstrapping `docker-compose` much more complicated for the users. So we decided to use a `setTimeout(500)` workaround. We're aware this is not perfect, but it seems to be the most appropriate solution for now. Details can be found in the [v2 PR discussion](https://github.com/PDMLab/docker-compose/pull/228#issuecomment-1422895821) (we're happy to get help here).\n\n## Running the tests\n\nWhile `docker-compose` runs on Node.js 6+, running the tests requires you to use Node.js 8+ as they make use of `async/await`.\n\n```bash\nyarn test\n```\n\n## Want to help?\n\nThis project is just getting off the ground and could use some help with cleaning things up and refactoring.\n\nIf you want to contribute - we'd love it! Just open an issue to work against so you get full credit for your fork. You can open the issue first so we can discuss and you can work your fork as we go along.\n\nIf you see a bug, please be so kind as to show how it's failing, and we'll do our best to get it fixed quickly.\n\nBefore sending a PR, please [create an issue](https://github.com/PDMLab/docker-compose/issues/new) to introduce your idea and have a reference for your PR.\n\nWe're using [conventional commits](https://www.conventionalcommits.org), so please use it for your commits as well.\n\nAlso please add tests and make sure to run `yarn lint`.\n\n### Discussions\n\nIf you want to discuss an `docker-compose` issue or PR in more detail, feel free to [start a discussion](https://github.com/PDMLab/docker-compose/discussions).\n\n## License\n\nMIT License\n\nCopyright (c) 2017 - 2021 PDMLab\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n","funding_links":[],"categories":["nodejs"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FPDMLab%2Fdocker-compose","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FPDMLab%2Fdocker-compose","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FPDMLab%2Fdocker-compose/lists"}