How to Install MongoDB with Podman on Rocky Linux 8

In this tutorial I will be showing you how to install MongoDB with Podman on Rocky Linux.

Mongodb is an open source NoSQL database that provides high throughput for data driven applications. Unlike relational databases such as MySQL, Oracle and SQL server which store data in tables according to a rigid schema, MongoDB stores data in documents with flexible schema.

Podman is a daemonless, open source, Linux native tool designed to make it easy to find, run, build, share and deploy applications using Open Container Initiative (OCI) containers and container images. 

Related Articles


  • Rocky Linux server
  • User with sudo privileges
  • Internet connection

Table of Contents

  1. Update your system repositories
  2. Install Podman
  3. Pull MongoDB using Podman
  4. Create MongoDB container
  5. Conclusion

1. Install Podman

We need to first install podman into our system with the following command.

$ sudo dnf install podman -y

Sample output will be as follows



Check version of Podman

$ podman -v
podman version 3.3.1

2. Pull MongoD using Podman

$ podman pull mongo

Choose where you want to pull your image from. For my case I chose Docker, you can use Fedora, Redhat or Centos whichever distro you prefer.

For Docker the output should be like this

Trying to pull
Getting image source signatures
Copying blob 90eb44ebc60b done  
Copying blob 7b1a6ab2e44d done  
Copying blob 019496b6c44a done  
Copying blob c0df4f407f69 done  
Copying blob 5085b59f2efb done  
Copying blob c7499923d022 done  
Copying blob 351daa315b6c done  
Copying blob 5b6df31e95f8 done  
Copying blob 98e820b4cad7 done  
Copying blob e82745116109 done  
Copying config 4253856b25 done  
Writing manifest to image destination
Storing signatures

Check to see the images

$ podman images 
REPOSITORY               TAG         IMAGE ID      CREATED      SIZE  latest      4253856b2570  8 hours ago  706 MB

You can test mongodb now with the following:

$ podman run --rm -it mongo

3. Create MongoDB Container

Create a directory to store MongoDB data so that in case you delete the container you will still got your data intact.

$ sudo mkdir data
$cd data

After you have cd into the directory, now you can create your MongoDB container with thefollowing command:

$ podman run --name nextgentipsmongo -d -p 27017:27017 -v $(pwd):/data/db:Z mongo

Let’s look at each command variable:

  • –name: describe the name of the project i.e nextgentipsmongo
  • -d: run your container in detached mode i.e in the background
  • -p 27017:27017: map port 27017 of the host to port 27017 on the container.
  • -v (volume): create persisting data generated and used by podman containers.
  • $(pwd):/data/db: shows the directory to to store your data.
  • :Z– tells podman that the volume content will be shared between containers

4. Test MongoDB

We can test our container to see if it is working with the following command; If it was installed correctly it should show the mongo shell where you can now perform your database routines.

$ podman run --rm -it --network host mongo mongo
MongoDB shell version v5.0.4
connecting to: mongodb://
Implicit session: session { "id" : UUID("9a9cc44d-696a-4370-ab0c-bb2d9fe12ded") }
MongoDB server version: 5.0.4
Warning: the "mongo" shell has been superseded by "mongosh",
which delivers improved usability and compatibility.The "mongo" shell has been deprecated and will be removed in
an upcoming release.
For installation instructions, see
Welcome to the MongoDB shell.
For interactive help, type "help".
For more comprehensive documentation, see
Questions? Try the MongoDB Developer Community Forums
The server generated these startup warnings when booting: 
        2021-11-17T11:01:45.156+00:00: Access control is not enabled for the database. Read and write access to data and configuration is unrestricted
        2021-11-17T11:01:45.156+00:00: /sys/kernel/mm/transparent_hugepage/enabled is 'always'. We suggest setting it to 'never'
        Enable MongoDB's free cloud-based monitoring service, which will then receive and display
        metrics about your deployment (disk utilization, CPU, operation statistics, etc).

        The monitoring data will be available on a MongoDB website with a unique URL accessible to you
        and anyone you share the URL with. MongoDB may use this information to make product
        improvements and to suggest MongoDB products and deployment options to you.

        To enable free monitoring, run the following command: db.enableFreeMonitoring()
        To permanently disable this reminder, run the following command: db.disableFreeMonitoring()
> db.test

5. Conclusion

Congrartulation you have successfully install MongoDB with Podman on a RockyLinux platform. You can now move ahead and connect your database to your project.

About Kipkoech Sang

I am a technology enthusiast who loves to share gained knowledge through offering daily tips as a way of empowering others. I am fan of Linux and all other things open source.
View all posts by Kipkoech Sang →

Leave a Reply

Your email address will not be published.