ACI + Azure File Share: not sharing
Guy Dillen
76
Reputation points
Hi,
I have a small Go (test) program:
package main
import (
"log"
"os"
)
func main() {
// log to custom file
LOG_FILE := "/app/logs/log.txt"
// open log file
//f, err := os.OpenFile(LOG_FILE, os.O_APPEND|os.O_RDWR|os.O_CREATE, 0644)
f, err := os.OpenFile(LOG_FILE, os.O_APPEND|os.O_RDWR|os.O_CREATE, 0666)
if err != nil {
// log.Fatalf("error opening file: %v", err)
log.Panic(err)
}
defer f.Close()
// set log out put
log.SetOutput(f)
// optional: log date-time, filename, and line number
log.SetFlags(log.Lshortfile | log.LstdFlags)
log.Println("Logging to custom file")
}
and a Dockerfile
# syntax=docker/dockerfile:1
FROM golang:1.19.3-alpine
WORKDIR /app
ARG LOG_DIR=/app/logs
RUN mkdir -p ${LOG_DIR}
ADD main main
VOLUME [${LOG_DIR}]
CMD [ "./main" ]
(Remark: go app is compiled as: "go build -o main .")
- Pushed the image to Azure Container Registry.
- Created an Azure Storage Account with a File Share
Then run:
az container create \
--resource-group myrg \
--name aci-test \
--ip-address public \
--restart-policy Never \
--image xxx.azurecr.io/go-docker-volume:dev \
--cpu 1 \
--memory 1 \
--registry-login-server xxx.azurecr.io \
--registry-username xxx \
--registry-password myregistrypassword \
--os-type linux \
--azure-file-volume-account-name mystacc \
--azure-file-volume-account-key mysecretkey \
--azure-file-volume-share-name acishare \
--azure-file-volume-mount-path /data
After running this script:
{
"containers": [
{
"command": null,
"environmentVariables": [],
"image": "xxx.azurecr.io/go-docker-volume:dev",
"instanceView": {
"currentState": {
"detailStatus": "Completed",
"exitCode": 0,
"finishTime": "2022-12-03T10:51:41.350000+00:00",
"startTime": "2022-12-03T10:51:36.551000+00:00",
"state": "Terminated"
},
"events": [],
"previousState": null,
"restartCount": 0
},
"livenessProbe": null,
"name": "aci-test",
"ports": [
{
"port": 80,
"protocol": "TCP"
}
],
"readinessProbe": null,
"resources": {
"limits": null,
"requests": {
"cpu": 1.0,
"gpu": null,
"memoryInGb": 1.0
}
},
"volumeMounts": [
{
"mountPath": "/data",
"name": "azurefile",
"readOnly": null
}
]
}
],
"diagnostics": null,
"dnsConfig": null,
"encryptionProperties": null,
"id": "/subscriptions/xxx/resourceGroups/xxx/providers/Microsoft.ContainerInstance/containerGroups/aci-test",
"identity": null,
"imageRegistryCredentials": [
{
"identity": null,
"identityUrl": null,
"password": null,
"server": "xxx.azurecr.io",
"username": "xxx"
}
],
"initContainers": [],
"instanceView": {
"events": [
{
"count": 1,
"firstTimestamp": "2022-12-03T10:51:35.325000+00:00",
"lastTimestamp": "2022-12-03T10:51:35.325000+00:00",
"message": "Successfully mounted Azure File Volume.",
"name": "SuccessfulMountAzureFileVolume",
"type": "Normal"
}
],
"state": "Succeeded"
},
"ipAddress": {
"dnsNameLabel": null,
"fqdn": null,
"ip": "xx.xx.xx.xx",
"ports": [
{
"port": 80,
"protocol": "TCP"
}
],
"type": "Public"
},
"location": "westeurope",
"name": "aci-test",
"osType": "Linux",
"provisioningState": "Succeeded",
"resourceGroup": "xxx",
"restartPolicy": "Never",
"sku": "Standard",
"subnetIds": null,
"tags": {},
"type": "Microsoft.ContainerInstance/containerGroups",
"volumes": [
{
"azureFile": {
"readOnly": null,
"shareName": "acishare",
"storageAccountKey": null,
"storageAccountName": "xxx"
},
"emptyDir": null,
"gitRepo": null,
"name": "azurefile",
"secret": null
}
],
"zones": null
}
However, I don't see a file (log.txt with 1 line) appearing in my File Share?! Using Docker locally works fine.
Anyone can tell me what I'm missing?
Thanks.
Guy
Azure Container Instances
Azure Container Instances
An Azure service that provides customers with a serverless container experience.
756 questions
Sign in to answer