{"id":13463683,"url":"https://github.com/muayyad-alsadi/docker-glue","last_synced_at":"2025-10-25T17:30:49.544Z","repository":{"id":147752499,"uuid":"41751583","full_name":"muayyad-alsadi/docker-glue","owner":"muayyad-alsadi","description":"Automated unattended pluggable docker management","archived":false,"fork":false,"pushed_at":"2015-09-01T16:58:38.000Z","size":128,"stargazers_count":8,"open_issues_count":0,"forks_count":0,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-08-01T14:02:40.104Z","etag":null,"topics":["docker","docker-container","load-balancer"],"latest_commit_sha":null,"homepage":"https://github.com/muayyad-alsadi/docker-glue","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/muayyad-alsadi.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-09-01T16:56:38.000Z","updated_at":"2019-07-06T10:17:35.000Z","dependencies_parsed_at":"2023-03-27T21:48:15.334Z","dependency_job_id":null,"html_url":"https://github.com/muayyad-alsadi/docker-glue","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/muayyad-alsadi%2Fdocker-glue","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/muayyad-alsadi%2Fdocker-glue/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/muayyad-alsadi%2Fdocker-glue/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/muayyad-alsadi%2Fdocker-glue/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/muayyad-alsadi","download_url":"https://codeload.github.com/muayyad-alsadi/docker-glue/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":219865234,"owners_count":16555929,"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-container","load-balancer"],"created_at":"2024-07-31T14:00:26.484Z","updated_at":"2025-10-25T17:30:49.247Z","avatar_url":"https://github.com/muayyad-alsadi.png","language":"Python","funding_links":[],"categories":["Docker, Linux containers and Kubernetes"],"sub_categories":[],"readme":"# Docker Glue\n\nAutomated unattended pluggable docker management based on docker events.\nCan be used to update load-balancers, DNS, service discovery, ...etc. \nManaging docker containers would be as simple as tagging them with some labels\n\n## Use Cases\n\n- Dynamically add/remove containers to/from load-balancer (currently `haproxy` using `jinja2` templates)\n- can send traffic of a specific domain to corresponding containers based on Host HTTP header\n- can send traffic of a specific path prefix to corresponding containers \n- Replace `docker0` bridge,docker-proxy, ...etc with more advanced `SDN` (like `OVS` or OpenStack Neutron).\n- Run a specific handler code (python plugins) or handler script based on docker events\n- publish containers inspection to discovery service (like `etcd`)\n\n## Daemons\n\n- `docker-glue` the modular pluggable daemon that can run handlers and scripts\n- `docker-balancer` a standalone daemon that just updates `haproxy` (a special case of glue)\n\nYou can pass `-1` to run once, and `-w` to wait for events, and `-h` for details. \n\n## Requirements and Installation\n\n```\nyum install haproxy python-docker-py python-jinja2\ncp docker-balancer.service /etc/systemd/system/docker-balancer.service\ncp docker-glue.service /etc/systemd/system/docker-glue.service\n```\n\n## Using Docker Balancer\n\nyou can set labels like (replace 80 with any port):\n\n- `glue_http_80_host` the HTTP host to which this container would be attached in the load-balancer\n- `glue_http_80_prefix` the prefix (without leading `/`) to attach it to\n- `glue_http_80_strip_prefix` pass `1` if the prefix should be stripped before passing to backend\n- `glue_http_80_weight` the weight (defaults to 100)\n\nlet's assume that you have started `docker-balancer -w` or the `docker-balancer` service\n\n```\ndocker run -d --name wp1 -l glue_http_80_host='wp1.example.com' mywordpress/wordpress \ndocker run -d --name wp2 -l glue_http_80_host='wp2.example.com' mywordpress/wordpress \ndocker run -d --name os-ui1 -l glue_http_80_host=openstack.example.com -l glue_http_80_prefix=dashboard/horizon myopenstack/horizon\ndocker run -d --name os-id1 -l glue_http_80_host=openstack.example.com -l glue_http_80_prefix=identity/keystone myopenstack/keystone\n```\n\n## Using Docker Glue\n\nin `docker-glue.d` you have many `.example` files copy the files you need to remove that extension, for example\n```\ncd docker-glue.d\ncp lb.ini.example lb.ini\ncp test.ini.example test.ini\ncd ..\n```\n\nthen start `docker-glue` daemon or run `docker-glue -w`\n\n## Handlers INI files\n\nfiles in `docker-glue.d/*.ini` (we have included examples) looks like this\n\n```\n[handler]\nclass=DockerGlue.handlers.exec.ScriptHandler\nevents=all\nenabled=1\ntriggers-none=0\n\n[params]\nscript=test-handler.sh\ndemo-option=some value\n```\n\n`handler` section specifies what and when to run\n\n- `class` the handler plugin, which can be one of \n  - `DockerGlue.handlers.exec.ScriptHandler` executes a shell script\n    - `test-handler.sh` a demo script that logs the event to `/tmp/docker-glue-test.log`\n    - `ovs-handler.sh` connect the container to `OpenVSwicth`\n  - `DockerGlue.handlers.lb.HAProxyHandler` load balancer that uses HAProxy\n  - `DockerGlue.handlers.publishers.distconfig.Publisher` publish containers to discovery service like etcd\n- `events` the even statuses (comma separated) that triggers this handler, can be `none` (which is dummy event) or `all` (which does not include `none`)\n- `enabled`\n- `triggers-none` - set it if you want this handler to triggers `none` dummy event\n\n`params` section is custom params to be passed to the handler\n\n\n## Writing script plugins\n\nscripts in `handler-scripts` will be passed the ini path and docker event and the docker container id for example it might be like this `test-handler.sh test.ini start 123456`\n\nthe code of `test-handler.sh` look like this\n\n```bash\n#! /bin/bash\n\ncd `dirname $0`\n\nfunction error() {\n    echo \"$@\"\n    exit -1\n}\n\n[ $# -ne 3 ] \u0026\u0026 error \"Usage `basename $0` config.ini status container_id\"\nini=\"$1\"\nstatus=\"$2\"\ncontainer_id=\"$3\"\nini_demo_option=$( crudini --inplace --get $ini params demo-option 2\u003e/dev/null || : )\necho \"`date +%F` container_id=[$container_id] status=[$status] ini_demo_option=[$ini_demo_option]\" \u003e\u003e /tmp/docker-glue-test.log\n```\n\nas you can see you can read options using `crudini` from the passed ini file.\n\n## Writing python plugins\n\njust extend `BaseHandler` and in the `__init__` do what ever you need, and read your custom params from the ini and implement a handle method like this\n\n\n```python\nfrom . import BaseHandler\n\nlogger = logging.getLogger(__name__)\n\nclass DemoHandler(BaseHandler):\n    def __init__(self, agent, ini_file, ini):\n        BaseHandler.__init__(self, agent, ini_file, ini)\n        self.custom_param=ini.get('params', 'custom_param') if ini.has_option('params', 'custom_param') else None\n        \n    def handle(self, event, container_id):\n        logger.info('got event=%r on container=%r and custom_param=%r', event, container_id, self.custom_param)\n\n```\n\n## TODO\n\n- implement TCP/UDP load balancing using ipvsadm or keepalived\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmuayyad-alsadi%2Fdocker-glue","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmuayyad-alsadi%2Fdocker-glue","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmuayyad-alsadi%2Fdocker-glue/lists"}