This document provides the exact procedure to decouple the monolithic docker-compose.yml into a fully distributed, cross-hypervisor microservice architecture.
To demonstrate cross-platform interoperability, the application stack is split across three distinct virtualized environments on the host machine.
mysql (Database Engine)192.168.130.170 (Bridged)ollama (Local LLM) + searxng (Web Search)192.168.130.171 (Bridged)app (Streamlit Web Interface)192.168.130.172 (NAT/Bridged via Hyper-V switch)To ensure these isolated VMs can communicate, you must configure a Bridged Virtual Switch:
ufw or Windows Firewall for the 192.168.130.0/24 subnet on all hosts.On VM 1, create a docker-compose.yml containing only the MySQL service.
services:
mysql:
build:
context: ./docker/mysql
ports:
- "3306:3306"
- "161:161/udp" # Expose SNMP
volumes:
- mysql_data:/var/lib/mysql
On VM 2, create a docker-compose.yml containing the AI services.
services:
ollama:
image: ollama/ollama:latest
ports:
- "11434:11434"
- "161:161/udp" # Requires sidecar or custom image for SNMP
searxng:
image: searxng/searxng:latest
ports:
- "8080:8080"
On VM 3, configure the App container to point to the external IP addresses rather than Docker DNS hostnames.
Update your .env file on WSL2:
DB_HOST=192.168.130.170
OLLAMA_HOST=http://192.168.130.171:11434
SEARXNG_HOST=http://192.168.130.171:8080
By default, Docker containers run a single process (PID 1). To run snmpd alongside the application in every container, we use supervisord.
Example Dockerfile Modification for App Container:
RUN apt-get update && apt-get install -y supervisor snmpd
COPY snmpd.conf /etc/snmp/snmpd.conf
COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf
EXPOSE 8501 161/udp
CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"]
supervisord.conf:
[supervisord]
nodaemon=true
[program:app]
command=streamlit run app.py
autorestart=true
[program:snmpd]
command=/usr/sbin/snmpd -f
autorestart=true
192.168.130.170:8081), navigate to Configuration > Hosts.192.168.130.170, 192.168.130.171, 192.168.130.172).