1. Home
  2. Linux
  3. Deploy nextcloud in podman on ubuntu

Deploy NextCloud in Podman on Ubuntu

If you’d like to deploy NextCloud on Podman, it’s a bit different than on Docker. However, different doesn’t mean harder. In this guide, we’ll go over the ins and outs of deploying NextCloud on Docker.

Nextcloud on Podman Hero image.

How to install Podman on Ubuntu Server

Before you can deploy Nextcloud in a Podman container, you need to install it on the Ubuntu container host system. To start the installation on Ubuntu, log into the Ubuntu container, and launch a terminal. Once the terminal window is open and ready to use, enter the apt update command to update your Ubuntu system’s software sources.

sudo apt update

After updating your Ubuntu system’s software sources, you’ll need to install pending software upgrades. You can do this by entering the apt upgrade command.

sudo apt upgrade -y

Once everything is up to date, you’re ready to install the Podman package. Using the apt install command, set up the “podman” package.

sudo apt install podman podman-compose

Note that if you are on a version of Ubuntu Server below 23.10, you’ll need to install podman-compose with:

sudo apt install python3-pip

sudo pip3 install podman-compose

With the Podman package installed, you’ll need to test the package and find out if it is working correctly. You can quickly check the Podman package by running the podman --help command.

podman --help

Assuming the podman --help command executes correctly, and Podman is up and running, it is ready to use on your Ubuntu container host system. However, if nothing happens, you may need to re-install Podman.

How to pull the Nextcloud image

To deploy NextCloud in a Podman container, you must first pull down the official NextCloud container from Dockerhub. Open a terminal on the Ubuntu container host, and use the podman pull command to grab the latest “nextcloud” image.

podman pull nextcloud

Pulling the NextCloud image shouldn’t take long at all. Once the pull is complete, you can move on to pulling the database image.

How to pull the MariaDB image

NextCloud needs a dedicated database container to run correctly, and relying on the built-in “Sqlite” database is highly discouraged, as it is extremely unreliable. Here’s how to get the MariaDB image pulled.

Using the podman pull command, pull the mariadb image directly from Dockerhub.

podman pull mariadb

How to install CNI plugins

You need CNI plugins installed on Ubuntu to fully take advantage of Podman. Setting these plugins up can be confusing. To simplify things, I’ve written a simple bash script that takes care of it. View the code here.

To install the CNI plugins on your Ubuntu system, simply run the following command:

curl -fsSL https://raw.githubusercontent.com/soltros/random-stuff/main/cni-tool.sh | bash

How to deploy NextCloud inside of Podman

The Nextcloud file interface.

Now that you’ve pulled the images, it is time to create the Podman volumes that your NextCloud data and MariaDB database data will live on. To create these volumes, use the podman volume create command below.

podman volume create nc-app

podman volume create nc-data

podman volume create nc-db

After creating your volumes, you’ll need to verify they’re on the system. To do this, run the podman volume ls command.

podman volume ls

Assuming the volumes are present on your system, you need to create a network for NextCloud to use. To do this, use the podman network create command below.

podman network create nc-net

Once you’ve created your network, it is time to create our deployment scripts. We’ll be making two scripts. First, create your database deployment script file by entering the touch command below.

touch nc-podman-db-deploy.sh

Next, open up the file in the Nano text editor.

nano nc-podman-db-deploy.sh

Paste the following code to the Nano text editor. Be sure to edit the code so that “USER_PASSWORD” and “DBROOT_PASSWORD” are changed to memorable, secure passwords.


podman run --detach \
  --env MYSQL_DATABASE=nextcloud \
  --env MYSQL_USER=nextcloud \
  --volume nc-db:/var/lib/mysql \
  --network nc-net \
  --restart on-failure \
  --name nextcloud-db \

Save the edits with Ctrl + O, and exit with Ctrl + X. Then, use the touch command to create the second NextCloud deployment script.

touch nc-podman-app-deploy.sh

Open up the script file in Nano, and paste in the following code. Be sure to change “DB_USER_PASSWORD” to match the first deployment script. Additionally, change “NCADMIN” to your desired admin username, and “NCPASSWORD” to a secure NextCloud password.


# Run Podman container with environment variables
podman run --detach \
  --env MYSQL_HOST=nextcloud-db.dns.podman \
  --env MYSQL_DATABASE=nextcloud \
  --env MYSQL_USER=nextcloud \
  --volume nc-app:/var/www/html \
  --volume nc-data:/var/www/html/data \
  --network nc-net \
  --restart on-failure \
  --name nextcloud \
  --publish 8080:80 \

When done, save the edits with Ctrl + O and exit with Ctrl + X. Run the scripts with:

bash nc-podman-db-deploy.sh

bash nc-podman-app-deploy.sh

Next, use the exec commands to update the container and install Nano.

podman exec -u root -it nextcloud apt update

podman exec -u root -it nextcloud apt upgrade

podman exec -u root -it nextcloud apt install nano

Open the config.php file for editing in Nano.

podman exec -u root -it nextcloud nano /var/www/html/config/config.php

Find “localhost” and change it to your desired trusted domain. In this guide, we changed “localhost” to “ubuntu-server-vm”. Once you’ve made your edits, press Ctrl + O to save, and Ctrl + X to exit.

You’ll now need to restart the container using:

podman container restart nextcloud

With the Nextcloud container restarted, log in with your Nextcloud user account and password. From here, you’ll be able to configure your NextCloud installation!

Starting up containers

The Nextcloud dashboard.

There’s no need to re-run the scripts unless you plan on re-installing NextCloud. Instead, if you need to start up NextCloud again, do the following:

podman container start nextcloud

podman container start nextcloud-db

You Can also stop them with:

podman container stop nextcloud

podman container stop nextcloud-db

Lastly, you can reboot them with:

podman container restart nextcloud

podman container restart nextcloud-db

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.