Search code examples
azuredockerazure-container-instancesazure-files

Azure container can't access a mounted volume on startup why?


I am having problems using a volume mount in my container on Azure container instances.

I can mount a volume mount to my container no problem. Here is the az cli command I am using and it works well. I followed this tutorial

az container create --resource-group mydemo --name paulwx --image containerregistry.azurecr.io/container:master --registry-username username --registry-password password --dns-name-label paulwx --ports 8080 --assign-identity --azure-file-volume-account-name accountname --azure-file-volume-account-key secretkey  --azure-file-volume-share-name myshare --azure-file-volume-mount-path /opt/application/config

This works great and I can attach to the container console and access the shared volume. I can touch files and read files.

The problem comes when I try to have the application read this folder on startup (to get its application configuration). Again the command is almost identical except the application is flagged to read the configs from the volume mount via an ENV variable called SPRING_CONFIG_LOCATION.

az container create --resource-group mydemo --name paulwx --image containerregistry.azurecr.io/container:master --registry-username username --registry-password password --dns-name-label paulwx --ports 8080 --assign-identity --azure-file-volume-account-name accountname --azure-file-volume-account-key secretkey  --azure-file-volume-share-name myshare --azure-file-volume-mount-path /opt/application/config --environment-variables SPRING_CONFIG_LOCATION=file:/opt/application/config/

The container now terminates with the following error.

Error: Failed to start container paulwx, Error response: to create containerd task: failed to mount container storage: guest modify: guest RPC failure: failed to mount container root filesystem using overlayfs /run/gcs/c/e51f86c414ae83c7c279a4252864a381399069d358f5d2303c97c630e17b049f/rootfs: no such file or directory: unknown

So I can mount a volume as long as I don't access it on start up. Am I missing something very fundamental here? Surely having a volume mount means the mount point will be available when the container starts.

The volume mount type is samba and Standard_LRS.


Solution

  • So to cut a long story short the issue here was that the application on startup was configured to read the property file from a folder that was not where I expected it to be be.

    The application failed to start due to not finding the application.properties where it expected to find them.The Azure error message was a red herring and not at all reflective of the problem. The application logger was not logging to standard out properly so I actually missed the application log which clearly stated application.properties not found.