# Run Seafile - Cloud Storage System - in Docker

## What is Seafile?

> Seafile is an open source file sync&share solution designed for high reliability, performance and productivity. Sync, share and collaborate across devices and teams. Build your team's knowledge base with Seafile's built-in Wiki feature. - https://seafile.com/

## Installing Docker

1. Log into the Linux based device
2. Run the following commands in the terminal
   # install prerequisites
   sudo apt install apt-transport-https ca-certificates curl software-properties-common gnupg-agent -y
   # add docker gpg key
   curl -fsSL https://download.docker.com/linux/$(awk -F'=' '/^ID=/{ print $NF }' /etc/os-release)/gpg | sudo apt-key add -
   # add docker software repository
   sudo add-apt-repository "deb [arch=$(dpkg --print-architecture)] https://download.docker.com/linux/$(awk -F'=' '/^ID=/{ print $NF }' /etc/os-release) $(lsb_release -cs) stable"
   # install docker
   sudo apt install docker-ce docker-compose containerd.io -y
   # enable and start docker service
   sudo systemctl enable docker && sudo systemctl start docker
   # add the current user to the docker group
   sudo usermod -aG docker $USER
   # reauthenticate for the new group membership to take effect
   su - $USER

## Running Seafile

1. Now that Docker is installed, run the following commands to setup the Seafile Docker container and run it
   # create working directories
   mkdir ~/docker/mariadb -p && mkdir ~/docker/seafile
   # set owner of working directories
   sudo chown "$USER":"$USER" ~/docker -R
   # create containers network
   docker network create containers
   # run the mariadb docker container
   docker run -d --name mariadb --network containers -e MYSQL_ROOT_PASSWORD=r00tp@ss -v ~/docker/mariadb:/var/lib/mysql --restart=unless-stopped mariadb:latest
   # run the seafile docker container
   docker run -d --name seafile --network containers -p 8080:80 -e DB_HOST=mariadb -e DB_ROOT_PASSWD=r00tp@ss -e TIME_ZONE=America/New_York -v ~/docker/seafile:/shared --restart=unless-stopped seafileltd/seafile-mc:11.0-latest

## Seafile Setup

1. Open a web browser and navigate to http://DNSorIP:8080
2. Login with the username me@example.com and password asecret
3. Click the profile icon at the top right of the screen > System Admin
4. Select Users from the left navigation menu
5. Click the Add User button at the top of the screen
6. Complete the new user form with an email and password > Click Submit
7. Click the Admin tab
8. Click the Add Admin button at the top of the screen
9. Search for and select the the new user > Submit
10. Click the profile icon at the top right of the screen > Logout
11. Log back in using the new user credentials
12. Click the profile icon at the top right of the screen > System Admin
13. Select Users from the left navigation menu
14. Check the box next to the me@example.com > Click Delete Users at the top of the screen
15. Welcome to Seafile

Documentation: https://manual.seafile.com/docker/deploy_seafile_with_docker/