Simulate a multi-node server environment using Docker Compose. Each container runs Ubuntu with SSH, named uniquely and mapped to an auto-incremented host port—ideal for testing distributed software and configuration management tools.
On Ubuntu, for example:
sudo apt update
sudo apt install docker-ce docker-ce-cli containerd.io
sudo usermod -aG docker ${USER} && su - ${USER}
git clone https://github.com/Pradipbabar/MultiNodeTestLab.git
cd MultiNodeTestLab
ssh-keygen -t rsa -b 4096
docker-compose up -d
List running containers:
docker ps
SSH into a container (replace `
ssh -i ~/.ssh/id_rsa -p root@localhost
The core definitions live in docker-compose.yml
:
services:
node1:
build: .
container_name: node1
ports:
- "2201:22"
node2:
build: .
container_name: node2
ports:
- "2202:22"
# …
Adjust the nodes/
directory to add startup scripts, custom packages, or configuration for
each node.