Hard drive mount in docker appear empty after a few hours

So I have everything setup for my HTPC and all is working great. They only issue I have is with my hard drive mounts.

After a few hours, my drives don’t show any files or folders in all containers. Once I reboot the containers, it works again for a few hours and then show empty again.

Has anybody ever seen this? It happens on all of my containers.

bind-mounts? local disk volumes ? remote share volumes?

Its my local USB drives. I’m still fairly new to docker and am unsure what a bind mount is.

Thank you for your help

Here is an example of one on my containers in docker compose

    container_name: PlexMediaServer
    restart: always
    image: plexinc/pms-docker
    network_mode: host
        - ${USERDIR}/docker/plexms:/config
        - ${USERDIR}/Downloads/plex_tmp:/transcode
        - /media:/media
        - ${USERDIR}/docker/shared:/shared
        - TZ=${TZ}
        - PLEX_UID=${PUID}
        - PLEX_GID=${PGID}

The -/media:/media is the location of my mounted drives

Your volumes are “bind-mounts”, technicaly they use “mount --bind” to mount a host folder into a container folder.

Such a mount is like a pointer. Now here is the fun part: the container will see the exact pointer that /media had during container start. If the host side of the mount gets unmounted (disconnect/sleep?), the container side of the mount becomes stale. If you re-mount the host side, the “pointer” inside the container will still point to the stale volume. You will need to restart the container in order to see the new mount “pointer”.

Hope this makes sense…

LT:DR: normal behavior, don’t use a drive that can be unmounted/remounted during container execution.

Fantastic. This makes complete sense!.

What would be the best solution to fix this issue? Like I said, im still a newbie to docker and docker compose.

I know you said to not use a drive that can be unmounted/remounted during container execution, but how would do this with my USB drives?

This is not a docker problem per se.

Either don’t use a usb drive (my Plex instance mounts media from a nfs remote share) or figure out how to prevent your usb drive to sleep, hibernate or whatever caused the disconnect.

Got it. Not using a USB drive is out of question so I’ll need to find another solution I guess.