Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docker容器环境变量配置不生效 #380

Open
kaolaaz163 opened this issue Mar 15, 2024 · 0 comments
Open

Docker容器环境变量配置不生效 #380

kaolaaz163 opened this issue Mar 15, 2024 · 0 comments

Comments

@kaolaaz163
Copy link

kaolaaz163 commented Mar 15, 2024

通过容器启动的PrometheusAlert,启动容器的配置如下:

version: '3'
services:
  prometheus-alert:
    image: feiyu563/prometheus-alert:latest
    container_name: prometheus-alert
    restart: always
    environment:
    - PA_LOGIN_USER=admin
    - PA_LOGIN_PASSWORD=xxxxxx
    - PA_TITLE=Prometheus告警
    - PA_OPEN_FEISHU=0
    - PA_OPEN_DINGDING=0
    - PA_OPEN_WEIXIN=1
    - PA_ALERTRECORD=1
    ports:
    - 8080:8080
    volumes:
    - /data/prometheus-alert/data:/app/db

容器启动后,提示open-feishu和title环境变量配置有问题,检查app.conf配置文件中的配置并没有被替换

sh: open-feishu: unknown operand
sed: unmatched '@'
sh: title: unknown operand
sed: unmatched '@'
pass!
Config overridden from Environment variable, AlertRecord=1.
Config overridden from Environment variable, open-dingding=0.
Config overridden from Environment variable, login_password=xxxxxx.
Config overridden from Environment variable, open-weixin=1.
Config overridden from Environment variable, login_user=admin.
Config overridden from Environment variable, open-feishu
open-feishu=0.
Config overridden from Environment variable, title
title=Prometheus告警.
table `prometheus_alert_d_b` already exists, skip
table `alert_record` already exists, skip
table `alert_router` already exists, skip
2024/03/15 13:48:19.881 [I] [proc.go:250]  [main] 构建的Go版本: go1.20.6
2024/03/15 13:48:19.881 [I] [proc.go:250]  [main] 应用当前版本: v4.9
2024/03/15 13:48:19.881 [I] [proc.go:250]  [main] 应用当前提交: b0cc4630afefe67353c08fd884c0f040018eb316
2024/03/15 13:48:19.881 [I] [proc.go:250]  [main] 应用构建时间: 2023-07-28T09:37:42+00:00
2024/03/15 13:48:19.881 [I] [proc.go:250]  [main] 应用构建用户: root@buildkitsandbox
2024/03/15 13:48:19.912 [I] [asm_amd64.s:1598]  http server Running on http://0.0.0.0:8080

检查docker-entrypoint.sh脚本,发现在过滤配置项的时候只要包含关键字配置项即匹配,这样是否会过滤出无关的配置项,是否可以加个"-w":

        CONF_ITEM=$(grep -Eio "${VAR_NAME/_/-}|${VAR_NAME}" /app/conf/app.conf)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant