Docker Community Forums

Share and learn in the Docker community.

Few questions how to use Docker with regarding to web apps (Multiple WordPress, NextCloud, VPN etc.)

Hi! My name is Kimberley and I’m new here :blush: (is there anywhere a introduction fora?)

In recent weeks I have started with 2 Raspberry Pi4s and I am very happy with them. What I wanted to achieve is my own apache server with different websites and I succeeded! By making a lot of mistakes and especially starting over a lot and I really mean going through all the steps from the beginning.

Then a friend came up with the tip to try Docker, so I set to work on that. Again it took me hours or even days with a lot of high blood pressure and stress, what a lot it takes to understand that! Respect for everyone who thinks this is a piece of cake! Finally learned a lot, but now I also got a lot of questions, see below;

1.a) Have a Docker container containing Biarms / Mysql, Wordpress and PHPMyAdmin. On my first Raspberry everything runs without a container and because it has several websites running on it, I had to point domain names to the correct folder in file /etc/apache2/sites-available/000-default.conf. But how is that going with Docker container websites? Where do I indicate which domain should go to which Docker container?

1.b) Is it smarter to create a new Docker container per website or is it smarter to host all websites in 1 Docker container?

  1. Now have a NextCloud with Biarms / MySQL running in Docker container, just wondering if I can view the files without opening the Docker container. Where are they stored and can I possibly ensure that they are stored outside the Docker container? (Wordpress files can be viewed and edited outside the container, exactly what I would like with NextCloud)

  2. Is it smart to place different images in 1 Docker container or do you have to grab one Docker container per images? What is Wisdom?

What I ultimately want is my own VPN, cloud storage or NAS, web server with different websites and preferably with a control panel for the websites to be configured. What is the logical structure in Docker here?

To use the fpm image, you need an additional web server that can proxy http-request to the fpm-port of the container. For fpm connection this container exposes port 9000. In most cases, you might want use another container or your host as proxy. If you use your host you can address your Nextcloud container directly on port 9000. If you use another container, make sure that you add them to the same docker network (via docker run --network … or a docker-compose file). In both cases you don’t want to map the fpm port to your host.

$ docker run -d nextcloud:fpm
As the fastCGI-Process is not capable of serving static files (style sheets, images, …), the webserver needs access to these files. This can be achieved with the volumes-from option. You can find more information in the docker-compose section.

Using an external database
By default, this container uses SQLite for data storage but the Nextcloud setup wizard (appears on first run) allows connecting to an existing MySQL/MariaDB or PostgreSQL database. You can also link a database container, e. g. --link my-mysql:mysql, and then use mysql as the database host on setup. More info is in the docker-compose section.

Persistent data
The Nextcloud installation and all data beyond what lives in the database (file uploads, etc) are stored in the unnamed docker volume volume /var/www/html. The docker daemon will store that data within the docker directory /var/lib/docker/volumes/… That means your data is saved even if the container crashes, is stopped or deleted.

A named Docker volume or a mounted host directory should be used for upgrades and backups. To achieve this, you need one volume for your database container and one for Nextcloud.

Nextcloud:

/var/www/html/ folder where all nextcloud data lives
$ docker run -d
-v nextcloud:/var/www/html
nextcloud
Database:

/var/lib/mysql MySQL / MariaDB Data
/var/lib/postgresql/data PostgreSQL Data
$ docker run -d
-v db:/var/lib/mysql
mariadb
If you want to get fine grained access to your individual files, you can mount additional volumes for data, config, your theme and custom apps. The data, config files are stored in respective subfolders inside /var/www/html/. The apps are split into core apps (which are shipped with Nextcloud and you don’t need to take care of) and a custom_apps folder. If you use a custom theme it would go into the themes subfolder.

Overview of the folders that can be mounted as volumes:

/var/www/html Main folder, needed for updating
/var/www/html/custom_apps installed / modified apps
/var/www/html/config local configuration
/var/www/html/data the actual data of your Nextcloud
/var/www/html/themes/<YOUR_CUSTOM_THEME> theming/branding
If you want to use named volumes for all of these, it would look like this:

$ docker run -d
-v nextcloud:/var/www/html
-v apps:/var/www/html/custom_apps
-v config:/var/www/html/config
-v data:/var/www/html/data
-v theme:/var/www/html/themes/<YOUR_CUSTOM_THEME>
nextcloud
Using the Nextcloud command-line interface
To use the Nextcloud command-line interface (aka. occ command):

$ docker exec --user www-data CONTAINER_ID php occ
or for docker-compose:

$ docker-compose exec --user www-data app php occ

1 Like

I am very satisfied with your answers and I will slowly process this. I should have done the questions per question, now I’m getting overwhelmed with too much information at once hahaha. I actually also had questions number 1 to 3, but the last two questions have been placed as a quote. :slight_smile:

Very sweet! But maybe I pretended to be someone who already understood everything hahaha Can I go a little deeper here with the questions?

You said

additional web server that can proxy http-request

Do you mean I have to run a Apache2 container to specify those addresses?

First I’m going to look into the docker-compose section, like you said many times. I like to work with docker-compose files, don’t know why :innocent: If anyone criticizes that, please say it to me! I want to learn…

Can’t find an answer to the question 1.b) is running individual container smarter than creating docker-compose.yml with serveral images (do I said that correct?) Like this: (I’m working with VSCode)

v CONTAINERS 
  v wordpress site one
     v mysql
     v phpmyadmin
     v wordpress
  v wordpress site two
     v mysql
     v phpmyadmin
     v wordpress
  v wordpress site three
     v mysql
     v phpmyadmin
     v wordpress
  v nextcloud
     v mysql
     v nextcloud

or should I work with individual containers?

v CONTAINERS
   v apache2
   v mysql
   v php7
   v phppmyadmin
   v wordpress site one
   v wordpress site two
   v wordpress site three
   v nextcloud

or doesn’t matters at all?

The thing about Persistent data, is it correct when I say that the data is not accessible via Rasp OS, but can be reached in all kinds of ways and therefore more secure?

lewish is someones “let me google this for you bot”. Don’t expect a fitting answer or any follow up posts.

The layout pretty much depends on your needs and the ressources at hand.

The suggestion from lewish is to use a reverse proxy as entrypoint and use fpm versions of the image to save ressources. I would definitly go with a distinct container per site, as the intances won’t be tightly coupled.

Though, you might want to stick with a single mysql instance and use a different database per site container.

May I suggest this exceptional free self-paced docker training? https://container.training/intro-selfpaced.yml.html . The number of slides might seem a lot, but many of them can be rushed thru - they are definitly worh the time!. Make sure to do the hands-on exercises.

update: lewish’s answer is taken from https://github.com/nextcloud/docker/blob/master/README.md#using-the-fpm-image and (like with all its anwers) a vialotion of Post Only Your Own Stuff.