Can't update grafana in docker from v 4.6.3 to v 5.2.2

We have Grafana v 4.6.3 docker container installed on Ubuntu machine. It uses volume grafana-storage. When I try to run latest version of grafana container with this volume it fails.

Here’s command I try to run:

 docker run \
    -d \
    -p 3000:3000 \
    --name=grafana-new \
    -v grafana-storage:/var/lib/grafana \
    -e GF_AUTH_ANONYMOUS_ENABLED=true \
    grafana/grafana:5.2.2

Here’re the logs:

~$ docker logs grafana-new
t=2018-08-09T12:00:42+0000 lvl=info msg="Starting Grafana" logger=server version=5.2.2 commit=aeaf7b2 compiled=2018-07-25T11:17:28+0000
t=2018-08-09T12:00:42+0000 lvl=info msg="Config loaded from" logger=settings file=/usr/share/grafana/conf/defaults.ini
t=2018-08-09T12:00:42+0000 lvl=info msg="Config loaded from" logger=settings file=/etc/grafana/grafana.ini
t=2018-08-09T12:00:42+0000 lvl=info msg="Config overridden from command line" logger=settings arg="default.paths.data=/var/lib/grafana"
t=2018-08-09T12:00:42+0000 lvl=info msg="Config overridden from command line" logger=settings arg="default.paths.logs=/var/log/grafana"
t=2018-08-09T12:00:42+0000 lvl=info msg="Config overridden from command line" logger=settings arg="default.paths.plugins=/var/lib/grafana/plugins"
t=2018-08-09T12:00:42+0000 lvl=info msg="Config overridden from command line" logger=settings arg="default.paths.provisioning=/etc/grafana/provisioning"
t=2018-08-09T12:00:42+0000 lvl=info msg="Config overridden from command line" logger=settings arg="default.log.mode=console"
t=2018-08-09T12:00:42+0000 lvl=info msg="Config overridden from Environment variable" logger=settings var="GF_PATHS_DATA=/var/lib/grafana"
t=2018-08-09T12:00:42+0000 lvl=info msg="Config overridden from Environment variable" logger=settings var="GF_PATHS_LOGS=/var/log/grafana"
t=2018-08-09T12:00:42+0000 lvl=info msg="Config overridden from Environment variable" logger=settings var="GF_PATHS_PLUGINS=/var/lib/grafana/plugins"
t=2018-08-09T12:00:42+0000 lvl=info msg="Config overridden from Environment variable" logger=settings var="GF_PATHS_PROVISIONING=/etc/grafana/provisioning"
t=2018-08-09T12:00:42+0000 lvl=info msg="Config overridden from Environment variable" logger=settings var="GF_AUTH_ANONYMOUS_ENABLED=true"
t=2018-08-09T12:00:42+0000 lvl=info msg="Path Home" logger=settings path=/usr/share/grafana
t=2018-08-09T12:00:42+0000 lvl=info msg="Path Data" logger=settings path=/var/lib/grafana
t=2018-08-09T12:00:42+0000 lvl=info msg="Path Logs" logger=settings path=/var/log/grafana
t=2018-08-09T12:00:42+0000 lvl=info msg="Path Plugins" logger=settings path=/var/lib/grafana/plugins
t=2018-08-09T12:00:42+0000 lvl=info msg="Path Provisioning" logger=settings path=/etc/grafana/provisioning
t=2018-08-09T12:00:42+0000 lvl=info msg="App mode production" logger=settings
t=2018-08-09T12:00:42+0000 lvl=info msg="Initializing SqlStore" logger=server
t=2018-08-09T12:00:42+0000 lvl=info msg="Connecting to DB" logger=sqlstore dbtype=sqlite3
t=2018-08-09T12:00:42+0000 lvl=info msg="Starting DB migration" logger=migrator
t=2018-08-09T12:00:42+0000 lvl=info msg="Executing migration" logger=migrator id="Migrate all Read Only Viewers to Viewers"
t=2018-08-09T12:00:42+0000 lvl=eror msg="Executing migration failed" logger=migrator id="Migrate all Read Only Viewers to Viewers" error="attempt to write a               readonly database"
t=2018-08-09T12:00:42+0000 lvl=eror msg="Exec failed" logger=migrator error="attempt to write a readonly database" sql="UPDATE org_user SET role = 'Viewer'               WHERE role = 'Read Only Editor'"
t=2018-08-09T12:00:42+0000 lvl=eror msg="Server shutdown" logger=server reason="Service init failed: Migration failed err: attempt to write a readonly database"

Please help me update grafana

Probably wrong permissions/owner. You need:

$ ls -lah $(docker volume inspect grafana-storage --format "{{.Mountpoint}}")
total 392K
drwxrwxrwx. 3  472  472   37 Aug  9 13:29 .
drwxr-xr-x. 3 root root   18 Aug  9 13:28 ..
-rw-r--r--. 1  472  472 392K Aug  9 13:29 grafana.db
drwxrwxrwx. 2  472  472    6 Jun 29 10:40 plugins

Probably, this command command will fix it:

chown 472:472 --recursive $(docker volume inspect grafana-storage --format "{{.Mountpoint}}")
2 Likes

It helped. Thank you very much.

Why may be this necessary if your are specifying the proper GUID and PUID to the docker image?