I want to save a file to a network hard drive from a Docker Compose, running on a Linux MiniPC

26 Views Asked by At

I have installed a camera at the door of my house (Reolink doorbell POE). I have it integrated into Home Assistant with Docker Compose running on a PC. I want it to record when it detects movement and save the file to a network drive. I have gotten it to record on the PC, but I can't get it to record on the network hard drive.

I detail the steps I have taken and how far I have come, but I have not achieved it yet.

  • The path of my hard drive is: \\192.168.1.5\Camara It is a local and public folder, so it does not require a username or password.

  • Home Assistant is in the directory: home/casa/docker/homeassistant

    • User: home
    • Password: 1234 (I detail them as an example to describe it better)

I have mounted a network share (a network hard drive) in a local directory: ~/docker/homeassistant/mnt/camara For that, first, from the Home Assistant directory, I have created the directory for mounting /mnt/camera in the Home Assistant directory within the host file system using the command: sudo mkdir -p /mnt/camera.

Then I have already mounted the network disk in the mount directory, using the command: sudo mount -t cifs //192.168.1.5/Camara ~/docker/homeassistant/mnt/camara -o username=casa,password=1234 This told me Allows access to the network disk from within the Home Assistant container. If I run in terminal: ls -l ~/docker/homeassistant/mnt/camera to see what is in the folder, it goes directly to the hard drive and I see its contents, so it directs correctly. If I create a file with: sudo touch ~/docker/homeassistant/mnt/camara/test4.txt It creates it and I can see it on the hard drive.

I have modified the docker-compose.yaml to mount the mount directory in the Home Assistant container.

volumes:
      - './config:/config'
      - ~/docker/homeassistant/mnt/camara:/Camara:rw

I restarted the Home Assistant container for the configuration changes to take effect.

In my first test, to start recording on the PC hard drive, I wrote on the Home Assistant automation:

data:
      filename: /media/camera/filename.mp4

Now, to try to record on the hard drive, I indicate the new address:

data:
      filename: /mnt/camera/filename.mp4

I have tried different paths in that file description:

filename: /mnt/camera/filename.mp4
filename: ~/docker/homeassistant/mnt/camera /filename.mp4
filename: /home/casa/docker/homeassistant/mnt/camera/filename.mp4

But it hasn't worked with any of them and it always gave me the error: Can't write /home/casa/docker/homeassistant/mnt/camera/filename.mp4, no access to path!

I have something left to do, but I can't locate what it is or where the error is. I really appreciate if anyone can help me.

0

There are 0 best solutions below