The Azure Container Instances YAML reference gives option to expose multiple ports in the container.
see https://learn.microsoft.com/en-us/azure/container-instances/container-instances-reference-yaml
However, I haven’t figured out yet how to map/forward port as we do with docker. I would like to define on the YAML file a port forward, as we do with docker command:
docker run -e 'ACCEPT_EULA=Y' -e 'MSSQL_SA_PASSWORD=pw' -p 14000:1433
Is there a limitation using Azure YAML schema?
I have tried:
ports:
- port: 11401
- port: 1433
but it opens both ports.
2
Answers
As per the doc and doc, please try with format :
As per the below document, Azure Container Instances not supporting port mapping like in Docker.
Please refer this doc for more details: Troubleshoot common issues – Azure Container Instances | Microsoft Learn
The port which you expose in container instance should be same as port your container image listens to.
However, you can achieve it by defining arguments and environment variables in the docker file which lets you overwrite port during deployment.
For example, by default, the below docker file will listens to http port 80 as
http_port
is set to 80.But if you require ACI to listen on different port then define target_port in the environment variables of ACI deployment yaml file as shown below.
Once the above has file has deployed, Azure Container Instance starts listen to port 8090 even image port is 80.