A docker-compose file contains the definition of all the services that needs to run in harmony to successfully deploy an app stack.
When services and their interactions are defined clearly in a compose file manually charting a block diagram to list those services and their interaction is redundant, isn't it ? that was the thought I had when I needed to chart a block diagram for documenting my architecture.
A quick search using "tool to convert a docker compose file to a block diagram" yielded this awesome repo https://github.com/pmsipilot/docker-compose-viz
The code in this repo will help us to chart a block diagram from a docker compose file.
Lets create one!
-
Sample docker-compose of a simple SaaS stack
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersversion: '3.4' services: rabbitmq: image: rabbitmq:3-management ports: - "15672:15672" - "5672:5672" deploy: replicas: 1 placement: constraints: [node.role == manager] microservice: image: nameko-microservice restart: always deploy: replicas: 1 depends_on: - rabbitmq - logstash db: image: mariadb:10.3 volumes: - ./mysqldb_data:/var/lib/mysql ports: - "3306:3306" deploy: replicas: 1 placement: constraints: [node.role == manager] resources: reservations: memory: 128M limits: memory: 256M restapi: image: restapi restart: always ports: - "8000:8000" deploy: mode: global depends_on: - db - microservice - logstash nginx: image: ui restart: always ports: - "80:80" deploy: replicas: 1 depends_on: - restapi elasticsearch: image: elasticsearch:2 command: elasticsearch -Des.network.host=0.0.0.0 ports: - "9200:9200" - "9300:9300" kibana: image: kibana:latest build: kibana/ volumes: - ./kibana/config/:/opt/kibana/config/ ports: - "5601:5601" depends_on: - elasticsearch logstash: build: logstash/ command: logstash -f /etc/logstash/conf.d/logstash.conf image: logstash:latest volumes: - ./logstash/config:/etc/logstash/conf.d ports: - "5000:5000" depends_on: - elasticsearch -
Command to execute
docker run --rm -it \ --name dcv \ -v /home/user/blog:/input pmsipilot/docker-compose-viz \ render -m image \ --force docker-compose.yml \ --output-file=topology.png \ --no-volumes \ --no-ports \ --no-networks
Ouptput
- Command - With port numbers
docker run --rm -it \ --name dcv \ -v /home/user/blog:/input pmsipilot/docker-compose-viz \ render -m image \ --force docker-compose.yml \ --output-file=topology.png \ --no-volumes \ --no-networks
docker run --rm -it \ --name dcv \ -v /home/user/blog:/input pmsipilot/docker-compose-viz \ render -m image \ --force docker-compose.yml \ --output-file=topology.png \ --no-ports \ --no-networks
- Ouptput - with volumes
Top comments (0)