question

ambhareshvenkatraman-7264 avatar image
0 Votes"
ambhareshvenkatraman-7264 asked SandervandeVelde42 edited

Docker bind and volume mount

Hi,
I am trying to store a csv file inside a docker container and use binds to store it locally. The problem I'm facing is if i use just the file name to write to csv it is getting saved in /app directory. If I use any other path say /mydata/output.csv it's not getting stored.

If I use mount to store the file in local directory the container is failing with message "Error ./main.py is not a file or directory".

 local_file_name="output.csv"
 local_path = "/mydata/output"
 os.mkdir(local_path)
 upload_file_path = os.path.join(local_path, local_file_name)
    
 with open(upload_file_path, 'a') as csvfile:
     print("opened csv file")
     csvwriter = csv.writer(csvfile)                   
     csvwriter.writerow(metalist)

Deployment manifest

 "HostConfig": {
                     "Binds": [
                         "/opt/localstorage/output:/app"
                     ]
                 }




azure-iot-hubazure-iot-edge
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

SandervandeVelde42 avatar image
2 Votes"
SandervandeVelde42 answered SandervandeVelde42 edited

Hello @ambhareshvenkatraman-7264 ,

To be able to read and write files located on the host file system, there are a couple of things to check:

  • the code which access the file system

  • The bindingof the container

  • Access to the file system folders

You can investigate the folder access inside the module with

sudo docker exec -i -t [the name of your azure iot edge module] /bin/bash

Please check out this blog post where a comparable situation is investigated.







5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.