docker-network-graph
docker-network-graph copied to clipboard
GraphViz not present in Docker image
When trying to render the dot output directly through the Docker image, it complaines about a missing dependency:
root@panda ~/.tmp # docker run --rm -v /var/run/docker.sock:/var/run/docker.sock:ro -v ${PWD}:/usr/src/app/.tmp leoverto/docker-network-graph -o .tmp/panda.svg
Traceback (most recent call last):
File "/usr/local/lib/python3.9/site-packages/graphviz/backend.py", line 164, in run
proc = subprocess.Popen(cmd, startupinfo=get_startupinfo(), **kwargs)
File "/usr/local/lib/python3.9/subprocess.py", line 951, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "/usr/local/lib/python3.9/subprocess.py", line 1821, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'dot'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/src/app/docker-net-graph.py", line 211, in <module>
generate_graph(args.verbose, args.out)
File "/usr/src/app/docker-net-graph.py", line 193, in generate_graph
g.render(base)
File "/usr/local/lib/python3.9/site-packages/graphviz/files.py", line 243, in render
rendered = backend.render(self._engine, format, filepath,
File "/usr/local/lib/python3.9/site-packages/graphviz/backend.py", line 223, in render
run(cmd, capture_output=True, cwd=cwd, check=True, quiet=quiet)
File "/usr/local/lib/python3.9/site-packages/graphviz/backend.py", line 167, in run
raise ExecutableNotFound(cmd)
graphviz.backend.ExecutableNotFound: failed to execute ['dot', '-Ksfdp', '-Tsvg', '-O', 'panda'], make sure the Graphviz executables are on your systems' PATH
I get the same problem without using the docker image. Just followed the git clone steps.
❯ pipenv run python docker-net-graph.py -o output.svg
Traceback (most recent call last):
File "/Users/miketobias/.local/share/virtualenvs/docker-network-graph-uwAAFihC/lib/python3.9/site-packages/graphviz/backend.py", line 164, in run
proc = subprocess.Popen(cmd, startupinfo=get_startupinfo(), **kwargs)
File "/opt/homebrew/Cellar/[email protected]/3.9.12/Frameworks/Python.framework/Versions/3.9/lib/python3.9/subprocess.py", line 951, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "/opt/homebrew/Cellar/[email protected]/3.9.12/Frameworks/Python.framework/Versions/3.9/lib/python3.9/subprocess.py", line 1821, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'dot'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/miketobias/git/LeoVerto/docker-network-graph/docker-net-graph.py", line 211, in <module>
generate_graph(args.verbose, args.out)
File "/Users/miketobias/git/LeoVerto/docker-network-graph/docker-net-graph.py", line 193, in generate_graph
g.render(base)
File "/Users/miketobias/.local/share/virtualenvs/docker-network-graph-uwAAFihC/lib/python3.9/site-packages/graphviz/files.py", line 243, in render
rendered = backend.render(self._engine, format, filepath,
File "/Users/miketobias/.local/share/virtualenvs/docker-network-graph-uwAAFihC/lib/python3.9/site-packages/graphviz/backend.py", line 223, in render
run(cmd, capture_output=True, cwd=cwd, check=True, quiet=quiet)
File "/Users/miketobias/.local/share/virtualenvs/docker-network-graph-uwAAFihC/lib/python3.9/site-packages/graphviz/backend.py", line 167, in run
raise ExecutableNotFound(cmd)
graphviz.backend.ExecutableNotFound: failed to execute ['dot', '-Ksfdp', '-Tsvg', '-O', 'output'], make sure the Graphviz executables are on your systems' PATH
However, I was not able to replicate the problem via the docker command. I received the expected output and was able to paste it into the site linked in the README to see my graph.