{"id":13526910,"url":"https://github.com/markbirbeck/docker-engine","last_synced_at":"2025-04-11T18:21:22.431Z","repository":{"id":57213938,"uuid":"136086402","full_name":"markbirbeck/docker-engine","owner":"markbirbeck","description":"A Docker Engine API client for Node, driven at run-time by Docker's Swagger definition.","archived":false,"fork":false,"pushed_at":"2018-08-13T11:14:11.000Z","size":113,"stargazers_count":4,"open_issues_count":1,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-25T14:12:34.095Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/markbirbeck.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-06-04T21:45:40.000Z","updated_at":"2023-11-17T19:55:51.000Z","dependencies_parsed_at":"2022-08-29T02:10:50.430Z","dependency_job_id":null,"html_url":"https://github.com/markbirbeck/docker-engine","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/markbirbeck%2Fdocker-engine","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/markbirbeck%2Fdocker-engine/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/markbirbeck%2Fdocker-engine/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/markbirbeck%2Fdocker-engine/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/markbirbeck","download_url":"https://codeload.github.com/markbirbeck/docker-engine/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248036064,"owners_count":21037092,"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":[],"created_at":"2024-08-01T06:01:37.265Z","updated_at":"2025-04-11T18:21:22.405Z","avatar_url":"https://github.com/markbirbeck.png","language":"JavaScript","readme":"# docker-engine\n\nA Docker Engine API client for Node, driven at run-time by Docker's Swagger definition.\n\n## Usage\n\nTo use `docker-engine` do:\n\n```javascript\nconst client = await dockerEngine()\n```\n\nThis will connect to the Docker API using the default values (for example, `/var/run/docker.sock` to connect).\n\n### Connecting to a Docker Swarm on AWS\n\nTo use an SSH tunnel to connect to a swarm that has been set up using the [Docker for AWS instructions](https://docs.docker.com/docker-for-aws/), use config like the following:\n\n```javascript\nconst client = await dockerEngine({\n  username: 'docker',\n  privateKey: require('fs').readFileSync(__dirname + '/docker-swarm.pem', 'utf8'),\n  host: 'ec2-54-183-237-159.us-west.compute-1.amazonaws.com',\n  socketPath: '/var/run/docker.sock'\n})\n```\n\nTo output logging information on tunnel connections set the `DEBUG` environment variable:\n\n```shell\nDEBUG=docker-engine:tunnel \\\nDOCKER_AWS=ec2-54-183-237-159.us-west.compute-1.amazonaws.com \\\n  tap test/test.js\n```\n\n## Why?\n\nThere are a number of excellent modules that allow you to connect to the Docker Engine API, but each of them caused me a problem in different ways. Whilst looking at making changes to these modules I realised that all a Docker API client needed was to use the Swagger file that Docker provides.\n\n[harbor-master](https://www.npmjs.com/package/harbor-master): Has a minor issue with some endpoints. [I investigated how to fix this](https://github.com/arhea/harbor-master/issues/6#issuecomment-393490613) and discovered that the API endpoint definitions use Joi; since Swagger files are maintained by Docker themselves, I felt that this was the wrong way to go.\n\n[dockerode](https://www.npmjs.com/package/dockerode): Dockerode also takes the approach of maintaining 'by hand' the connections between itself and the Docker API definitions. An example is the code required to [implement the 'inspect container' endpoint](https://github.com/apocas/dockerode/blob/master/lib/container.js#L46). As with `harbor-master` I felt that this part of the module should be driven by the Swagger file.\n\n[docker-client](https://www.npmjs.com/package/docker-client): This module *is* driven the Swagger file. It's not dynamic--the client is generated with a code-generator that uses the Swagger file as input--but it would have been fine for my purposes. However, I was completely unable to get it to work with my local Docker Swarm. That's almost certain to be my fault, but I couldn't wait any longer, so had to move on. Note that because the client is generated it will be aligned with a specific version, whilst an approach that uses the Swagger file at *run-time* could be more dynamic.\n\n## Our Approach\n\nKey to the approach we've taken here is:\n\n* to use the Swagger file as a *single source of truth* to drive the creation of the client. And more specifically, to do this at *run-time* so that the same module can be used for any version of the Docker API, without needing to be continually updated;\n* to use ES6 proxies to allow the client methods to be wrapped and so present different kinds of interfaces to developers. This makes it very easy to present `harbor-master`- or `docker-client`-compatible interfaces that still benefit from being Swagger-driven.\n","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarkbirbeck%2Fdocker-engine","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmarkbirbeck%2Fdocker-engine","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarkbirbeck%2Fdocker-engine/lists"}