I have a docker-compose.yml script working well in Azure. But when I add en environment section with two variables then it fails with this error:
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
Shortened content of the docker-compose.yml file is:
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:
I tried:
- to have only one variable
- to use quotes around values i.e.
NGINX_PORT="80"
- to have whole variable definition in quotes i.e.
"NGINX_PORT=80"
- to rename variables using camel case i.e.
nginxPort=80
- to move environment section up and down
Nothing helped - still the same error message.
But it should be possible to use environment variables in Azure with Docker compose as it is shown here: https://learn.microsoft.com/en-us/dotnet/standard/microservices-architecture/multi-container-microservice-net-applications/multi-container-applications-docker-compose
Note: it works locally using docker-compose
command without any problem. So it must be some Azure specific problem.
What am I doing wrong?
Thank you