I have the following docker-compose file to run Matomo:
version: "2"
services:
matomo:
image: matomo
environment:
- MATOMO_DATABASE_HOST=matomo_db
- VIRTUAL_HOST=webmon.extinctionrebellion.uk
env_file:
- ./db.env
ports:
- 8088:80
volumes:
- ./config:/var/www/html/config:rw
- ./logs:/var/www/html/logs
- ./matomo:/var/www/html
depends_on:
- matomo_db
restart: unless-stopped
matomo_db:
container_name: matomo_db
image: mariadb
command: --max-allowed-packet=64MB
environment:
- MYSQL_ROOT_PASSWORD=passwordredacted
env_file:
- ./db.env
volumes:
- ./mysql/:/var/lib/mysql
restart: unless-stopped
I mostly use Matomo for analysing log files, so I have a shell script that imports them, using the command:
cat /var/log/nginx/myserver.access.log.1 /var/log/nginx/myserver.access.log | docker-compose exec -T matomo python3 misc/log-analytics/import_logs.py --url='http://localhost' --idsite=mysiteid -
I have recently updated Matomo, and nothing works now, because python3 is not installed in my matomo image. I tried to install it by entering the container and running apt-get, but the command was not found. I tried building an alternative image based on matomo, but with additional commands to install python3, but apt-get update wouldn't work because4 of missing pubkeys. I tried adding the pubkeys but it complains about missing gpg packages.
Help - I'm stuck!
[Later] I saw the instructions at https://github.com/matomo-org/docker#docker-compose-examples-and-log-import-instructions which implied you had to run python in a different container. I tried starting up a python container and running the import, but I got these errors:
Traceback (most recent call last):
File "/var/www/html/misc/log-analytics/import_logs.py", line 2690, in <module>
main()
File "/var/www/html/misc/log-analytics/import_logs.py", line 2652, in main
recorders = Recorder.launch(config.options.recorders)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/var/www/html/misc/log-analytics/import_logs.py", line 1828, in launch
t.start()
File "/usr/local/lib/python3.11/threading.py", line 957, in start
_start_new_thread(self._bootstrap, ())
RuntimeError: can't start new thread
read unix @->/var/run/docker.sock: read: connection reset by peer