Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/CenturyLinkLabs/docker-image-graph
https://github.com/CenturyLinkLabs/docker-image-graph
Last synced: about 1 month ago
JSON representation
- Host: GitHub
- URL: https://github.com/CenturyLinkLabs/docker-image-graph
- Owner: CenturyLinkLabs
- Created: 2014-08-04T22:20:00.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2020-01-24T17:31:43.000Z (almost 5 years ago)
- Last Synced: 2024-08-01T12:28:19.583Z (4 months ago)
- Language: HTML
- Size: 842 KB
- Stars: 113
- Watchers: 16
- Forks: 26
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-starred - CenturyLinkLabs/docker-image-graph - (others)
README
[![Analytics](https://ga-beacon.appspot.com/UA-49491413-7/docker-image-graph/README?pixel)](https://github.com/CenturyLinkLabs/docker-image-graph)
[![](https://badge.imagelayers.io/centurylink/image-graph.svg)](https://imagelayers.io/?images=centurylink/image-graph:latest 'Get your own badge on imagelayers.io')## NOTE
This repo is no longer being maintained. Users are welcome to fork it, but we make no warranty of its functionality.
## image-graph
Generates a nice graph showing the hierarchy of Docker images in your local
image cache.Looks at all of the Docker image layers cached on the local system and
generates a PNG image showing the relationship of the various layers.### Usage
The Ruby *image-graph* script is itself packaged as a Docker image so it can
easily be executed with the Docker *run* command.Since the script interacts with the Docker API in order to inspect your local
image cache it needs access to the Docker API socket. When starting the container, the `-v` flag needs to be used to make the Docker socket available inside the container.By default, when the container is started it will generate a PNG that is streamed to `stdout`:
docker run --rm -v /var/run/docker.sock:/var/run/docker.sock \
centurylink/image-graph > docker_images.pngYou'll need to redirect the container's output to a file in order to save/view the generated image. The name of the output file does not matter, but it is recommended that you use a `.png` extension so that your image viewer will properly recognize the format of the file.
If you supply an environment variabled named *PORT* using the `-e` flag the container will spin-up a web server on the designated port that hosts a web-based version of the image graph:
docker run -d -v /var/run/docker.sock:/var/run/docker.sock \
-e PORT=3000 -p 3000:3000 centurylink/image-graph
In the example above, the web server will be started on port 3000. When using this option you'll also want to use the `-p` flag to map the container port to a port on the host so that you can access the server from outside the container. The container port you specify with the `-p` flag should match the value you specified for the *PORT* environment variable.When a value for the *PORT* envrionment variable is provided, the PNG version of the image is **not** streamed to `stdout`.
### Example
Here's an example graph generated by this utility:
![Sample Image](https://github.com/CenturyLinkLabs/docker-image-graph/raw/master/sample-cmd.png)
And the web-based graph:
![Sample Image](https://github.com/CenturyLinkLabs/docker-image-graph/raw/master/sample-web.png)
### FAQs
**How is this different than running `docker images --viz | dot -Tpng`?**
Actually, it's not different at all. The Ruby script executed by the image
essentially generates the same output that the `--viz` flag does and then pipes
it to the Graphviz *dot* tool to generate the graph.**So, why do we need to execute a container when the same thing can be
achieved with a one-line Docker command?**While this will work for some versions of Docker, the `--viz` flag has been
marked as deprecated and will likely be removed in some future release.Additionally, my primary Docker environment is CoreOS which does not have
Graphviz installed and provides no way for me to install it myself -- in
an environment like this, the only option is to run Graphviz inside a
container.