A Docker-in-Docker (DinD) Orchestrator designed to run Docker Compose inside a container and dynamically generate services. This setup enables the ability to define services within Docker, allowing for extensible, scalable, and self-contained container orchestration.
docker-compose.yml file dynamically.docker-compose.yml and scale them dynamically.docker pull comanderanch/dind-orchestrator:latest
Before running the container, set up directories for volume mappings to persist configurations.
mkdir -p ~/cpp-orchestrator/generated_files
mkdir -p ~/cpp-orchestrator/config
docker run -d --privileged --name dind-runner \
-p 8080:80 \
-v ~/cpp-orchestrator/generated_files:/app/generated_files \
-v /var/run/docker.sock:/var/run/docker.sock \
comanderanch/dind-orchestrator
Note:
--privilegedis required for DinD to function properly.
To persist generated compose files and configuration files, the following volume mappings are used:
| Host Path | Container Path | Purpose |
|---|---|---|
~/cpp-orchestrator/generated_files | /app/generated_files | Stores generated docker-compose.yml |
/var/run/docker.sock | /var/run/docker.sock | Allows Docker commands inside the container |
Once inside the dind-runner container:
docker exec -it dind-runner sh
cd /app/generated_files
docker-compose up -d
This will start all services defined in
docker-compose.ymldynamically generated inside the container.
By default, containers may exit after execution. To keep services running indefinitely, update the docker-compose.yml:
version: '3.8'
services:
ubuntu-node:
image: ubuntu:22.04
command: ["sleep", "infinity"]
restart: always
Then, re-run:
docker-compose up -d
To add more services dynamically:
docker-compose.yml inside the container (/app/generated_files/docker-compose.yml) nginx:
image: nginx:latest
ports:
- "8081:80"
volumes:
- ./config/nginx.conf:/etc/nginx/nginx.conf:ro
docker-compose up -d
Using Nginx or another reverse proxy inside DinD, services can be stacked and routed dynamically.
8080) and internally distribute between services.nginx.conf to route services correctly.server {
listen 80;
location /service1 {
proxy_pass http://service1:8000;
}
location /service2 {
proxy_pass http://service2:9000;
}
}
Use the docker-compose.yml inside dind-runner to define the services and forward traffic accordingly.
Once the image is working as expected:
docker tag dind-orchestrator comanderanch/dind-orchestrator:latest
docker push comanderanch/dind-orchestrator:latest
dind-runner container start.With Docker-in-Docker (DinD) Orchestrator, you can define and stack services dynamically inside a container.
š” This setup allows for multi-container orchestration without needing a separate VM or external host management.
Feel free to fork, modify, and contribute to this setup!
I am a beginner at all of this. And I owe the Desire and means to learn and try to do something great too help in the open source community to my nephew and best freind <thehomebuiscuit> thank you b the hack-shak forever!!!
Content type
Image
Digest
sha256:efcc1e3c9ā¦
Size
288 MB
Last updated
over 1 year ago
docker pull comanderanch/dind-orchestrator