matomo-org / docker

Official Docker project for Matomo Analytics
https://matomo.org
Other
850 stars 349 forks source link

Version 5.0.1 not updated after docker pull #347

Open vandman opened 10 months ago

vandman commented 10 months ago

Hi, I have been using Matomo for a while now. I pull the latest image from docker hub and the upgrade did not work or was not done?

look at the website message: image

In my docker compose file, i specified the version just to be sure:

version: '3'

services:
  matomo:
    image: matomo:5.0.1
    container_name: matomo
    restart: unless-stopped
    volumes:
      - matomo_www:/var/www/html
      - $PWD/config:/var/www/html/config
      # Use MaxMind GeoLite2 databases:
      - /var/lib/GeoIP/:/var/www/html/misc/
    environment:
      - MATOMO_DATABASE_HOST=matomo-mariadb
      - MATOMO_DATABASE_ADAPTER=mysql
      - MATOMO_DATABASE_TABLES_PREFIX=matomo_
      - MATOMO_DATABASE_USERNAME=${MYSQL_USER}
      - MATOMO_DATABASE_PASSWORD=${MYSQL_PASSWORD}
      - MATOMO_DATABASE_DBNAME=${MYSQL_DATABASE}
      - TOKEN_AUTH=${TOKEN_AUTH}
    healthcheck:
      test: curl http://localhost/index.php?module=API&method=API.getMatomoVersion&token_auth=${TOKEN_AUTH}

docker image ls | grep matomo
matomo                       5.0.1               3354df586779   5 days ago       583MB
matomo                       latest              3354df586779   5 days ago       583MB
``

Am I missing something or is it a bug?

Regards,
Pierre NIKOLOV
alewis001 commented 10 months ago

I think this might be due to you not running through the upgrade process in the admin pages. The matomo source that's built into the container (in /usr/src/matomo) is copied to the mounted volume (/var/www/html) on startup of the container but only if the matomo source is not already present in that volume. So, even if you're running the 5.0.1 image, if there was already a version of matomo in the volume, let's say v4, then it will be v4 that will actually be served/running until the update process is run.

bovender commented 6 months ago

I ran into the same problem -- pulled a newer image from Docker Hub, but Matomo was stuck in the old version.

The hint with the volume is correct. In my case, I got confused because my docker-compose.yml did not explicitly declare the volume /var/www/html. However, this is done in the upstream Dockerfile: https://github.com/matomo-org/docker/blob/8137a7127656d793a7da44fdef7b147b931ba68f/Dockerfile-debian.template#L98

Thus, upgrading Matomo by pulling an image with a newer tag can never work by itself. The image creates a volume, and Matomo won't upgrade itself because the volume exists.

Steps to remedy this situation:

docker compose stop matomo

# remove the container so the volume is being released
docker compose rm matomo

# remove the volume
# it's hard to find the correct anonymous volume, therefore I use `prune`
# caveat: this may remove other dangling volumes as well!
docker volume prune

# ... do vim-magic or emacs-magic to update the Matomo image tag in your docker-compose.yml ...
# then:
docker compose up -d matomo

IMPORTANT: Think twice before removing the volume! Is all your precious data, e.g. config files, kept safe in separate volumes?

YMMV.