FileBrowser provides a file management interface for your server. It is a good replacement for file managers like FileZilla and WinSCP, etc. It can be used to upload, delete, preview, rename, and edit various files. It also allows you to create users and assign them permissions. You can create temporary links to files or folders as well.
In this article, we will discuss how to install it in a Docker container, using docker-compose as well.
Installing Docker.
But first, you need to update the OS packages.
apt update
Install the necessary packages and add a new repository:
apt install apt-transport-https ca-certificates curl gnupg-agent software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
Update the packages with the new repository:
apt update
Now install Docker itself.
apt-get install docker-ce docker-ce-cli containerd.io
Check the version:
docker --version
Check the status:
systemctl status docker
If it is not running, start it:
systemctl start docker
And add it to autostart.
systemctl enable docker
Installing Docker-Compose
For this project, we only need version 1.25 of Docker-Compose.
curl -L "https://github.com/docker/compose/releases/download/1.25.5/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
Set execute permissions.
chmod +x /usr/local/bin/docker-compose
Check the installation of Docker-Compose:
docker-compose --version
Add the Linux user to the docker group:
usermod -aG docker $USER
Let's create a *.yaml file for Docker-Compose.
To orient ourselves in the future about what we have installed, let's create a separate folder for this project in the /home directory and move into it.
mkdir /home/filebrowser && cd /home/filebrowser
You can also use another directory to place this and other projects.
We will use a repository to create a docker-compose.yaml file at the link https://hub.docker.com/r/filebrowser/filebrowser
Create a file docker-compose.yaml or docker-compose.yml,
vim docker-compose.yaml
And add the following code to it:
version: '3.3'
services:
filebrowser:
container_name: filebrowser
volumes:
- /:/srv
- /root/filebrowser/database/filebrowser.db:/database/filebrowser.db
environment:
- PUID=0
- PGID=0
ports:
- 9090:80
restart: always
image: filebrowser/filebrowser:s6
Where:
container_name: the name of your container;
In the volumes section, we specify the paths through which the database saving and the folder with files will be accessible. In this example, / (root) is indicated, which allows access to all files on the server.
ports: 9090 - the port through which the connection to the manager panel will be made.
Before starting docker-compose, let's create a file for the database filebrowser.db at the path indicated in volumes - /root/filebrowser/database/
If this is not done, we will observe an error in the logs: filebrowser.db is a directory.
Run the script (to do this, you need to be in the directory where our file is created. In this case, it is /home/filebrowser/):
docker-compose up -d
Wait for the images to download and deploy.
Check:
docker-compose ps
or
docker ps
You can also install FileBrowser with one command without using docker compose.
docker run -v /:/srv -v /root/filebrowser/database/filebrowser.db:/database/filebrowser.db -e PUID=0 -e PGID=0 -p 9090:80 -d filebrowser/filebrowser:s6
To view logs, use the command
docker logs -f filebrowser
Now you can use your server's IP and the port you specified, in this case, it's 9090, to connect to the web interface.
For authorization use:
login: admin
password: admin
Enjoy your use.