{"id":15586707,"url":"https://github.com/david-lor/mqtt2docker","last_synced_at":"2025-03-29T09:16:37.199Z","repository":{"id":104269162,"uuid":"222505651","full_name":"David-Lor/MQTT2Docker","owner":"David-Lor","description":"Shell scripts to interact with Docker containers through MQTT","archived":false,"fork":false,"pushed_at":"2019-11-19T18:37:09.000Z","size":8,"stargazers_count":1,"open_issues_count":0,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-03T23:49:04.631Z","etag":null,"topics":["bash","bash-script","container","container-management","containers","docker","docker-container","docker-socket","mqtt","mqtt-bridge","mqtt-client","mqtt-protocol","script","shell","shell-script"],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/David-Lor.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","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":"2019-11-18T17:29:56.000Z","updated_at":"2023-07-19T16:44:41.000Z","dependencies_parsed_at":null,"dependency_job_id":"0c7dbba1-def9-4c4e-8e2e-4bdc4c3bacb0","html_url":"https://github.com/David-Lor/MQTT2Docker","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/David-Lor%2FMQTT2Docker","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/David-Lor%2FMQTT2Docker/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/David-Lor%2FMQTT2Docker/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/David-Lor%2FMQTT2Docker/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/David-Lor","download_url":"https://codeload.github.com/David-Lor/MQTT2Docker/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246162147,"owners_count":20733357,"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":["bash","bash-script","container","container-management","containers","docker","docker-container","docker-socket","mqtt","mqtt-bridge","mqtt-client","mqtt-protocol","script","shell","shell-script"],"created_at":"2024-10-02T21:41:07.944Z","updated_at":"2025-03-29T09:16:37.176Z","avatar_url":"https://github.com/David-Lor.png","language":"Shell","readme":"# MQTT2Docker\n\nBash scripts to perform simple Docker container management through MQTT, and send container events to MQTT.\n\n## Scripts\n\n- **mqtt2docker** subscribes to MQTT and performs simple operations (like Start, Stop) on containers\n- **docker2mqtt** subscribes to Docker events API and publishes them on MQTT\n\n### mqtt2docker\n\nPublish messages to `mqtt/\u003ccontainerName\u003e/cmd` to send commands to a container.\n\nExample: START a container named `portainer`: send a message to the topic `mqtt/portainer/cmd` with the payload `start` (payload is not case-sensitive)\n\n#### Commands (payloads) available\n\n- **START**\n- **STOP**\n- **RESTART**\n- **PAUSE**\n- **UNPAUSE**\n- **KILL**\n\n### docker2mqtt\n\nThe script will publish all events occurring on a container to `mqtt/\u003ccontainerName\u003e/stat`.\n\nExample: when a container named `portainer` starts: a message to the topic `mqtt/portainer/stat` is published with the payload `start`.\n\n### Env variables\n\nUse environment variables as configurations:\n\n- **MQTT_HOST**: host where the MQTT broker is running (if not specified: `localhost`)\n- **MQTT_UID**: UID of the user that will run the `mosquitto_sub`/`mosquitto_pub` commands (if not specified: `1000`)\n\n```bash\nsudo bash MQTT_HOST=127.0.0.1 MQTT_UID=1000 mqtt2docker.sh\n```\n\n### Premises\n\n- Scripts read or write on the Docker API socket (`/var/run/docker.sock`), so they must run as root\n- Scripts are written in pure Bash, but require `mosquitto-client` (MQTT client) and `jq` (JSON parser) packages\n- Calls to `mosquitto_pub` and `mosquitto_sub` are performed by another user different than root\n- Both scripts can run on Docker containers mapping the `/var/run/docker.sock` as a bind volume\n\n## TODO\n\n- Create Docker images\n- (More) Setting customization - or pass arguments to the script to be part of the `mosquitto_sub`/`mosquitto_pub` args\n- Add binary pub/sub endpoints (ON/OFF - like payloads)\n\n## Changelog\n\n- 0.1 - Initial release\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdavid-lor%2Fmqtt2docker","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdavid-lor%2Fmqtt2docker","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdavid-lor%2Fmqtt2docker/lists"}