I cannot for the life of me get my Azure App Service multicontainer app with 3 containers working, where they can communicate with each other. I've tried for the better part of a week without any luck...
It's a .NET 6 app written in C# with 3 containers deployed - a web app, a Redis server and a MSSQL server - using Docker Compose and Azure DevOps. Deployment works as expected, but the web app fails because it cannot establish a connection to either the Redis server (using port 6379) or the MSSQL server (using port 1433)
The Docker Compose file looks something like this:
services:
website:
image: <registryname>.azurecr.io/<containername>:latest
container_name: web
restart: always
build:
context: .
dockerfile: Presentation/<WebProject>/Dockerfile
environment:
- ASPNETCORE_ENVIRONMENT=Production
db:
image: mcr.microsoft.com/mssql/server:2019-latest
container_name: db
ports:
- "1433:1433"
volumes:
- mssql:/var/opt/mssql/data
environment:
SA_PASSWORD: "<password>"
ACCEPT_EULA: "Y"
redis:
image: <registryname>.azurecr.io/redis:7.0.4
command: redis-server --requirepass <redisPassword>
ports:
- "6379:6379"
volumes:
- redis_data:/var/lib/redis
environment:
- REDIS_REPLICATION_MODE=master
volumes:
mssql:
external: true
redis_data:
driver: local
And the deployment YAML file looks something like this:
trigger:
branches:
include:
- 'master'
paths:
include:
- Presentation/<WebProject>/*
exclude:
- Presentation/<ApiProject>/*
resources:
- repo: self
variables:
# Container registry service connection established during pipeline creation
azureContainerRegistry: '{"loginServer": "<registryname>.azurecr.io", "id": "/subscriptions/<subscription-id>/resourcegroups/<resourcegroup>/providers/Microsoft.ContainerRegistry/registries/<registryname>"}'
azureSubscription: '<Name of service connection to Azure Resource Manager>'
appName: <Azure app service app name>
imageRepository: '<image name in registry>'
containerRegistry: '<regsitryname>.azurecr.io'
tag: latest
# Agent VM image name
vmImageName: 'ubuntu-latest'
stages:
- stage: Build
displayName: Build and push stage
jobs:
- job: Build
displayName: Build
pool:
vmImage: $(vmImageName)
steps:
- task: DockerCompose@0
displayName: 'Build images'
inputs:
containerregistrytype: Azure Container Registry
azureContainerRegistry: $(azureContainerRegistry)
azureSubscription: $(azureSubscription)
dockerComposeFile: 'docker-compose-web-azure.yml'
action: Build services
arguments: website
- task: DockerCompose@0
displayName: 'Push images'
inputs:
containerregistrytype: Azure Container Registry
azureContainerRegistry: $(azureContainerRegistry)
azureSubscription: $(azureSubscription)
dockerComposeFile: 'docker-compose-web-azure.yml'
action: Push services
includeSourceTags: true
includeLatestTag: false
- task: AzureWebAppContainer@1
displayName: 'Azure Web App on Container Deploy'
inputs:
azureSubscription: $(azureSubscription)
appName: $(appName)
imageName: $(containerRegistry)/$(imageRepository):$(tag)
multicontainerConfigFile: 'docker-compose-web-azure.yml'
All containers starts up as expected with no errors in the logs.
I've modified my Dockerfile for the web project so that I can SSH into the container from Azure App Service and test connectivity to other containers using telnet. Example:
telnet localhost 1433
telnet 127.0.0.1 1433
And a bunch of other stuff. Nothing works.
Am I better off using an Azure VM (where I can at least control everything, including Docker networks which I use on my own machine), or is there a solution to this?