8.0.3 docker. Please help with storing data outside the docker

Hi,

I am deploying Seafile using docker in a Ubuntu 20.04 DigitalOcean droplet. In that droplet I also have a blockstore volume attached for extra storage, I mounted it at /mnt/shared.

After reading Seafile documentation I expected that if I set:
/opt/seafile-data:/mnt/shared in the docker-compose.yml then Seafile would store all the data outside the docker filesystem, in the server filesystem at /mnt/shared. However Even if everything seems to work perfectly and I can upload files, I don’t see anything under /mnt/shared, the folder is empty. Actually I have no idea of where the data is stored. If I look for example for seafile.log:

root@files:/# locate seafile.log
    /var/lib/docker/overlay2/eb6aed715159f5c3cf66b4bcbbb0d739470b0517d684374819e9a872b56d67d9/diff/shared/seafile/logs/seafile.log
/var/lib/docker/overlay2/eb6aed715159f5c3cf66b4bcbbb0d739470b0517d684374819e9a872b56d67d9/merged/shared/seafile/logs/seafile.log

and there is nothing in /opt/seafile-data/

root@files:/opt/seafile-data# ls -a
.  ..

I am afraid that this is just me not knowing exactly how docker works. I would also expect the database to be located at /var/lib/mysql but there is nothing there and however there are data/files at /opt/seafile-mysql
Please let me know how can I find out where the files are stored and how would I be able to store the data/files outside the docker instance, in the /mnt/shared folder of the server.

Here is my docker-compose.yml:

version: '2.0'
services:
  db:
     image: mariadb:10.5
     container_name: seafile-mysql
     environment:
       - MYSQL_ROOT_PASSWORD=[password]
       - MYSQL_LOG_CONSOLE=true
     volumes:
       - /opt/seafile-mysql/db:/var/lib/mysql
     networks:
       - seafile-net

   memcached:
      image: memcached:1.5.6
      container_name: seafile-memcached
      entrypoint: memcached -m 256
      networks:
        - seafile-net
      
  seafile:
     image: seafileltd/seafile-mc:latest
     container_name: seafile
     ports:
        - "80:80"
        - "443:443"
     volumes:
        - /opt/seafile-data:/mnt/shared
     environment:
        - DB_HOST=db
        - DB_ROOT_PASSWD=[password] 
        # - TIME_ZONE=Etc/UTC
        - SEAFILE_ADMIN_EMAIL=[email]
        - SEAFILE_ADMIN_PASSWORD=[password]
        - SEAFILE_SERVER_LETSENCRYPT=true
        - SEAFILE_SERVER_HOSTNAME=[domain]
     depends_on:
        - db
        - memcached
     networks:
        - seafile-net

networks:
   seafile-net:

I’m interested in your progress as I am wanting to do the same thing tomorrow morning. Which installation guide did you follow?

@m_elias looks like I can’t add links to my posts, weird.

For now I used the following DigitalOcean tutorials:
the tutorial how-to-install-and-use-docker-on-ubuntu-20-04
and ufw-essentials-common-firewall-rules-and-commands (I opened ports 80 and 443)

Then I created a volume in DigitalOcean, attached it to my droplet, and mounted it in /mnt/shared

Then from the Seafile documentation I looked at the page “Deploy Seafile with Docker” where they provide an example for the docker-composer.yml file, and I created the docker-compose.yml file that I added in my previous post.

Then I just run the docker using
docker-compose up -d

That’s all until now.

So it is fixed now. @m_elias
The problem was that I was incorrectly using the paths inside “volumes:”. Basically you have
path_in_host:path_in_container

So when I was doing:

volumes:
    /opt/seafile-data:/mnt/shared

I was actually trying to attach the container path /mnt/shared to my host path /opt/seafile-data. Which is the opposite than what I wanted to do. So the right thing to do is:

volumes:
   /mnt/shared/seafile-data:/shared

Which attach the container /shared folder to the host folder /mnt/shared/seafile-data, and /mnt/shared is the folder in which I mounted the Digital Ocean blockstore volume. And in the same way you can also move the database to the blockstore volume:

volumes:
    /mnt/shared/seafile-mysql:/var/lib/mysql
2 Likes

@diegosb Thanks for clarifying that. It appears to have worked for me, other then being a docker-compose noob, I wasn’t sure where to put the docker-compose.yml file and I didn’t realize I needed sudo for starting docker-compose. I just created ~/seafile_compose dir and put the yaml in there.

I notice this guide doesn’t mention enabling Docker auto start at boot up nor does it mention any container restart policy.
https://manual.seafile.com/docker/pro-edition/Deploy%20Seafile-pro%20with%20Docker/

I used systemctl enable docker so that Docker at least starts up when the VM [re]boots but I’m not sure where in the yaml to place restart: always

Just like they suggest here https://serverfault.com/questions/884759/how-does-restart-always-policy-work-in-docker-compose I tried adding the line:

restart: always

in each service defined in the yaml. It worked, I tried to reboot the machine and the services are back up.