Reputation: 5031
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:
NGINX_PORT="80"
"NGINX_PORT=80"
nginxPort=80
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
Upvotes: 6
Views: 4849
Reputation: 1712
Try:
- Removing the dashes in front of the environment
values
- Changing '=' to ': ' for all environment
values
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:
Example yml from Microsoft:
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:
Source: https://learn.microsoft.com/en-us/azure/app-service/containers/tutorial-multi-container-app
Upvotes: 8