如何将 Gitlab CI 变量作为 Traefik traefik.http.routers.container_name.rule 标签值传递
how to pass Gitlab CI variable as a Traefik traefik.http.routers.container_name.rule label value
在 Gitlab 中 CI 我试图在构建图像时设置 Traefik 标签,以便在 Traefik 服务中注册它。这是如何完成的:
- docker build -t $IMAGE . --label traefik.http.routers.$SERVICE_NAME.rule="Host(`$SERVICE_URL`)" --label traefik.enable=true
这就是它的解释方式:
Step 7/7 : LABEL traefik.http.routers.socialmedia-service-master.rule=Host()
---> Running in c67fe595032a
$SERVICE_URL 和 $SERVICE_NAME 都确定了。
我怎样才能让它发挥作用?
尝试转义反引号,像这样:
docker build -t $IMAGE . --label traefik.http.routers.$SERVICE_NAME.rule="Host(\`$SERVICE_URL\`)" --label traefik.enable=true
在 Gitlab 中 CI 我试图在构建图像时设置 Traefik 标签,以便在 Traefik 服务中注册它。这是如何完成的:
- docker build -t $IMAGE . --label traefik.http.routers.$SERVICE_NAME.rule="Host(`$SERVICE_URL`)" --label traefik.enable=true
这就是它的解释方式:
Step 7/7 : LABEL traefik.http.routers.socialmedia-service-master.rule=Host()
---> Running in c67fe595032a
$SERVICE_URL 和 $SERVICE_NAME 都确定了。 我怎样才能让它发挥作用?
尝试转义反引号,像这样:
docker build -t $IMAGE . --label traefik.http.routers.$SERVICE_NAME.rule="Host(\`$SERVICE_URL\`)" --label traefik.enable=true