{"id":19357101,"url":"https://github.com/stealthybox/docker-demo","last_synced_at":"2025-04-23T10:33:11.496Z","repository":{"id":53344750,"uuid":"81273020","full_name":"stealthybox/docker-demo","owner":"stealthybox","description":"Multi-Node Swarm on your laptop /w Docker-in-Docker -- Fun Stackfiles","archived":false,"fork":false,"pushed_at":"2017-10-09T21:40:03.000Z","size":14,"stargazers_count":15,"open_issues_count":0,"forks_count":3,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-04-02T14:11:17.323Z","etag":null,"topics":["dind","docker","docker-stack","docker-swarm","infrastructure-as-code","scheduler","swarm-mode"],"latest_commit_sha":null,"homepage":"","language":"Shell","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/stealthybox.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":"2017-02-08T01:22:19.000Z","updated_at":"2023-01-31T22:35:06.000Z","dependencies_parsed_at":"2022-09-11T04:40:48.890Z","dependency_job_id":null,"html_url":"https://github.com/stealthybox/docker-demo","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/stealthybox%2Fdocker-demo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stealthybox%2Fdocker-demo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stealthybox%2Fdocker-demo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stealthybox%2Fdocker-demo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/stealthybox","download_url":"https://codeload.github.com/stealthybox/docker-demo/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250416978,"owners_count":21427106,"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":["dind","docker","docker-stack","docker-swarm","infrastructure-as-code","scheduler","swarm-mode"],"created_at":"2024-11-10T07:06:20.084Z","updated_at":"2025-04-23T10:33:06.482Z","avatar_url":"https://github.com/stealthybox.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"This repo contains useful things for playing with Docker Swarm Mode.\n\nThere is automation here for running a swarm with multiple hosts on a single machine using containers as managers and workers.\n\nThere are also several stack files which serve as a starting point for understanding the scheduler and playing with different use-cases.\n\n\n# Run a Swarm in Containers\n```bash\ncd swarm\nsource start\n```\nThis exports some environment vars into your shell.\nIf you are already part of a swarm, ignore the error.\n```bash\ndocker stack up admin -c ../admin/docker-compose.yaml\n# alternatively, `cd ../admin \u0026\u0026 docker-compose up -d`\n```\nIn a few moments, you should see a visualization @ [localhost:8090](http://localhost:8090) showing your host and any swarm services.\n```bash\ndocker-compose up -d worker\n# you should see a worker node join the swarm\ndocker-compose scale worker=4\n# 3 more should join in a few seconds\n```\nYou now have a multi-host swarm that you can play around in.\nFor speed, configure your docker engine to use:\n```json\n\"registry-mirrors\": [\n  \"http://localhost:5000\"\n]\n```\nWhen you're done, `cd swarm \u0026\u0026 ./kill`.\n\n## Some Helpful Commands\n```\nexport DOCKER_HIDE_LEGACY_COMMANDS=true\ndocker --help\ndocker node ls\ndocker node --help\ndocker stack ls\ndocker stack --help\ndocker service ls\ndocker service --help\ndocker service inspect \u003cSERVICE\u003e --pretty\n\n# list all node's engine labels:\nfor nid in `docker node Wls -q`; do docker node inspect $nid -f \"{{.Description.Engine.Labels}}\"; done\n```\n\n## How it Works\nThe `start` script:\n- ensures a swarm exists\n- exports the join tokens as env vars\n- exports the `{{.Swarm.NodeAddr}}` as `$HOST_IP`\n\n`swarm/docker-compose.yaml` depends on these env vars.\nIt contains services for managers and workers.\nThese services run **docker in docker** (`dind`) as priviledged containers on the host.\nThe `entrypoint` is overridden to run an inline shell script that:\n- starts the container's `dockerd` with overlay2 and the `admin_mirror`\n- traps interrupts\n- waits until `docker info` succeeds\n- joins the host's swarm with the service's `$TOKEN`\n\nYou can classify nodes by adding `--label` flags to the `$opts`.\nThese are engine labels which shouldn't be confused with swarm node labels.\n\n# Using Stacks\nStack files allow you to use the [docker-compose schema](https://docs.docker.com/compose/compose-file/) to declare a desired state for many related services.\nThese services will achieve their desired state through the swarm scheduler.\n\nThis repo contains a few different stack files that demonstrate neat use cases.\n\nYou can deploy a stack by running:\n```bash\ndocker stack up -c stack_name/docker-compose.yaml stack_name\n```\nYou can change the file and run the command again to watch swarm remediate the state.\n\nThe **admin** stack is recommended since it runs services that help you understand and speed up what you are doing.\n\nTry the **minio** stack if you want to play with a self-hosted, distributed, S3 compatible object store.\n\nThe **routing** stack is great for trying `traefik`, a dynamically configured load-balancer.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstealthybox%2Fdocker-demo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstealthybox%2Fdocker-demo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstealthybox%2Fdocker-demo/lists"}