Podman basics for beginners
Tags: podman, devops, tutorial, beginners
Published: 2024-04-05 18:03:04

## Podman: An Alternative to Docker for Easier Application Development and Deployment

If you've worked with Docker before, you know how it can help us develop, deploy, and run applications easily. But did you know there's an alternative tool called Podman that offers some unique advantages? In this post, we'll dive into Podman and explore how you can use it to manage your containerized applications with ease.

| Table of Contents                                  |
|----------------------------------------------------|
| What is Podman?                                    |
| Podman vs. Docker: Key Differences                 |
| Installing Podman                                  |
| Basic Podman Commands                              |
| Practical Example: Deploying a Service with Podman |
| Advantages of Podman                               |                        
| Final Thoughts                                     |
| Additional Resources                               |

## What is Podman?
Podman is an open-source tool developed by Red Hat that allows you to create and manage containers in a similar way to Docker, but with some key differences. Podman presents itself as a more secure and daemon-less alternative to Docker, making it a great choice for environments with stricter security requirements or more restrictive policies.


![Podman Logo](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1r0xitjq2ruwma6h2uuj.png)


## Podman vs. Docker: Key Differences
While Podman and Docker share many similarities, there are several important differences between the two:

- Podman doesn't require a running daemon, which makes it more secure and less prone to security issues.
- Podman is compatible with most Docker commands, making it easier to migrate from Docker.
- Podman uses a daemon-less architecture, which means containers run natively on the host without a central process.
- Podman provides better integration with Kubernetes and other container orchestration tools.

## Installing Podman
The installation process for Podman varies depending on your operating system. In this example, we'll show you how to install Podman on a Debian/Ubuntu-based system (22.04 version):

```bash
# Update the System
sudo apt update && sudo apt upgrade -y
```

```bash
# Installing Podman Using apt
sudo apt install -y podman
```


```bash
# Verify the Installation
podman --version 

# Output
> podman --version
podman version 4.9.3
```

## Basic Podman Commands
Here are some of the basic Podman commands you can use:

```bash
# Download an image from a registry:
podman pull <image>

# Create and run a container from an image:
podman run <image>

# List running containers:
podman ps

# Stop a running container:
podman stop <container>

# Remove a container:
podman rm <container>

# Create a volume:
podman volume create <volume>

# List existing volumes:
podman volume ls
```

## Practical Example: Deploying a Service with Podmam
In this example, we'll deploy a simple web service using Podman:

First, let's pull the Nginx image from the container registry:
```bash
# Pull the nginx image
podman pull nginx
```

![nginx image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/h5eo2hb8hu8954yem9jo.png)


![podman pull image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/d1tf69oxkpekafalqi6q.png)


![podman image nginx](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8jjqdohnb4xrdpfeg1zv.png)

Next, we'll create and run a new Nginx container:

```bash
# Create and run an nginx container
podman run -d -p 80:80 --name nginx nginx
```

Let's break down this command:

- **podman run**: This tells Podman to create and run a new container.
- **-d**: This runs the container in detached mode, which means it will run in the background.
- **-p 80:80**: This maps port 80 on the host system to port 80 inside the container. This allows us to access the web server from the host.
- **--name nginx**: This gives the container a friendly name, "nginx".
- **nginx**: This specifies the image to use for the container, in this case, the Nginx image we pulled earlier.

Now, if we run podman ps, we should see our Nginx container running:
![podman run](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ykhtwe4c81i9mey3ebsn.png)

![podman ps](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/o7ysivclymiq63vr1h24.png)

Access the web service at http://localhost
![localhost](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/m2azal8e7cft53tqoira.png)

If you need to stop the container, you can use the podman stop command:

```bash
podman stop nginx
```

And to remove the container, you can use the podman rm command:

```bash
podman rm nginx
```

This example demonstrates the basic workflow of using Podman to deploy a simple web service. In a real-world scenario, you would likely create a more complex application using multiple containers, configure networking between them, and potentially integrate with other tools like Kubernetes for orchestration.

## Advantages of Podman
Some of the main advantages of Podman over Docker include:

- Improved security by not requiring a daemon.
- Better integration with Kubernetes and other orchestration tools.
- Compatibility with most Docker commands.
- Daemon-less architecture, making it more efficient and scalable.

## Final Thoughts
Podman presents an interesting alternative to Docker, especially in environments that require more security and reliability. While the learning curve may be similar, the architectural and security differences make Podman a option worth considering for developing and deploying containerized applications.

## Additional Resources

- [Podman Official Documentation](https://docs.podman.io/en/latest/)
- [Podman vs. Docker Comparison](https://www.youtube.com/watch?v=Xx588nbshlM)
- [Podman Tutorials and Examples](https://www.youtube.com/watch?v=VdbjFgqPPE8)