It is currently Sun Sep 20, 2020 2:42 am
All times are UTC + 8 hours

Docker concept questions - docker database and backup related questions hosted on NAS

Docker containers wrap a piece of software in a complete filesystem that contains everything needed to run: code, runtime, system tools, system libraries – anything that can be installed on a server. This guarantees that the software will always run the same, regardless of its environment.

Docker concept questions - docker database and backup related questions hosted on NAS

Postby krunchynug8 » Mon Jun 15, 2020 12:00 pm

Hi folks I am new to docker. There is a few questions that I have on my mind. If anyone can answer anyone of these please reply.
Background - I am running docker on an Asustor NAS - Nimbustor 2 with Portainer.
I want to run the following apps for example - Bitwarden - with Mariadb/MySQL, Wordpress - with phPMYAdmin - with MySQL, Bookstack with MySQL and Calibre web (I think this does not need a database? not sure)
Since most of these apps use database hence my database question

Question 1: Can I use an external database? Is it safe to use the host database? Database is on the host. I cannot get the container to access the host database.
Question 2: If I use a container Database (Mariadb container) can all of these 4 apps access this one container to store their data? Or do I require 4 containers running Mariadb one for each app?
Question 3: Is it possible to backup containers? How do I backup a database if it is in a container? Does the database store its data inside files? I am a noob when it comes to databases.
Question 4: Is it possible to administer a database using phPMYAdmin if it is running in a container?
Question 5: I will be using Bind volumes to store the data from these apps to a docker folder in my NAS under their respective directories. If I update a container or loose a container is all of my data safe in the NAS? Is it better to use docker volumes are they persistent? What is an NFS volume?

Sorry if some of these questions seems basic. I am willing to read the manual but some of the concepts are not clearly stated.
Thanks.
krunchynug8
 
Posts: 12
Joined: Thu May 28, 2020 1:30 pm

Re: Docker concept questions - docker database and backup related questions hosted on NAS

Postby Nazar78 » Wed Jul 01, 2020 4:01 am

Question 1: Can I use an external database? Is it safe to use the host database? Database is on the host. I cannot get the container to access the host database.

Safe or not, no differences. Yes you can let the container access the host but since the host database is only bind to the local interface 127.0.0.1:3306, without changing the host DB settings, you can bind the host unix socket to the container. I've posted it somewhere recently in this section on how to bind and share the unix socket. Edited: here viewtopic.php?f=220&t=11178


Question 2: If I use a container Database (Mariadb container) can all of these 4 apps access this one container to store their data? Or do I require 4 containers running Mariadb one for each app?

All the apps can share the container DB, similar concept to question #1, you either edit the container DB local bind to the docker subnet i.e. 172.x.x.x:3306 or expose the container DB socket to a shared path on the host e.g. host: /var/run/ and container: /var/run/mysqld/ they can access the same mysqld.sock.


Question 3: Is it possible to backup containers? How do I backup a database if it is in a container? Does the database store its data inside files? I am a noob when it comes to databases.

Bind the container DB path /var/lib/mysql to the host e.g. /share/Docker/mysql and you can backup this NAS path. But I think best way is to schedule a DB dump i.e. mysqldump -u${MYSQL_USER} -p${MYSQL_PASS} --socket /var/run/mysqld/mysqld.sock --all-databases|gzip > backup-$(date '+%Y%m%d-%H%M%S').sql.gz


Question 4: Is it possible to administer a database using phPMYAdmin if it is running in a container?

Yes point phpmyadmin to the exposed /var/run/mysqld/mysqld.sock or if you chose to edit the network bind to 0.0.0.0:3306.


Question 5: I will be using Bind volumes to store the data from these apps to a docker folder in my NAS under their respective directories. If I update a container or loose a container is all of my data safe in the NAS? Is it better to use docker volumes are they persistent? What is an NFS volume?

Yes the data should be safe as it's outside of the container but it's not fool proof to crashes so backup regularly. Docker volumes it's up to you as it's almost the same to me, bind volumes easier to access from the host. NFS is network file system, you don't actually need this unless you span your data across multiple NAS/System i.e. nginx running on NAS-A serve wordpress files from NAS-B.
Last edited by Nazar78 on Wed Jul 01, 2020 1:53 pm, edited 1 time in total.
AS5304T - 16GB DDR4 - [40TB N300 RAID10 + 5 Bay USB: 8TB RAID5 & 480GB SSD for Apps]
Nazar78
 
Posts: 119
Joined: Wed Jul 17, 2019 10:21 pm

Re: Docker concept questions - docker database and backup related questions hosted on NAS

Postby krunchynug8 » Wed Jul 01, 2020 7:23 am

Awesome. Thanks for your replies :D . Very precise and helpful answers. I have figured most of this out since posting this question by reading online. But very helpful thank you.
I now have a setup that uses a single MariaDB container with bind volumes for all the apps, including the container, working beautifully. I plan to set up another container that runs a cron job to backup the database regularly.
krunchynug8
 
Posts: 12
Joined: Thu May 28, 2020 1:30 pm

Re: Docker concept questions - docker database and backup related questions hosted on NAS

Postby Nazar78 » Sat Jul 04, 2020 1:44 am

Np glad it helps. It's up to individual how to plan the layout. Just to share, for me I don't really have that many running docker apps. The only one reason why I use docker is for those apps that I want to limit its CPU i.e. 25% of only any one core (note it's not CPU affinity). I even have all those docker apps running at it's lowest priority (nice 19) and schedule (idle 39). These low priorities are for apps such as transmission, sonarr, jackett etc. As for my normal priority web, stream, fcgi apps including httpd and mysql, I run them all in a single debian chroot (NAS access mounted into it). Easily back them up using tar gzip every midnight and the db dump scheduled hourly in the chroot cron job. Actually all these are easily ported over from my old decommissioned NAS, just bring over the chroot and made few changes, and I have lots of customization so docker isn't a choice.
AS5304T - 16GB DDR4 - [40TB N300 RAID10 + 5 Bay USB: 8TB RAID5 & 480GB SSD for Apps]
Nazar78
 
Posts: 119
Joined: Wed Jul 17, 2019 10:21 pm

Return to Docker

  • You cannot post new topics in this forum
    You cannot reply to topics in this forum
    You cannot edit your posts in this forum
    You cannot delete your posts in this forum
    You cannot post attachments in this forum
  • Who is online

    Users browsing this forum: No registered users and 3 guests