2018-08-31 04:50:58 +02:00
|
|
|
# Docker Network Graph
|
2016-09-29 23:59:45 +02:00
|
|
|
|
2018-08-31 13:55:22 +02:00
|
|
|
Visualize the relationship between Docker networks and containers
|
|
|
|
as a neat graphviz graph.
|
2016-09-29 23:59:45 +02:00
|
|
|
|
|
|
|
|
2018-08-31 15:31:13 +02:00
|
|
|
## Example
|
2018-08-31 21:51:03 +02:00
|
|
|
![example graph](https://raw.githubusercontent.com/LeoVerto/docker-network-graph/master/example.png)
|
2018-08-31 15:31:13 +02:00
|
|
|
|
2018-08-31 04:50:58 +02:00
|
|
|
## Usage
|
|
|
|
usage: docker-net-graph.py [-h] [-v] [-o OUT]
|
2016-09-29 23:59:45 +02:00
|
|
|
|
2018-08-31 04:50:58 +02:00
|
|
|
Generate docker network graph.
|
|
|
|
|
|
|
|
optional arguments:
|
|
|
|
-h, --help show this help message and exit
|
|
|
|
-v, --verbose Verbose output
|
|
|
|
-o OUT, --out OUT Write output to file
|
|
|
|
|
|
|
|
In most cases what you want to run are the following couple commands:
|
|
|
|
|
|
|
|
git clone https://github.com/LeoVerto/docker-network-graph-poc.git
|
|
|
|
cd docker-network-graph-poc
|
|
|
|
pipenv install
|
|
|
|
pipenv run python docker-net-graph.py -o output.gv
|
|
|
|
|
2018-08-31 05:16:34 +02:00
|
|
|
This will end up generating a .pdf file containing the graph.
|
|
|
|
|
|
|
|
## Running inside docker
|
|
|
|
If you want to generate a graph for a remote system you can also easily
|
|
|
|
run this script inside a pre-built docker container:
|
|
|
|
|
2018-08-31 13:58:52 +02:00
|
|
|
docker run --rm -v /var/run/docker.sock:/var/run/docker.sock leoverto/docker-network-graph
|
2018-08-31 05:16:34 +02:00
|
|
|
|
|
|
|
This will just generate and output the graph. You can then run
|
2018-08-31 06:23:07 +02:00
|
|
|
`fdp -Tpdf -o out.pdf`or `fdp -Tpng -o out.png` on a system with
|
2018-08-31 05:16:34 +02:00
|
|
|
graphviz installed, paste the previous output there, press enter
|
2018-08-31 16:38:22 +02:00
|
|
|
and finally CTRL+C to generate the file.
|
|
|
|
|
2018-08-31 16:55:50 +02:00
|
|
|
Alternatively, you can use [this website](https://dreampuf.github.io/GraphvizOnline/) for an online version of Graphviz.
|
|
|
|
The recommended render engine is `fdp`.
|
2018-08-31 21:51:03 +02:00
|
|
|
|
|
|
|
For more advanced use cases you can append arguments to the `docker run`
|
|
|
|
command as if you were running it in a local shell.
|