Docker Community Forums

Share and learn in the Docker community.

Accessing files in host from a docker container

I’m a docker newbie so sorry if the question turns out to be trivial or silly… I have a docker container running on Ubuntu server. In the container there is Home Assistant image. I’ve installed Plex plugin for Home Assistant and would like to add my library, but can’t do that as the container can’t access host files. The library I’d like to add is on usb drive which I’ve mapped to /Home//Usb drive/. When I click “Browse” from Plex and go to “/Home/” there is no folder in it, because it can’t access host’s filesystem…
From this topic I’ve learnt that I should run this command:

*docker run -v /path/on/host:/path/inside/container <image_name>*

The question is, what happens if I run this command while this image is already running? If I understand correctly, new instance of docker containg this image will run. If that’s the case, what happens to the data that current Home Assistant image have been storing inside the container (probably)?

As a general rule, a container can’t access the host’s filesystem, except to the extent that the docker run -v option maps specific directories into a container . Also as a general rule you can’t directly change mount points in a container ; stop, delete, and recreate it with different -v options.

1 Like

Copy the data to the host and mount it from there. Maybe the problem is with the USB drive.

There is no data stored inside a container that survives a restart. If you follow the instructions on home-assistant.io then you mount a local folder /PATH_TO_YOUR_CONFIG that contains the yaml files and the sqlite db into the container. This folder is persistent because it is located on your host.

Can’t do it. It’s old HP T620 terminal with only 16 GB of storage. I have very limitted budget and would prefer to stick to what’s available. Besides, I mapped the drive to Samba and it seems to be working correctly.

I installed it with this script. I can see that whole homeassistant folder with all the yamls and db is mounted to /usr/share/hassio/homeassistant/. Perhaps I can mount the USB drive to /usr/share/hassio/media/DRIVE/? It is accessible from Home Assistant Plex addon…

EDIT: OK, even though I mounted the drive to /usr/share/hassio/media/ I still don’t see any folders/files when browsing from Plex addon…

EDIT2: Surprisingly, when I copy .mp4 file to /usr/share/hassio/media/, it DOES show up in Plex…