Skip to main content

Setting Up Filebrowser with Docker Compose on a Raspberry pi

How to Mount a USB Drive on Raspberry Pi and Use It in a Docker Container (FileBrowser Example)

Mounting a USB drive on a Raspberry Pi and accessing it from a Docker container like FileBrowser is a great way to expand your Pi’s file storage and make your external files accessible from a web interface. In this article, we’ll walk through everything step-by-step — from detecting the drive to auto-mounting and making it usable in Docker.

🧾 Prerequisites

  • A Raspberry Pi running Linux (e.g., Raspberry Pi OS, DietPi, or Debian)

  • A USB drive (formatted as ntfs, FAT32, exFAT, or ext4)

  • Docker installed and running on your Pi

  • Some basic terminal skills

✅ Step 1: Identify Your USB Drive

Plug in your USB drive and run:

lsblk

Look for a line like:

sda      8:0    1  14.9G  0 disk 
└─sda1   8:1    1  14.9G  0 part 

Here, /dev/sda1 is the partition we want to mount.

You can confirm the filesystem type and UUID with:

sudo blkid

✅ Step 2: Mount the USB Drive Manually

sudo mkdir -p /mnt/usb

Then mount the USB drive:

sudo mount /dev/sda1 /mnt/usb

You can now access the USB contents in /mnt/usb

✅ Step 3: Make the Mount Persistent

To ensure the drive is automatically mounted on boot and remounted when unplugged and replugged:

1. Get the UUID of the USB drive:

sudo blkid

Example output:

/dev/sda1: UUID="1234-ABCD" TYPE="vfat"

Open the /etc/fstab file:

sudo nano /etc/fstab

Add this line at the end:

UUID=1234-ABCD  /mnt/usb  auto  nofail,x-systemd.automount  0  0

Mount all drives to test:

sudo mount -a

 

Introduction to Filebrowser

Filebrowser is a self-hosted file managing interface that allows you to manage files and directories through a web interface. It's a simple and convenient way to access, upload, and manage your files remotely.

Docker Compose Configuration for Filebrowser

This Docker Compose setup deploys Filebrowser in a Docker container, providing an easy-to-use web interface for file management.

Docker Compose File (docker-compose.yml)


version: '3'
services:
  filebrowser:
    image: filebrowser/filebrowser:latest
    container_name: filebrowser
    restart: always
    volumes:
      - /mnt/USB:/srv #Change to match your directory
      - /home/mediatech/filebrowser/filebrowser.db:/database/filebrowser.db #Change to match your directory
      - /home/mediatech/filebrowser/settings.json:/config/settings.json #Change to match your directory
    environment:
      - PUID=$(id -u)
      - PGID=$(id -g)
    ports:
      - 8095:80 #Change the port if needed

Key Components of the Configuration

Service: Filebrowser

  • Imagefilebrowser/filebrowser:latest is the Docker image used for Filebrowser.
  • Volumes:
  • /mnt/USB:/srv: Maps a local directory to the server directory in the container.
  • /home/mediatech/filebrowser/filebrowser.db:/database/filebrowser.db: Persistent storage for Filebrowser's database.
  • /home/mediatech/filebrowser/settings.json:/config/settings.json: Stores configuration settings for Filebrowser.
  • Environment Variables:
  • PUID=$(id -u) and PGID=$(id -g): Sets the user and group ID for file permissions.
  • Ports:
  • 8095:80: Maps port 8095 on the host to port 80 in the container, where Filebrowser's web interface is accessible.

Deploying Filebrowser

  1. Save the Docker Compose configuration in a docker-compose.yml file.
  2. Replace the volume paths with your actual directory paths.
  3. Manually create the filebrowser.db and settings.json by running touch filebrowser.db touch settings.json in the compose directory, if you do not do this you will get permission errors.
  4. Run docker compose up -d to start Filebrowser in detached mode.
  5. Access Filebrowser by navigating to http://<host-ip>:8095.
  6. Default login is admin admin

Configuring and Using Filebrowser

After deployment, use the Filebrowser web interface to manage your files. You can upload, download, and organize files, as well as customize settings according to your needs.