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-11-27 07:37:31 +01:00
|
|
|
Visualize docker networks.
|
2018-08-31 04:50:58 +02:00
|
|
|
|
|
|
|
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:
|
|
|
|
|
2018-11-27 07:37:31 +01:00
|
|
|
git clone https://github.com/LeoVerto/docker-network-graph.git
|
|
|
|
cd docker-network-graph
|
2018-08-31 04:50:58 +02:00
|
|
|
pipenv install
|
2018-11-27 07:37:31 +01:00
|
|
|
pipenv run python docker-net-graph.py -o output.svg
|
2018-08-31 04:50:58 +02:00
|
|
|
|
2018-11-27 07:37:31 +01:00
|
|
|
This will generate an .svg file containing the graph.
|
2018-08-31 05:16:34 +02:00
|
|
|
|
|
|
|
## 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
|
|
|
|
2018-11-27 07:37:31 +01:00
|
|
|
This will just generate and output the graph in the [DOT Language][dot].
|
|
|
|
You can then paste that code into [GraphvizOnline][gvonline]
|
|
|
|
to render it. The recommended rendering engine is `fdp`.
|
|
|
|
|
|
|
|
Alternatively, if you prefer to render locally, you can run
|
|
|
|
`fdp -Tpng -o out.png` on a system with graphviz installed,
|
|
|
|
paste the previous output there, press enter and finally CTRL+C to
|
|
|
|
generate the file.
|
2018-08-31 16:38:22 +02:00
|
|
|
|
2018-08-31 21:51:03 +02:00
|
|
|
|
|
|
|
For more advanced use cases you can append arguments to the `docker run`
|
2018-11-27 07:37:31 +01:00
|
|
|
command as if you were running it in a local shell.
|
|
|
|
|
|
|
|
[dot]: https://www.graphviz.org/doc/info/lang.html
|
|
|
|
[gvonline]: https://dreampuf.github.io/GraphvizOnline/
|