HowTo: Linux + Podman (Desktop) + Nextcloud + MariaDB

This tutorial is for all, who are looking for a tutorial to get nextcloud running on podman.
As I’m always disappointed, getting tutorials out of date. This tutorial works at least up to 18.02.2026 with Nextcloud docker 32.0.5 and 32.0.6.

In this installation I have a Ubuntu server, but guess this will work with any other linux distribution the same.
Podman Desktop can be installed directly with flatpak from Flathub and then you only have to install podman as guided through Podman Desktop.

For MariaDB I used Docker Hub Container Image Library | App Containerization It is not the recommended one and throws a warning, but the nextcloud works like a charm.
For Nextcloud I used Docker Hub Container Image Library | App Containerization

precondition:
To get and keep all necessary configs and settings, you need some folders for the volumes. As Podman runs rootless you need for all following folders and files ownership and access for your logged in user.

nextcloud_main_folder:
  ├── config.php
  ├── nextcloud.sh
  ├── nextclouddata-folder/
  │   ├── 

Like in Docker you first have to pull both images. In Podman Desktop this is on “Images > Button:Pull”

In your “nextcloud.sh” you can copy an all in one installtion, but keep in mind, that network, pod and database will only created once. So for updates and testing you only need the “podman run” command.
Nextcloud GmbH recommends a MariaDB >= 10.6 und 11.8 <=, so you may prefer to set a defined version.

#!/bin/bash

podman network create -d bridge nextcloudnet

podman pod create --name nextcloudpod -p 8086:80 --network nextcloudnet

podman run -d 
–pod nextcloudpod 
–name mariadb-nextcloud 
-e MYSQL_ROOT_PASSWORD=nextcloud 
-e MYSQL_USER=nextcloud 
-e MYSQL_PASSWORD=nextcloud 
-e MYSQL_DATABASE=nextcloud 
–restart=always 
docker.io/library/mariadb:stable \\

podman run -d 
–pod nextcloudpod 
–name nextcloud 
-v /mnt/cloudron/common/nextcloud/nextclouddata:/var/www/html 
–restart=always 

docker.io/library/nextcloud:latest

The sh must be executable and can be started with ./nextcloud.sh from the current folder or with full path. For security reasons feel free to edit the login credentials for the mariadb nextcloud database.

  • The naming for the network, port and the pod can be edited freely. But need to edited in any other tutorial step later.

After running the skript or all podman command in a terminal, the pod should be created and database and nextcloud should be available on the http://localhost:8086
Podman itself also creates a “cryptic”-infra container to handle the pod itself. You don’t need to care or touch it.

Here you start with the initial config for nextcloud, entering the credentials for mariadb. (I did’nt managed to autofill this in the run command.)

At this step, it runs. Further taska are enabling and hardening additional security settings, addings apps.

1 Like

Part II is an optional one:

For NextPush, News and some other Apps and to remove the warning, you can add Redis as no SQL Cache. For me it fixed an issue with cron jobs too.

In this tutorial, the server is named redis-nextcloud.

If you haven’t initialized nextcloud yet (or for the next installation),you can add the command to the script.

If already running, start the nextcloud maintainance mode, and type the command in the terminal:

podman run -d
–pod nextcloudpod
–name redis-nextcloud
-v /mnt/cloudron/common/nextcloud/redis-data/:/data

redis-server --requirepass {yourpassword} --appendonly yes

As there is not really stored something, one don’t need the “volume” right now, but you never know.

Second, redis don’t need a password, but you harden the unrestricted access to nextcloud.

After that, open nextclouds config.php.

You can do this in the terminal of the podman container (As I don’t like VIM, I first get nano with “apt update”, “apt install nano”, then nano config/config.php” as we already are on /var/www/html.

In addition can mange that on your hosts terminal “podman exec nextcloud nano /var/www/html/config/config.php”

Add after ‘memcache.local’ => ‘\OC\Memcache\Memcached’,

the two new lines:
‘memcache.locking’ => ‘\OC\Memcache\Memcached’,
‘memcache.distributed’ => ‘\OC\Memcached\Memcached’,

Important! Add these lines in the end, meaning after initialization of nextcloud, maria-db etc, but before the closing “);” !

‘redis’ =>
array (
‘host’ => ‘redis-nextcloud’,
‘port’ => 6379,
‘password’ => ‘{yourpasswordagain}’,
),
‘session’ =>
array (
‘type’ => ‘redis’,
‘redis’ =>
array (
‘host’ => ‘redis-nextcloud’,
‘port’ => 6379,
‘password’ => ‘{yourpasswordagain}’,
),
),

You don’t need to open the port outside the pod as nextcloud reaches it internally.

As I also had struggle with the cronjob before redis installation, it seems to fix this problem too. So, set in the config

‘cronjob_mode’ => ‘cron’,

Save the file and exit.

As there are also solutions for systemd or quadlets, for the start and low level entry, it is a host cronjob

create a script on your hosts home directory:

~/scripts/nextcloud-cron.sh

#!/usr/bin/env bash

LOGFILE=“${HOME}/scripts/nextcloud-cron.log”

# u33 is www-data, which is mandatory to run the cronjob inside the container

podman exec -u 33 nextcloud php -f /var/www/html/cron.php

“${LOGFILE}” 2>&1

if [[ $? -eq 0 ]]; then
echo “$(date ‘+%Y-%m-%d %H:%M:%S’) :white_check_mark: cron executed successfully” >> “${LOGFILE}”
else
echo “$(date ‘+%Y-%m-%d %H:%M:%S’) :cross_mark: cron failed (exit code $?)” >> “${LOGFILE}”
fi

At last, open cron

crontab -e

and add

*/5 * * * * /home/{your_user}/scripts/nextcloud-cron.sh

Restart the nextcloud container and end the maintainance mode.

Now you should add “nextpush” and “news”, or other apps requiring redis.