Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to expose multiple ports on Azure Container Instance?

Is it possible to expose/open more than one port on an Azure Container Instance? I've only been able to open one port per container.

I'd like to run the equivalent of: docker run -p 80:80 -p 443:443 ...

I've unsuccessfully tried:

  • Maps only the last port: az container create ... --port 80 --port 443
  • Syntax error: az container create ... --port 80 443

But the resource JSON seems to indicate that an array is possible:

az container show -name <container-name> --resource-group <resource-group-name>

Response: 
{
  "containers": [
    {
      ...
      "name": "...",
      "ports": [
        {
          "port": 80
        }
      ...
    }
  ],
   ...
  "ipAddress": {
    "ip": "xxx.xxx.xxx.xxx",
    "ports": [
      {
        "port": 80,
        "protocol": "TCP"
      }
    ]
  },
  ...
}
like image 218
dstj Avatar asked Aug 09 '17 16:08

dstj


1 Answers

This can now be done via Azure CLI. Example is below:

az container create -g MyResourceGroup --name myalpine --image alpine:latest --ip-address public --ports 80 443

https://docs.microsoft.com/en-us/cli/azure/container?view=azure-cli-latest#az_container_create

like image 79
jluk Avatar answered Nov 13 '22 12:11

jluk