Grafana on Docker on Mac! Under 1 minute!

What do you do when you have a minute to spare and just have a Mac with Docker running?

Well, you install Grafana! In under a minute! And then clean up the workspace!

So here goes

Pre – requisites – a Mac running Docker (duh!)

Next, get an image of Grafana going!

docker run -d -p 3000:3000 grafana/grafana 

This should pull in the image and configure Grafana on port 3000!

ayans-mbp:~ ayan$ docker run -d -p 3000:3000 grafana/grafana
Unable to find image 'grafana/grafana:latest' locally
latest: Pulling from grafana/grafana
a5a6f2f73cd8: Pull complete 
08e6195c0f29: Pull complete 
b7bd3a2a524c: Pull complete 
d3421658103b: Pull complete 
cd7c84229877: Pull complete 
49917e11f039: Pull complete 
Digest: sha256:b9a31857e86e9cf43552605bd7f3c990c123f8792ab6bea8f499db1a1bdb7d53
Status: Downloaded newer image for grafana/grafana:latest
73c3bacda79bca85bac23d8857447d2d31f31467e0940032523d9d42c5b5b0a7

So about 15 secs! Now get that image/container up (defaults) and run in foreground (save time)

yans-mbp:~ ayan$ docker run grafana/grafana
t=2019-01-11T13:25:20+0000 lvl=info msg="Starting Grafana" logger=server version=5.4.2 commit=d812109 branch=HEAD compiled=2018-12-13T12:49:23+0000
t=2019-01-11T13:25:20+0000 lvl=info msg="Config loaded from" logger=settings file=/usr/share/grafana/conf/defaults.ini
t=2019-01-11T13:25:20+0000 lvl=info msg="Config loaded from" logger=settings file=/etc/grafana/grafana.ini
t=2019-01-11T13:25:20+0000 lvl=info msg="Config overridden from command line" logger=settings arg="default.paths.data=/var/lib/grafana"
t=2019-01-11T13:25:20+0000 lvl=info msg="Config overridden from command line" logger=settings arg="default.paths.logs=/var/log/grafana"
t=2019-01-11T13:25:20+0000 lvl=info msg="Config overridden from command line" logger=settings arg="default.paths.plugins=/var/lib/grafana/plugins"
t=2019-01-11T13:25:20+0000 lvl=info msg="Config overridden from command line" logger=settings arg="default.paths.provisioning=/etc/grafana/provisioning"
t=2019-01-11T13:25:20+0000 lvl=info msg="Config overridden from command line" logger=settings arg="default.log.mode=console"
t=2019-01-11T13:25:20+0000 lvl=info msg="Config overridden from Environment variable" logger=settings var="GF_PATHS_DATA=/var/lib/grafana"
t=2019-01-11T13:25:20+0000 lvl=info msg="Config overridden from Environment variable" logger=settings var="GF_PATHS_LOGS=/var/log/grafana"
t=2019-01-11T13:25:20+0000 lvl=info msg="Config overridden from Environment variable" logger=settings var="GF_PATHS_PLUGINS=/var/lib/grafana/plugins"
t=2019-01-11T13:25:20+0000 lvl=info msg="Config overridden from Environment variable" logger=settings var="GF_PATHS_PROVISIONING=/etc/grafana/provisioning"
t=2019-01-11T13:25:20+0000 lvl=info msg="Path Home" logger=settings path=/usr/share/grafana
t=2019-01-11T13:25:20+0000 lvl=info msg="Path Data" logger=settings path=/var/lib/grafana

Keep the session running! Quickly open a separate terminal and check the containers

ayans-mbp:~ ayan$ docker container ls
CONTAINER ID        IMAGE               COMMAND             CREATED              STATUS              PORTS                    NAMES
61099371d59a        grafana/grafana     "/run.sh"           About a minute ago   Up About a minute   3000/tcp                 practical_neumann
73c3bacda79b        grafana/grafana     "/run.sh"           4 minutes ago        Up 4 minutes        0.0.0.0:3000->3000/tcp   xenodochial_banzai

Now open your favourite browser (Chrome 🙂 ) and browse to localhost:3000

Grafana

Sweet! Log in – admin/admin

Grafana Login Page Password

Change your password or Skip (skip – we are 40 secs in!)

And Welcome to your Dashboard!

Grafana Dashboard

Not bad! Now, how do we get this container removed? (This is just a test, we don’t really need the data/install – so we remove it the quick and easy way)

Open a Terminal and kill the running instances (list above)

ayans-mbp:~ ayan$ docker kill 61099371d59a
61099371d59a
ayans-mbp:~ ayan$ docker kill 73c3bacda79b
73c3bacda79b

Now, remove the containers

ayans-mbp:~ ayan$ docker container prune
WARNING! This will remove all stopped containers.
Are you sure you want to continue? [y/N] y
Deleted Containers:
61099371d59a3186c095ac96ff4e9029ba1ffd958d3d7d8c1a646e70ea1ee3b4
73c3bacda79bca85bac23d8857447d2d31f31467e0940032523d9d42c5b5b0a7

Total reclaimed space: 819.2kB

And remove the image

ayans-mbp:~ ayan$ docker image list
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
grafana/grafana     latest              6f18ddf9e552        4 weeks ago         243MB
ayans-mbp:~ ayan$ docker image rm 6f18ddf9e552
Untagged: grafana/grafana:latest
Untagged: grafana/grafana@sha256:b9a31857e86e9cf43552605bd7f3c990c123f8792ab6bea8f499db1a1bdb7d53
Deleted: sha256:6f18ddf9e552921525b5279cddd90bf5fe778c5f20ac3a27fd1a0e32f1763fe6
Deleted: sha256:ac285917b6524e097ca03c89a072981797e30a009de3289ca08c5c0fd05881d7
Deleted: sha256:37a8dee692db2f0c62579dc27bf3f4dd49e1d73a45063ec663207ce0d4f0cdbf
Deleted: sha256:23b47fb1bf679276c6dc35c5396acc9fa700215980435509a1b7a4c892455617
Deleted: sha256:1d9efb990380c40838963cb6a52c58b91e6262b413839e802bc9ce4035845da7
Deleted: sha256:1a7aac37eed31ba176acfbfdf1cef42fecd5b91396ebbb05c00d7becccfb248d
Deleted: sha256:ef68f6734aa485edf13a8509fe60e4272428deaf63f446a441b79d47fc5d17d3

There you go! A Grafana install in Docker on a Mac! In a minute!

Comments

No comments yet. Why don’t you start the discussion?

Leave a Reply

Your email address will not be published. Required fields are marked *