Loading...

How to Upload and Download Files from Docker Volumes

Jonas Scholz
3 min read 07. Nov. 2024

Docker volumes are great for persisting data, but managing files within them can be challenging. In this tutorial, we'll set up FileBrowser - a modern web application that provides a clean interface to upload, download, and manage files in your Docker volumes.

What is FileBrowser?

FileBrowser is a web-based file management interface that allows you to:

  • Upload and download files through your browser
  • Create, rename, and delete files and folders
  • Edit text files directly in the browser
  • Manage user permissions
  • Search through your files
  • And much more!

Prerequisites

  • Docker installed on your system
  • Basic understanding of Docker volumes
  • 10 minutes of your time

Setting Up FileBrowser

First, let's create a Docker volume to store our files (skip this step if you already have a volume):

docker volume create my_files

Now we can run FileBrowser:

docker run -d --name filebrowser -p 8080:80 -v my_files:/srv filebrowser/filebrowser:latest

Let's break down this command:

  • -d: Runs the container in the background
  • --name filebrowser: Names our container "filebrowser"
  • -p 8080:80: Maps port 8080 on your machine to port 80 in the container
  • -v my_files:/srv: Connects our Docker volume to the container's /srv directory
  • filebrowser/filebrowser:latest: Uses the latest FileBrowser image

Then open your browser and navigate to http://localhost:8080 to access FileBrowser. The default credentials are admin for both the username and password.

Auth

After logging in, you'll see the FileBrowser interface!

FileBrowser

Now this is all pretty cool, but what if we want to customize FileBrowser?

Changing Default Settings

You can customize FileBrowser by mounting a configuration file. Create a filebrowser.json:

{
  "port": 80,
  "baseURL": "",
  "address": "0.0.0.0",
  "log": "stdout",
  "database": "/database.db",
  "root": "/srv"
}

Then run FileBrowser with the config:

docker run -d \
  --name filebrowser \
  -p 8080:80 \
  -v my_files:/srv \
  -v $(pwd)/filebrowser.json:/config/settings.json \
  filebrowser/filebrowser:latest

Using Docker Compose

Of course, you can also use Docker Compose to set this up. Create a docker-compose.yml if you don't have one already:

version: "3"
services:
  filebrowser:
    image: filebrowser/filebrowser:latest
    ports:
      - "8080:80"
    volumes:
      - my_files:/srv
      - ./filebrowser.json:/config/settings.json
    restart: unless-stopped

volumes:
  my_files:

Here we are doing the same thing as before, but in a more readable format.

Conclusion

FileBrowser provides a user-friendly solution for managing Docker volume contents. With proper configuration and security measures, it can be a valuable tool for various use cases from development to production environments.

Additional Resources

If you want to deploy your Docker apps, check out my company sliplane.io. We make it super easy to deploy and manage your Docker apps.

Cheers,

Jonas

Welcome to the container cloud

Sliplane makes it simple to deploy containers in the cloud and scale up as you grow. Try it now and get started in minutes!