Docker-compose不解析变量

来自三线的随记
Admin讨论 | 贡献2020年1月31日 (五) 15:30的版本 (创建页面,内容为“If you're trying to pass those variables into the container, you need to escape them in the command using an extra <code>$</code> [root@test]# vim docker-compose.ym…”)
(差异) ←上一版本 | 最后版本 (差异) | 下一版本→ (差异)

If you're trying to pass those variables into the container, you need to escape them in the command using an extra $

[root@test]# vim docker-compose.yml 
version: '2'

services:
 v2ray:
    image: ephz3nt/v2ray_v3:go
    restart: always
    network_mode: "host"
    command:
      - /bin/sh
      - -c
      - |
        sed -i "s|\"info\"|\"debug\"|" "/etc/v2ray/config.json" && sed -i "s|\"port\": 2333,|\"port\": $${api_port}, |"  "/etc/v2ray/config.json" && sed -i "s|\"https://google.com\"|\"$${sspanel_url}\"|g" "/etc
/v2ray/config.json" && sed -i "s/\"55fUxDGFzH3n\"/\"$${key}\"/g" "/etc/v2ray/config.json" && sed -i "s/123456/$${node_id}/g" "/etc/v2ray/config.json" &&  sed -i "s/\"SpeedTestCheckRate\": 6/\"SpeedTestCheckRate
\": $${speedtest}/g" "/etc/v2ray/config.json" &&  sed -i "s/\"downWithPanel\": 6/\"downWithPanel\": $${downWithPanel}/g" "/etc/v2ray/config.json" && v2ray -config=/etc/v2ray/config.json