`docker context create aci` `--location` argument seems to have no effect

Viewed 836

When using docker compose to deploy a container group to Azure Container Instances, the --location argument specified when creating the docker context for aci, docker context create aci..., appears to have no effect.

I'm following these azure instructions for using docker compose with azure container instances and this docker documentation showing the additional arguments for the docker context create command

Steps to re-produce

Pre-requisites:

Azure CLI

λ az version
{
  "azure-cli": "2.22.1",
  "azure-cli-core": "2.22.1",
  "azure-cli-telemetry": "1.0.6",
  "extensions": {}
}

Docker

λ docker-compose --version
docker-compose version 1.29.0, build 07737305

Docker Compose

λ docker --version
Docker version 20.10.5, build 55c4c88

Steps:

  1. Log into azure via the cli az login
  2. Authenticate docker with azure docker login azure
  3. Create an azure resource group in a specific location az group create -l uksouth -n test-aci-ctx-group
  4. Create a docker context specifying a location different to the resource group location docker context create aci aci-context-eastus --resource-group test-aci-ctx-group --location eastus
  5. Display the information about the new context. docker context inspect aci-context-eastus
  6. Expected result: a context bound to the location specified as --location for the docker context create command, i.e., eastus
  7. Actual result: a context bound to the same location as the azure resource group, i.e., uksouth
λ docker context inspect aci-context-eastus
[
    {
        "Name": "aci-context-eastus",
        "Metadata": {
            "Description": "test-aci-ctx-group@uksouth",
            "Type": "aci"
        },
        "Endpoints": {
            "aci": {
                "Location": "uksouth",
                "ResourceGroup": "test-aci-ctx-group",
                "SubscriptionID": "xxxxxxxxxxxxxxxxxxx"
            },
            "docker": {
                "SkipTLSVerify": false
            }
        },
        "TLSMaterial": {},
        "Storage": {
            "MetadataPath": "xxxx",
            "TLSPath": "xxxx"
        }
    }
]

The ultimate manifestation of this issue is that I am unable to create a container group in azure because I'm working in the context of a resource group which I cannot change, but the resource group is in a location that does not support Azure Container Instances. When I try and issue the docker-compose up command in the aci context that I thought I created in a location that supports azure container instances, I get a location not supported error, listing the location of the resource group and not the location I specified for the docker aci context.

Am I misunderstanding the purpose of the --location parameter?

I know you can mix and match locations between a container instance and a resource group because I am able to create a container instance via azure cli with a location different to that of the resource group that it is linked to.

1 Answers

You misunderstand the steps. The parameter needs to be used like this:

docker context create aci --location "eastus"

So you don't need to create the resource group first. When you do it, then the group is already created with a certain location and you can't change it with the docker-compose command.

You have two choices. One is that create the resource group with the location you want, for example, location "eastus". Or create the resource group with the parameter --location "eastus" without a name.

Related