Azure Docker compose 因环境部分而失败

Azure Docker compose fails with the environment section

我有一个 docker-compose.yml 脚本在 Azure 中运行良好。但是当我添加带有两个变量的环境部分时,它会失败并出现此错误:

2018-08-24 10:29:30.214 ERROR - Exception in multi-container config parsing: System.InvalidCastException: Specified cast is not valid.  
 at LWAS.Kube.ComposeFileParser.ParseContainer (System.Collections.Generic.KeyValuePair`2[TKey,TValue] service) [0x00152] in <029f376c1c6a4bb79892c2f60333c2d8>:0
 at LWAS.Kube.ComposeFileParser.ParseFile (System.String composeYaml) [0x000d2] in <029f376c1c6a4bb79892c2f60333c2d8>:0
 at LWAS.Kube.PodSpec.LoadSpecFromComposeYamlFile (System.String composeFile) [0x00000] in <029f376c1c6a4bb79892c2f60333c2d8>:0
 at LWAS.SiteStartInfoRepository.SetupPodSpecForMultiContainerApp (Microsoft.Web.Hosting.StartSiteContext ctx, LWAS.LinuxSiteStartInfo startInfo) [0x0000f] in <029f376c1c6a4bb79892c2f60333c2d8>:0
2018-08-24 10:29:30.215 ERROR - Start multi-container app failed

docker-compose.yml 文件的缩短内容为:

version: '3.3'

services:
  application:
    image: myregistry.azurecr.io/application:latest
    volumes:
      - application_data:/usr/local/application/data

  proxy:
    image: myregistry.azurecr.io/proxy:latest
    depends_on:
      - application
    environment:
      - NGINX_HOST=myapplication.azurewebsites.net
      - NGINX_PORT=80
    ports:
      - "80:80"

volumes:
  application_data:

我试过了:

  1. 只有一个变量
  2. 在值周围使用引号,即 NGINX_PORT="80"
  3. 在引号中包含整个变量定义,即 "NGINX_PORT=80"
  4. 使用驼峰式重命名变量,即 nginxPort=80
  5. 上下移动环境部分

没有任何帮助 - 仍然是相同的错误消息。

但是应该可以在 Azure 中使用环境变量 Docker compose,如下所示:https://docs.microsoft.com/en-us/dotnet/standard/microservices-architecture/multi-container-microservice-net-applications/multi-container-applications-docker-compose

注意: 它在本地使用 docker-compose 命令没有任何问题。所以这一定是一些 Azure 特有的问题。

我做错了什么?

谢谢

尝试:
- 删除 environment
前面的破折号 - 将所有 environment

的“=”更改为“:”
version: '3.3'

services:
  application:
    image: myregistry.azurecr.io/application:latest
    volumes:
      - application_data:/usr/local/application/data

  proxy:
    image: myregistry.azurecr.io/proxy:latest
    depends_on:
      - application
    environment:
      NGINX_HOST: myapplication.azurewebsites.net
      NGINX_PORT: 80
    ports:
      - "80:80"

volumes:
  application_data:

Microsoft 的 yml 示例:

version: '3.3'

services:
   db:
     image: mysql:5.7
     volumes:
       - db_data:/var/lib/mysql
     restart: always
     environment:
       MYSQL_ROOT_PASSWORD: somewordpress
       MYSQL_DATABASE: wordpress
       MYSQL_USER: wordpress
       MYSQL_PASSWORD: wordpress

   wordpress:
     depends_on:
       - db
     image: wordpress:latest
     ports:
       - "8000:80"
     restart: always
     environment:
       WORDPRESS_DB_HOST: db:3306
       WORDPRESS_DB_USER: wordpress
       WORDPRESS_DB_PASSWORD: wordpress
volumes:
    db_data:

来源: https://docs.microsoft.com/en-us/azure/app-service/containers/tutorial-multi-container-app