docker-network-graph/README.md

56 lines
1.8 KiB
Markdown
Raw Normal View History

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
![example graph](https://raw.githubusercontent.com/e-dant/docker-network-graph/release/example.png)
2018-08-31 15:31:13 +02:00
2018-08-31 04:50:58 +02:00
## Usage
usage: docker-network-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:
git clone https://github.com/e-dant/docker-network-graph.git
2018-11-27 07:37:31 +01:00
cd docker-network-graph
2018-08-31 04:50:58 +02:00
pipenv install
pipenv run python docker-network-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.
## 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:
docker run --rm -v /var/run/docker.sock:/var/run/docker.sock e-dant/docker-network-graph
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
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/
## Development
If you'd like to contribute to this project, there is a sample docker-compose file
using dummy containers in `test`.
You can deploy it using `docker-compose -f test/docker-compose.yml up -d`.