Using and configuring external volumes
Overview
This tutorial will explain external volumes, why they are useful, and how to use them in Docker CLI and Docker Compose. Additionally, we’ll compare internal vs. external volumes and provide an example using FileBrowser to manage files inside an external volume.
Videotutorial
Watch this tutorial on Persistent Folders - External Volumes.
What Are External Volumes in Docker?
External volumes are Docker-managed storage locations that persist data even after a container stops or is removed. Unlike bind mounts, which depend on specific host paths, external volumes are managed independently by Docker, making them portable and more secure.
Docker stores volumes in /var/lib/docker/volumes/ on Linux, but you don’t need to manage them manually—Docker takes care of it.
Internal vs. External Volumes: Key Differences
| Feature | Internal Volumes | External Volumes |
|---|---|---|
| Created by | Docker Compose or docker run (implicit) | Manually with docker volume create (locally) or using the docker volumes card (In Panel) |
| Managed by Docker | ✅ Yes | ✅ Yes |
| Needs to be pre-created? | ❌ No | ✅ Yes |
| Best for | Storage only accessible from one container | Persistent data across multiple containers |
Which One Should You Use?
- Use internal volumes If the data is specific to the application defined in your compose file.
- Use external volumes If you need sharing between services, or backups.
Hands-on Practice 1: Using Internal Volumes Locally
Step 1. Creating an External Volume
Create a Docker volume using:
docker volume create my_external_volume
To list existing volumes:
docker volume ls
Step 2. Using an External Volume in a Docker Compose File
When using Docker Compose, define an external volume in your docker-compose.yml.
This example uses the FileBrowser Docker image, which provides a web-based file manager to browse and manage files inside the external volume.
Example: Docker Compose with FileBrowser and External Volume
version: "3.9"
services:
filebrowser:
image: filebrowser/filebrowser
container_name: filebrowser
ports:
- "8080:80"
volumes:
- my_external_volume:/srv
restart: unless-stopped
volumes:
my_external_volume:
external: true
name: my_external_volume
💡 Key Points:
- The FileBrowser service runs on port
8080. - The external volume
my_external_volumeis mounted to/srvinside the container. - FileBrowser will display and manage files inside
/srv. - The
restart: unless-stoppedpolicy ensures the container restarts unless manually stopped.
Step 3. Start the filebrowser service
Now, start the services:
docker-compose up -d
Step 4. Access FileBrowser Web UI
After running the container, open http://localhost:8080 in your browser. You’ll see the FileBrowser web interface, where you can manage files inside my_external_volume.
🔑 Default Login Credentials:
- Username:
admin - Password:
admin
💡 You can change the credentials inside the FileBrowser UI under Settings > Users.
Step 5. Inspecting the External Volume
Check volume details:
docker volume inspect my_external_volume
This will show metadata like mount point and driver.
Step 6. Stop the services
Now, stop the services typing:
docker-compose down
Step 7. Removing an External Volume
Finally, remove the unused external volume:
docker volume rm my_external_volume
You must remove any container using the volume before deleting it.
Hands-on Practice 2: Deploying Filebrowser with External Volumes on a Barbara Edge Node
Now, let's deploy the Filebrowser application using an internal volume to a Barbara Edge Node.
Step 1: ZIP the docker-compose.yaml File
Compress the folder containing the docker-compose.yaml file:
zip -r filebrowser_app.zip ./
Step 2: Upload the Application to Barbara’s Library
- Go to your Barbara Panel’s Library.
- Click on "Add New Application" and name it
filebrowser. - Once created, add a new version and upload the
filebrowser_app.zipfile.
Step 3: Go to the node details view and create an external volume
- Go to your node details view
- Open the "Docker Volumes" card.
- Create a new external volume called
my_external_volume.
Step 4: Deploy the Application to an Edge Node
- Select an edge node from your Barbara Panel.
- Click "Add Card" and choose "Add a New Application".
- Select the
filebrowserapplication and deploy it to the node.
Step 5: Access the Filebrowser Interface
- Open a browser and navigate to
http://[IP_OF_YOUR_NODE]:8080. - You should see the Filebrowser interface, now running on your remote edge node.
Step 6: Verify Data Persistence on the Edge Node
- Stop the application from the Barbara Panel.
- Restart it and check that previously uploaded files remain available.
Step 7: Stop and Uninstall the Application
- In the Barbara Panel, navigate to the application card.
- Stop the application and uninstall it.
Step 8: Delete the volume in Barbara Panel
- Finally, go to the "Docker Volumes" card in the Barbara Panel.
- Locate the
my_external_volumevolume and verify its information. - Delete it.
Summary
External volumes in Docker provide a reliable way to persist data and manage storage efficiently. Compared to internal volumes, they are better suited for long-term storage and multi-container environments.
By using FileBrowser in Docker Compose, you can easily manage files stored in an external volume through a web interface.