{"id":13582994,"url":"https://github.com/rjchicago/docker-event-stream","last_synced_at":"2025-04-06T18:31:45.091Z","repository":{"id":57138990,"uuid":"455586509","full_name":"rjchicago/docker-event-stream","owner":"rjchicago","description":"A simple, lightweight, zero-dependency EventEmitter for Docker Events.","archived":false,"fork":false,"pushed_at":"2022-03-11T17:15:04.000Z","size":62,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-01T04:03:40.965Z","etag":null,"topics":["docker","docker-events","eventemitter","events","nodejs","swarm"],"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/rjchicago.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":"2022-02-04T14:54:55.000Z","updated_at":"2025-02-27T23:01:46.000Z","dependencies_parsed_at":"2022-08-29T00:03:02.014Z","dependency_job_id":null,"html_url":"https://github.com/rjchicago/docker-event-stream","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rjchicago%2Fdocker-event-stream","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rjchicago%2Fdocker-event-stream/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rjchicago%2Fdocker-event-stream/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rjchicago%2Fdocker-event-stream/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rjchicago","download_url":"https://codeload.github.com/rjchicago/docker-event-stream/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247530971,"owners_count":20953881,"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":["docker","docker-events","eventemitter","events","nodejs","swarm"],"created_at":"2024-08-01T15:03:10.863Z","updated_at":"2025-04-06T18:31:44.796Z","avatar_url":"https://github.com/rjchicago.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"# docker-event-stream\n\nA simple, lightweight, zero-dependency NodeJS [EventEmitter](https://nodejs.org/api/events.html#class-eventemitter) for [Docker Events](https://docs.docker.com/engine/reference/commandline/events/).\n\n## installation\n\n``` sh\nnpm install @rjchicago/docker-event-stream --save\n```\n\n## init\n\nCall `DockerEventStream.init()` to initialize. By default, `DockerEventStream` will emit **all** events for both scopes `local` and `swarm`.\n\nYou may pass `options` in the init call to connect a remote host, limit or filter events.\n\n``` js\nconst options = {\n  host: $HOST, // hostname or IP\n  port: $PORT, // i.e. 2375\n  since: $SINCE, // i.e. '10s'\n  filter: {\n    $FILTER1_KEY: $FILTER1_VALUE, // i.e. scope: 'local'\n    $FILTER2_KEY: $FILTER2_VALUE, // i.e. type: 'container'\n    $FILTER3_KEY: [ $FILTER3_VALUE1, $FILTER3_VALUE2 ] // i.e. event: [ 'start', 'die' ]\n  }\n}\n```\n\n## use\n\nIn this demo, we'll use the default configuration and log all events to console.\n\nDemo `index.js`:\n\n``` javascript\nconst DockerEventStream = require('@rjchicago/docker-event-stream');\n\nDockerEventStream.init();\nDockerEventStream.on('event', console.log);\n```\n\nTo bring up our demo app, run the following...\n\n``` sh\n# create demo folder\nmkdir docker-event-stream-demo\ncd docker-event-stream-demo\n\n# init\nnpm init -y\nnpm install -s @rjchicago/docker-event-stream\n\n# create demo index.js\necho \"const DockerEventStream = require('@rjchicago/docker-event-stream');\nDockerEventStream.init();\nDockerEventStream.on('event', console.log);\" \u003e index.js\n\n# run demo\nnode index.js\n```\n\nNext, in another shell, test an event:\n\n``` sh\ndocker run --rm alpine echo \"hello\"\n```\n\nIn the application shell, you will see the stream of docker events...\n\n``` js\n{\n  status: 'create',\n  id: 'd5af2dc4f43d6866bd2a8991a0584268ac5aad94b7014ff5c5dfa2f1259037bd',\n  from: 'alpine:3.15',\n  Type: 'container',\n  Action: 'create',\n  Actor: {\n    ID: 'd5af2dc4f43d6866bd2a8991a0584268ac5aad94b7014ff5c5dfa2f1259037bd',\n    Attributes: { image: 'alpine:3.15', name: 'random_name' }\n  },\n  scope: 'local',\n  time: 1643984948,\n  timeNano: 1643984948954996500\n}\n```\n\n## options\n\n### since\n\nSee [Docker Events docs](https://docs.docker.com/engine/reference/commandline/events/#limiting-filtering-and-formatting-the-output)\n\n* `since` can be Unix timestamps, date formatted timestamps, or Go duration strings (e.g. 10m, 1h30m).\n* if you do not provide the `since` option, only new and/or live events will be emitted.\n\n### filtering\n\nSee [Docker Events docs](https://docs.docker.com/engine/reference/commandline/events/#limiting-filtering-and-formatting-the-output)\n\n\u003e The currently supported filters are:\n\u003e  \n\u003e * config (config=`name or id`)\n\u003e * container (container=`name or id`)\n\u003e * daemon (daemon=`name or id`)\n\u003e * event (event=`event action`)\n\u003e * image (image=`repository or tag`)\n\u003e * label (label=`key` or label=`key`=`value`)\n\u003e * network (network=`name or id`)\n\u003e * node (node=`id`)\n\u003e * plugin (plugin=`name or id`)\n\u003e * scope (scope=`local or swarm`)\n\u003e * secret (secret=`name or id`)\n\u003e * service (service=`name or id`)\n\u003e * type (type=`container or image or volume or network or daemon or plugin or service or node or secret or config`)\n\u003e * volume (volume=`name`)\n\nNOTE:\n\n\u003e * using the same filter multiple times will be handled as `OR`.\n\u003e * using multiple filters will be handled as `AND`.\n\n#### example\n\nThe following will listen on \"local\" events since \"30s\" ago from containers \"foo\" `OR` \"bar\" only:\n\n``` js\nconst options = {\n  since: 30s,\n  filter: {\n    scope: 'local',\n    container: ['foo', 'bar']\n  }\n}\n```\n\n## docker-compose\n\nWhen running Node.js inside of Docker, you need map the docker socket under volumes in your docker-compose.yml:\n\n``` yaml\n    volumes:\n      - /var/run/docker.sock:/var/run/docker.sock\n```\n\n\u003e See [docker](./examples/docker) under [examples](./examples)\n\n## publish\n\nIncrement the package version and commit with the follow message format:\n\n\u003e `Release ${VERSION}`\n\nThe GitHub Actions Workflow is automated using [publish-to-npm](https://github.com/marketplace/actions/publish-to-npm)\n\n## contribution\n\nPlease do! Open a pull request with your code or idea and let's chat!\n\n## license\n\n\u003e see [LICENSE](./LICENSE)\n\n[![GitHub Super-Linter](https://github.com/rjchicago/docker-event-stream/workflows/Lint%20Code%20Base/badge.svg)](https://github.com/marketplace/actions/super-linter)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frjchicago%2Fdocker-event-stream","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frjchicago%2Fdocker-event-stream","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frjchicago%2Fdocker-event-stream/lists"}