Category: Linux Server

  • How to Deploy MariaDB with Portainer Stacks Using Docker Compose


    If you’re looking to run a robust relational database in your Dockerized environment, MariaDB is an excellent open-source choice. With Portainer, managing your databases and application stacks becomes super easy—even with little Docker experience. In this post, I’ll walk you step by step through deploying MariaDB using Portainer Stacks (which leverages Docker Compose).


    Why Use MariaDB with Portainer?

    • MariaDB: Powerful open-source database, compatible with MySQL.
    • Portainer: Friendly web UI to easily deploy, manage, and monitor Docker containers, stacks, and services.

    Using them together lets you:

    • Quickly spin up databases.
    • Take advantage of persistent storage.
    • Easily manage your containers and stacks through a visual interface.

    Step 1: Access Your Portainer Dashboard

    You need your Portainer instance up and running. Log in at
    http://<your-server>:9000
    Replace <your-server> with your server’s IP or domain.


    Step 2: Open Portainer Stacks

    • On the left sidebar, click Stacks.
    • Then, click the “+ Add stack” button.

    Step 3: Compose the MariaDB Stack

    1. Name your stack (e.g., mariadb-stack).
    2. In the Web editor area, paste the following Docker Compose YAML (and adjust credentials as needed):
       version: '3.8'
    
       services:
         mariadb:
           image: mariadb:11.3
           container_name: mariadb
           restart: unless-stopped
           environment:
             - MARIADB_ROOT_PASSWORD=YourRootPassword123
             - MARIADB_DATABASE=mydatabase
             - MARIADB_USER=myuser
             - MARIADB_PASSWORD=userpassword
           ports:
             - "3306:3306"
           volumes:
             - mariadb_data:/var/lib/mysql
    
       volumes:
         mariadb_data:

    What does this do?

    • Pulls the latest MariaDB image (v11.3).
    • Sets up root/user passwords and a database.
    • Persists your data in a Docker volume (mariadb_data).
    • Exposes MariaDB on the default port 3306.

    Step 4: Deploy Your MariaDB Stack

    Scroll to the bottom and click Deploy the stack.

    Portainer will pull the required images and create your MariaDB container.


    Step 5: Connect & Use Your Database

    The MariaDB instance is now running! You can connect to it:

    • From any app on the server:
      localhost:3306, user myuser, password userpassword
    • From another machine (if port 3306 is accessible):
      your-server-ip:3306, same credentials

    Use your favorite MariaDB/MySQL client, or connect from other containers via the Docker network.


    Optional: Add phpMyAdmin for Easy Database Management

    Want a web interface for MariaDB? Just add phpMyAdmin to the stack by updating your YAML:

    version: '3.8'
    
    services:
      mariadb:
        image: mariadb:11.3
        container_name: mariadb
        restart: unless-stopped
        environment:
          - MARIADB_ROOT_PASSWORD=YourRootPassword123
          - MARIADB_DATABASE=mydatabase
          - MARIADB_USER=myuser
          - MARIADB_PASSWORD=userpassword
        ports:
          - "3306:3306"
        volumes:
          - mariadb_data:/var/lib/mysql
    
      phpmyadmin:
        image: phpmyadmin:latest
        restart: unless-stopped
        ports:
          - "8080:80"
        environment:
          - PMA_HOST=mariadb
          - PMA_USER=myuser
          - PMA_PASSWORD=userpassword
    
    volumes:
      mariadb_data:

    Now, after redeploying the stack, visit:
    http://<your-server>:8080 for a full-featured GUI!


    Tips & Best Practices

    • Secure Your Database: Don’t expose port 3306 to the internet unless necessary.
    • Persistent Storage: Docker volumes make it easy to back up or move data.
    • Stack Upgrades: Edit the stack YAML and re-deploy for future changes.

    Conclusion

    With just a few clicks and a simple YAML file, you can have a resilient MariaDB server up and running using Portainer Stacks and Docker Compose. Add phpMyAdmin for web-based administration, and you have a powerful, easy-to-manage development or production setup!

    Have questions or run into trouble? Drop a comment below! 🚀


  • How to set up PhpMyAdmin with MariaDB on Portainer with NGINX Proxy Manger.

    PhpMyAdmin is easy to set up for any app and fix the table database or troubleshoot. So, we will set up PhpMyAdmin with NGINX SSL secure for our HTTPS. Due to the possibility of a grabber username and password exploit, we would prefer not to expose this on HTTP.

    Please ensure that you complete this first. Before starting, we should make sure that this tutorial prevents hacking and exposes our port to the public. We do not want that to happen. We only want 80 and 443 to be open.

    How to set up Portainer with nginx Proxy Manager

    After you complete Portainer and nginx, we are good to go to build this app with nginx and PhpMyAdmin.

    Open Portainer → Stacks→ create stacks

    version: '3'
    services:
      pma:
        networks:
          - nginx
          - mariadb
        image: phpmyadmin/phpmyadmin
        container_name: pma
        environment:
          PMA_ARBITRARY: 1
        restart: always
        #ports:
         # - 8081:80
    networks:
      nginx:
        external: true
      mariadb:
        external: true

    I put hashtags on ports and port numbers because we don’t need them. We’ll just use nginx network on this app. Nginx proxy can talk to PhpMyAdmin instead of port or public. It is more secure to build our app before it is published to the public. Your sites can be injected with any insecure port.

    After deploying the stacks, your PhpMyAdmin is now online, but it won’t show up on the site because you didn’t set up the nginx proxy info. That would be our next step.

    You should open the nginx proxy manager for your site. My will be nginx__.richardapplegate.io.

    Thereafter, you’ll need to access your admin account. Add proxy host, then fill this detail.

    I configured the PMA to forward hostname/IP as a result of setting docker-compose on the PhpMyAdmin container_name to the PMA. And this app uses 80 ports on the NGINX network.
    Make sure you enable SSL and HTTP/2 and HSTS.

    Now you may be able to open your site with a domain without port. My will be phpmyadmin.richardapplegate.io. and working!

    Server: your database container_name on docker-compose. Mine is mariadatabase
    Username: your primary account for all database control. Mine is root.
    Password: you create the password and the password should on your docker-compose. You won’t be possible to log in my PhpMyAdmin because 3 times incorrect information, then you will be banned. You won’t access from my server or see my sites anymore for 1 week.

    You’re in the MariaDB database.

    “SSL is not being used” is normal because itself PhpMyAdmin is not on public, it is on nginx proxy manager. So, PhpMyAdmin is not public, it is full secured under the nginx. And you can see that we can create databases or tables or control user accounts.
  • How to set up Baserow on Portainer with nginx proxy manager

    This baserow is my absolute favorite, it’s more like a spreadsheet with more options and an easy-to-use database. It also had a Grid and Form and a Gallery and a Calendar! It’s great for our list of things to do.

    Look over Baserow.io!

    You’ll need Portainer and nginx running, remember? If not, here are my instruction to set up on your server.

    Let’s build stacks now.

    Open Portainer site → stacks → add stacks

    version: "3.4"
    services:
      baserow:
        container_name: applegate-baserow
        image: baserow/baserow:1.24.2
        networks:
          - nginx
          - mariadb
        environment:
          BASEROW_PUBLIC_URL: 'https://sub.domain.com'
        volumes:
          - /yourpath/baserow/data:/baserow/data
    networks:
      nginx:
        external: true
      mariadb:
        external: true
        

    Before you deploy, please ensure you follow the high light and modify and edit the networks to match your nginx proxy manager and MariaDB Database Network. Then, deploy the stack and this app is online but not show on site. We need to go to nginx proxy manager to set up a proxy host for baserow.

    Scheme – HTTP
    Forward Hostname – Your container_name here
    Forward port – Expose 80 to here.
    ensure to enable SSL and HTTP/2 and HSTS

    The sign-up form should appear when you open the base row. Please complete it for the first user, and this account will provide you with an admin account.

Secret Link