I have been following all of the tutorials for using docker compose with regards to azure and have been running into a problem with regards to volumes.
My docker compose file looks like this :
version: '3.7'
services:
app-server:
build:
context: .
dockerfile: Dockerfile
ports:
- "8080:8080"
depends_on:
- db
environment:
SPRING_DATASOURCE_URL: jdbc:mysql://db:3306/shapeshop?useSSL=false&serverTimezone=UTC&useLegacyDatetimeCode=false
SPRING_DATASOURCE_USERNAME: root
SPRING_DATASOURCE_PASSWORD: root
SERVER_PORT: 8080
networks:
- backend
db:
image: mysql:5.7
ports:
- "3306:3306"
restart: always
environment:
MYSQL_DATABASE: shapeshop
MYSQL_USER: admin
MYSQL_PASSWORD: admin
MYSQL_ROOT_PASSWORD: root
volumes:
- "db-data:/var/lib/mysql"
networks:
- backend
volumes:
db-data:
driver: azure_file
driver_opts:
share_name: shapeshopfileshare
storage_account_name: shapeshopstorageaccount
networks:
backend:
In the above YML file I am defining the volume for the mysql container (db) to point to azure artifacts. The tutorials state that I should use "azure_file" as a driver and then create a file share and a storage account.
I created both of these (shapeshopfileshare and shapeshopstorageaccount):
Now if I log into "az" CLI like so :
az login
I see my subscription "shapeShopResourceGroup"
{
"id": "/subscriptions/8cdb50cb-ede8-4eac-80df-55afadf861cd/resourceGroups/shapeShopResourceGroup",
"location": "eastus",
"managedBy": null,
"name": "shapeShopResourceGroup",
"properties": {
"provisioningState": "Succeeded"
},
"tags": null,
"type": "Microsoft.Resources/resourceGroups"
},
I am also using the "aci" context :
However when I do docker compose up I get this error :
error: The storage account named shapeshopstorageaccount is already
taken.
This is really frustrating to me because, yes, shapeshopstorageaccount DOES EXIST! I created it for ME!
So then, I think somehow my context does not associate properly with my subscription. So to check I type in :
az storage account list
…and my shapeshopstorageaccount is listed in the returned JSON. So it seems like the association between my storage account and subscription exists.
Why is azure (or docker-compose) not associating the declared volume in my YML file with the azure storage that I created??
2
Answers
I think that storage account must be unique globally. The reason for that is that the name becomes part of the URL, let’s say
https://shapeshopstorageaccount.blob.core.windows.net
Try to add oliver_s0mthing to your storage account,probably that is unique name.
You might need to login to Azure Container Registry with
az acr login --name <acrName>
and from the same terminal run the compose command. Check this for more details.Alternatively, you might need to include the storage account key in yaml, like this.
Check also this, in which I am not sure why variable names are different though.