Whenever I'm testing code that sends metrics to Graphite, I usually depend on a shared graphite instance that we have accessible on the network as Graphite is quite a lot of work to install locally. Today though, I realised that we can use Docker to run a Graphite instance for testing. Fifteen minutes later, I have a working Graphite instance that works perfectly.
First, you need docker installed.
Once you have Docker, you need an image to run. I ended up using this one from hopsoft. To download and start the image, run the following command:
sudo docker run -d \
--name graphite \
-p 81:80 \
-p 2003:2003 \
-p 8125:8125/udp \
This is almost identical to the command provided in the README, except it runs the web UI on
localhost:81 rather than
localhost:80. I do this because I already have things listening on port 80.
Docker should download all the required dependencies and start the container. Visit
http://localhost:81 and you should see the Graphite UI.
Once you're done testing, you can stop the container with
docker stop graphite. If you want to remove the data completely, you can run
docker rm docker.
If you just stopped the container, you can restart it at any point in the future with
docker start graphite. If you removed the container, you'll need to use the
docker run command above to recreate it (although all the dependencies should be cached)