The previous article explained how to install the Uptime Kuma application using Docker. However, by default, Uptime Kuma uses a SQLite database, and you want to change the database to MariaDB for some reasons.
Problem
How to install Uptime Kuma and MariaDB in Docker?
Solution
Although SQLite serves as a superb embedded database option for numerous scenarios, certain inherent limitations render it inappropriate for particular applications. If your application has a large amount of traffic and uses a lot of write modes simultaneously, and the data growth is very fast, your application is not suitable for using a SQLite database. Likewise, with the Uptime Kuma application. If you monitor many hosts using low intervals, it will cause very fast data growth, so you have to think about another database solution besides the SQLite database.
1. Create a Docker Compose file
Create a compose folder in the /opt folder using the command below:
sudo mkdir -p /opt/compose/uptime-kuma/
cd /opt/compose/uptime-kuma/
After that, create docker-compose.yaml file and copy the script below:
services:
mariadb:
image: mariadb:11.4
container_name: mariadb
restart: unless-stopped
environment:
MARIADB_ROOT_PASSWORD: ${MARIADB_ROOT_PASSWORD}
MARIADB_DATABASE: ${MARIADB_DATABASE}
MARIADB_USER: ${MARIADB_USER}
MARIADB_PASSWORD: ${MARIADB_PASSWORD}
volumes:
- mariadb-data:/var/lib/mysql
networks:
- kuma-net
healthcheck:
test: ["CMD", "healthcheck.sh", "--connect", "--innodb_initialized"]
interval: 10s
timeout: 5s
retries: 5
uptime-kuma:
image: louislam/uptime-kuma:2
container_name: uptime-kuma
restart: unless-stopped
depends_on:
mariadb:
condition: service_healthy
ports:
- "3001:3001"
volumes:
- kuma-data:/app/data
networks:
- kuma-net
volumes:
mariadb-data:
kuma-data:
networks:
kuma-net:
After that, create a .env file like the below script (Adjust the value of this file to your liking):
MARIADB_DATABASE=kuma
MARIADB_USER=kuma-user
MARIADB_PASSWORD=123456
MARIADB_ROOT_PASSWORD=qwerty
Run the below command to turn on Docker Compose:
docker compose up -d
To check if the containers are running or not, use the command below:
docker ps
After you type the commands, your screen will show up similar to the one below:

2. Configure the web server
If you use Apache, create a file at /etc/apache2/sites-available/kuma.conf and copy the script below to the file:
<VirtualHost *:80>
ServerName yourdomain.com
DocumentRoot /var/www/html/
ProxyPass / http://localhost:3001/
RewriteEngine on
RewriteCond %{HTTP:Upgrade} websocket [NC]
RewriteCond %{HTTP:Connection} upgrade [NC]
RewriteRule ^/?(.*) "ws://localhost:3001/$1" [P,L]
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Then run the command below:
sudo a2enmod rewrite
sudo a2enmod proxy
sudo a2enmod proxy_http
sudo a2ensite kuma.conf
Check if there is an error in Apache, and if there is no error, reload Apache using the command below:
apachectl -t
sudo systemctl reload apache2
server {
listen 80;
server_name uptime-kuma.yourdomainname.com;
location / {
proxy_pass http://localhost:3001;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
# Added WebSocket support
proxy_set_header Sec-WebSocket-Key $http_sec_websocket_key;
proxy_set_header Sec-WebSocket-Version $http_sec_websocket_version;
proxy_set_header Sec-WebSocket-Extensions $http_sec_websocket_extensions;
# Improve performance of this reverse proxy
proxy_buffering off;
}
# Redirect HTTP to HTTPS if needed for encryption
# Uncomment the following lines if you have SSL enabled
# return 301 https://$host$request_uri;
}
Use the command below to check if there is an error in the nginx configuration and then reload nginx:
sudo nginx -t
sudo systemctl reload nginx
3. Access uptime kuma
Open your browser, and type:
http://ip_server:3001
Then there will be a display like below:

Click MariaDB/MySQL, and your screen will appear similar to the picture below:

Enter in the columns above the values that correspond to the .env file. Click the Next button, and your screen will show up similar to the one below:

You have to wait until finishes, and after that, your screen will appear similar to the image shown below:

Enter in the columns above the value you want and press the Create button, then a display will appear similar to the image provided below:

If you want to make sure Uptime Kuma uses a MariaDB database, run the command below:
docker logs uptime-kuma | grep DB
Your screen will appear similar to the picture shown below:

If you want to monitor the website, click the Add New Monitor button at the top left of the site, and an image similar to the one shown will appear:

Fill in the required fields (at least fill in the Monitor Type, Friendly Name, and URL columns) and press the Save button, then the host you have filled in will look like in the image below:

If you just want to display the status without displaying many attributes, then you can click the Status Pages button at the top right of the site, like the image below:

After you press the Status Page button, the following image will appear:

Click the New Status Page button, and an image will appear similar to the one shown below:

Enter the name and slug you want (I wrote the sites for the name and slug), then press the Next button, and then there will be a display as below:

Enter the host you want to display on the Status Page, after that, click the Save button, then there will be a display as below:

You can see that the hosts to be monitored look simpler, and you can give the URL to other parties to also monitor these hosts.
Note
If you want to back up the MariaDB database running on Docker and learn how to restore the database, you can go to this page.
References
quora.com
magnus919.com
uptimekuma.org

