A distributed container orchestration system built in Go that manages Docker containers across multiple nodes using etcd for coordination, with automatic load balancing via Traefik and monitoring through Prometheus.
- Distributed Scheduling: Automatically schedules containers on available nodes based on resource capacity
- Load Balancing: Integrated Traefik for automatic domain-based routing and SSL termination
- Monitoring: Prometheus metrics collection for system resources and container health
- Cluster Management: etcd-based coordination for node discovery and state management
- REST API: HTTP API for container lifecycle management
- Resource Awareness: Intelligent node scoring based on CPU, memory, and disk availability
The system consists of multiple components:
- Control Plane: Manages cluster state, scheduling decisions, and API endpoints
- Worker Nodes: Run containers and report resource metrics
- etcd: Distributed key-value store for coordination
- Traefik: Reverse proxy and load balancer with dynamic configuration
- Prometheus: Metrics collection and monitoring
- Grafana: Dashboard for visualization (optional)
- Go 1.25+
- Docker and Docker Compose
- Linux environment with Docker socket access
-
Clone the repository
git clone https://github.com/shakirmengrani/distributed_docker.git cd distributed_docker -
Configure the system Edit
config.ymlto set your node configuration:prefix: "master" address: "127.0.0.1:8000" control_plane: "127.0.0.1:8000" etcd: "http://etcd:2379"
-
Start the cluster
docker-compose up -d
-
Build and run the application
go build -o dist-docker ./dist-docker
GET /health- Service health status
GET /info- Node resource information and capacity status
POST /container- Create a new containerGET /container?name=<name>- Get container detailsPOST /container/remove- Remove a containerGET /container/list- List all containers
POST /container/connect- Connect domain to existing container
POST /member- Add a new cluster memberGET /member/list- List all cluster members
GET /metrics- Prometheus metrics endpoint
Create a container with domain routing:
POST /container
{
"name": "my-app",
"domain": ["my-app.example.com"],
"image": "nginx:latest",
"port": 80,
"environments": ["ENV=production"],
"volumes": {"/data": {}},
"workingDir": "/app",
"cmd": ["nginx", "-g", "daemon off;"]
}Access monitoring interfaces:
- Prometheus: http://localhost:9090
- Grafana: http://localhost:3000 (admin/admin)
- Traefik Dashboard: http://localhost:8081
prefix: "master" # Node identifier
address: "127.0.0.1:8000" # Node listen address
control_plane: "127.0.0.1:8000" # Control plane address
etcd: "http://etcd:2379" # etcd endpoint- app: Go application container
- etcd: Distributed key-value store
- prometheus: Metrics collection
- grafana: Visualization dashboard
- traefik: Reverse proxy and load balancer
go build -o dist-docker main.gogo test ./...docker-compose up --build- Fork the repository
- Create a feature branch
- Make your changes
- Add tests
- Submit a pull request
This project is licensed under the MIT License - see the LICENSE file for details.