Creating a MariaDB Database
To create a MariaDB database in Dokploy:- Navigate to your project
- Select the environment
- Click “Add Service” and select “MariaDB”
- Configure the database settings
Basic Configuration
- Name - A friendly name for your database
- App Name - The Docker service name (used for internal DNS)
- Description - Optional description
- Docker Image - Default:
mariadb:latest(recommended:mariadb:11ormariadb:10.11)
Database Credentials
- Database Name - Name of the database to create
- Database User - Username for database access
- Database Password - Password for the user
- Root Password - Password for the root user
These credentials are automatically configured via environment variables:
MARIADB_DATABASEMARIADB_USERMARIADB_PASSWORDMARIADB_ROOT_PASSWORD
Advanced Settings
- External Port - Optional port to expose MariaDB externally (default internal port: 3306)
- Command - Override the default container command
- Args - Additional arguments to pass to MariaDB
- Environment Variables - Additional custom environment variables
Connection Strings
Internal Connection (from other services)
When connecting from applications within the same Docker network:MariaDB uses the same protocol and port as MySQL, making it a drop-in replacement in most cases.
External Connection
If you’ve configured an external port (e.g., 3307):Connection String Formats
- Standard URI
- mariadb Command
- Node.js (mysql2)
- Python (mysql-connector)
- PHP (mysqli)
Environment Variables
MariaDB containers support these environment variables:| Variable | Description | Required |
|---|---|---|
MARIADB_ROOT_PASSWORD | Root user password | Yes |
MARIADB_DATABASE | Database to create on startup | Yes |
MARIADB_USER | User to create | Yes |
MARIADB_PASSWORD | Password for MARIADB_USER | Yes |
MARIADB_ALLOW_EMPTY_PASSWORD | Allow root with empty password | No |
MARIADB_RANDOM_ROOT_PASSWORD | Generate random root password | No |
MARIADB_AUTO_UPGRADE | Auto upgrade on version change | No |
Data Persistence
MariaDB data is stored in a Docker volume mounted at:- Mount Path:
/var/lib/mysql - Volume Name:
{appName}-data
Resource Configuration
Configure resource limits for your MariaDB instance:Operations
Starting the Database
Click the “Start” button in the Dokploy UI or use the API:Stopping the Database
Click the “Stop” button or use the API:Reloading the Database
Reload applies configuration changes by stopping and starting the service:Rebuilding the Database
Accessing MariaDB CLI
To access the MariaDB CLI in the running container:Common MariaDB Commands
MariaDB is MySQL-compatible, so most MySQL commands work:MariaDB-Specific Features
MariaDB offers several improvements over MySQL:1. Better Performance
- Improved query optimizer
- Faster replication
- Better thread pool implementation
2. Additional Storage Engines
- Aria - Crash-safe MyISAM replacement
- ColumnStore - Columnar storage for analytics
- Spider - Sharding and partitioning
3. Enhanced JSON Support
MariaDB 10.2+ includes JSON functions:4. Temporal Tables
System-versioned tables for historical data:Backups
Dokploy provides automated backup functionality for MariaDB. Backups are performed usingmariadb-dump (or mysqldump):
Troubleshooting
Connection Refused
- Verify the service is running in Dokploy UI
- Check the service name matches your
appName - Ensure your application is in the same Docker network
Authentication Failed
- Verify credentials in the database settings
- Check user has proper host permissions (
%or specific IP) - Verify
MARIADB_environment variables are set correctly
Migration from MySQL
MariaDB is generally compatible with MySQL, but:- Test thoroughly before production migration
- Check for MySQL-specific features not in MariaDB
- Review version compatibility (e.g., MariaDB 10.6 ≈ MySQL 8.0)
- Use
mariadb-upgradeafter migration
Best Practices
- Use Specific Versions - Pin to specific MariaDB versions (e.g.,
mariadb:10.11.6) instead oflatest - Strong Passwords - Use strong, randomly generated passwords for production
- Regular Backups - Configure automated backups and test restoration
- Monitor Resources - Watch memory and CPU usage, adjust limits as needed
- Security - Don’t expose MariaDB externally unless necessary
- Upgrade Path - Plan upgrades carefully; test in staging first
- Connection Pooling - Use connection pooling in your applications
Performance Tuning
Add these configuration options via environment variables or custom config:MariaDB vs MySQL
| Feature | MariaDB | MySQL |
|---|---|---|
| License | GPL | GPL (Oracle) |
| Performance | Generally faster | Good |
| Storage Engines | More options | Standard |
| JSON Support | Yes | Yes (better in 8.0+) |
| Thread Pool | Yes (built-in) | Enterprise only |
| Community | Active community | Oracle-backed |
| Compatibility | MySQL compatible | - |
Next Steps
Backups
Configure automated MariaDB backups
MySQL
Compare with MySQL documentation