docker-network-graph/README.md

73 lines
2.2 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
2024-01-13 17:31:01 +01:00
This repository fork [e-dant/docker-network-graph](https://github.com/e-dant/docker-network-graph)
Changes:
- Improved design
- Added the ability to generate url
- Added display of connections with the host
2024-01-13 21:29:41 +01:00
- Github package
2016-09-29 23:59:45 +02:00
2018-08-31 15:31:13 +02:00
## Example
2024-01-13 17:31:01 +01:00
![example graph](./example.png)
2018-08-31 15:31:13 +02:00
2018-08-31 04:50:58 +02:00
## Usage
2024-01-13 17:37:07 +01:00
```bash
2024-01-13 17:31:01 +01:00
usage: docker-network-graph.py [-h] [-v] [-o OUT] [-u]
2018-11-27 07:37:31 +01:00
Visualize docker networks.
2018-08-31 04:50:58 +02:00
optional arguments:
2024-01-13 17:31:01 +01:00
-h, --help Show this help message and exit
2018-08-31 04:50:58 +02:00
-v, --verbose Verbose output
2024-01-13 17:31:01 +01:00
-o OUT, --out OUT Write output to file [not supported by container]
-u, --url Generate link for GraphvizOnline
2024-01-13 17:37:07 +01:00
```
2018-08-31 04:50:58 +02:00
2024-01-13 17:31:01 +01: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:
2024-01-13 17:37:07 +01:00
```bash
2024-01-13 18:15:22 +01:00
docker run --rm -v /var/run/docker.sock:/var/run/docker.sock ghcr.io/muratovas/docker-network-graph:latest -u
2024-01-13 17:37:07 +01:00
```
2024-01-13 17:31:01 +01: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.
## Running local
2018-08-31 04:50:58 +02:00
In most cases what you want to run are the following couple commands:
2024-01-13 17:37:07 +01:00
```bash
git clone https://github.com/muratovas/docker-network-graph.git
cd docker-network-graph
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.
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
## Development
If you'd like to contribute to this project, there is a sample docker-compose file
using dummy containers in `test`.
2024-01-13 18:15:22 +01:00
You can deploy it using
```bash
docker-compose -f docker-compose.yml up -d
```
2024-01-13 17:31:01 +01:00
## Credit
2024-01-13 17:37:07 +01:00
2024-01-13 17:32:28 +01:00
[dot lang](https://www.graphviz.org/doc/info/lang.html)
2024-01-13 17:37:07 +01:00
2024-01-13 17:32:28 +01:00
[gvonline](https://dreampuf.github.io/GraphvizOnline/)