通过 dockerfile 更新 matomo 自定义变量

问题描述

我有一个 dockerfile,其中包含 matomo 并复制我的配置文件

FROM matomo:3.14.1

copY config/config.PHP /var/www/html/config/config.PHP

RUN ./console customvariables:set-max-custom-variables 10

但是我似乎无法成功更新自定义变量,我可以在没有 RUN 的情况下运行 docker build 并在 /var/www/html 位置看到 ./console 命令,因此我不太明白为什么它不会也只执行这个命令?我在这里做错了什么吗?

解决方法

该图像的 Dockerfile declares a VOLUME for the /var/www/html directory 因此派生图像永远无法更改该目录的内容。您需要使用 docker run -v 选项或 Compose volumes: 来注入您的配置文件;您无需创建自定义图像即可执行此操作。

docker run \
  -v $PWD/config/config.php:/var/www/html/config/config.php \
  ... --other-docker-options ... \
  mamoto:3.14.1