1) Install Docker Manager in the App Store.
2) Run Docker Manager, go to Image management and get the latest nextcloud and mariadb images by simply entering their image names.

3) Prepare folders for permanent storage of your container data. I suggest to create a "docker" folder in which you create another folder for your actual container. I will name them "nextcloud" and "mariadb".

4) Create the containers in Docker Manager. To do so you need to know which ports and directories your applications are working with. This information can usually be found at the docker hub of your application. In case of nextcloud the link is: https://hub.docker.com/_/nextcloud/
Nextcloud uses port 80 and saves it's data in the directory /var/www/html
You need to map the port 80 to something free on your server. I will use 8080.
Also map the directory of your container /var/www/html to the directory we prepared earlier /docker/nextcloud

5) Change the container name to something that makes sense - nextcloud for example.

6) Repeat the procedure for MariaDB. This time map port 3306 to something free. I will simply add an 0 and use port 33060. Your directory mapping needs to be /var/lib/mysql to /docker/mariadb
This time we also need to add Environment Variables in order to create the necessary database for nextcloud to work with:
MYSQL_ROOT_PASSWORD=password
MYSQL_DATABASE=nextcloud
MYSQL_USER=nextcloud
MYSQL_PASSWORD=password

Simply change the values after "=" to whatever you want your password or name to be.

7) Change the container name to something easy again.
8) Get the IP of your MariaDB container by going to the Terminal and entering docker exec mariadb cat /etc/hosts. The name after exec is your container name. Now you know why we changed it to something easy 😀

Note the IP address you see at the very bottom.
9) Now run the Nextcloud-Setup by entering your servers IP followed by the nextcloud port in your browser. Choose an account name and password and fill in the mariadb database details as well as the correct IP and port of your container.

10) Congrats you did it! You sucessfully set up Nextcloud and MariaDB using Docker Manager!

    Took me quite a while to figure out everything, so i hope it's helpful for you guys!

    9 days later

    I can not enter database as root too
    ERROR 1045 (28000): Access denied for user 'root'@'172.17.0.3' (using password: YES)

    6 days later
    4 months later

    neotheghost

    Great!

    Tell me, what is the difference of using the docker/container or doing the installation "common"?

    I use with ownCloud.

    8 months later

    How to fix it?
    Error while trying to initialise the database: An exception occurred while executing a query: SQLSTATE[HY000]: General error: 4047 InnoDB refuses to write tables with ROW_FORMAT=COMPRESSED or KEY_BLOCK_SIZE.

      3 months later

      It works smooth for me, thanks a lot
      I avoided installing again MariaDB, so I didn't create a MariaDB container and I just used my current IP and port to connect it.

      Now, I have NextCloud, fully operational on my IP and some Port.
      My question is: how can I setup to assign a subdomain and SSL?

      Tahnk you
      Great tutorial

        To be honstest, quite some time passed since then, and i have a much easier and better solution now i would recommend you to use.

        PORTAINER + NGINX PROXY MANAGER

        Its a dream combo for running multiple docker apps on 1 server.

        I would highly suggest to do this instead, since portainer is such a powerful tool and will save you so much time in the long run working with docker containers.

        If anyone is interested i this, then i will make a complete step by step Youtube tutorial.

          a month later

          neotheghost
          First of all, I like to thank you, for the Tutorial. It works good, but I could not manage to run with an qualified domain name, such as cloud.domain.com. I am interested to learn about PORTAINER + NGINX PROXY MANAGER.
          Thank you!

          17 days later
          a month later

          Although this post if old it did help but I don't want to have another docket for SQL when there is a decent SQL server built into aapanel but I'm unable to get Nextcloud to connect to it. any help will be appreciated.
          Could this maybe have something to do with SYS Firewall as I also want a database or two to be useable for my game servers as it'll allow me to sync permission between servers instead of copying them manually for each and they are unable to connect too.

          6 months later

          For those who are only installing nextcloud on docker and using MySQL from aapanel itself, when creating the MySQL user, remember to give permission to everyone, not just to the local server. Otherwise, there will be a permission denied error.

          Very good tip and tutorial.

          a month later
          6 months later

          Sir, it is the Very good way to install nextcloud to aapanel. thank you sir.
          but Please can you help me one thing sir, you are install installing at root directory and access site using host ip address, but if i want to create is on a website what is the process. Example : First i will create a website like mycloud.domain.com then install next cloud and want to use to access it https:.//mucloud.domain.com with out port and all file want to install this /www/wwwroot/mycloud.domain.com.
          Please help me sir. I did try but shows error.

          Connect with us: 📨 Telegram 💬 Discord Email: support@aapanel.com