Tag Archives: Podman

How to use docker compose with Podman on Linux

Introduction

Using docker compose with Podman on Linux is a straightforward process, especially because Podman is designed to be a drop-in replacement for Docker. This means you can use Podman to run software that was written for Docker, such as Docker Compose, without modifying the Dockerfile or docker-compose.yml files.

Setting up Docker Compose with Podman

Here’s a step-by-step guide to using docker-compose with Podman on Linux:

1. Install Podman

First, ensure that Podman is installed on your system. You can install Podman using your package manager. For example, on Ubuntu:

sudo apt update
sudo apt install -y podman

On Fedora or CentOS:

sudo dnf install -y podman

2. Install Docker Compose

You also need Docker Compose. Install it using pip:

sudo pip3 install docker-compose

3. Set Up Podman to Mimic Docker

You need to configure Podman to mimic Docker. This involves setting up alias and ensuring that socket files are correctly handled.

You can alias Docker commands to Podman for your user by adding the following line to your ~/.bashrc or ~/.zshrc:

alias docker=podman

After adding the alias, apply the changes:

source ~/.bashrc  # or ~/.zshrc

4. Configure Docker Compose for Podman

To make Docker Compose use Podman, and point to the DOCKER_HOST environment variable to Podman’s socket. You can do this on the fly or by setting it permanently in your shell configuration file:

export DOCKER_HOST=unix:///run/user/$(id -u)/podman/podman.sock

For permanent configuration, add the above line to your ~/.bashrc or ~/.zshrc.

5. Run Docker Compose

Now, you can use Docker Compose as you normally would:

docker-compose up

or if you have not aliased docker to podman, you can explicitly tell Docker Compose to use Podman:

DOCKER_HOST=unix:///run/user/$(id -u)/podman/podman.sock docker-compose up

6. Troubleshooting

If you encounter permissions issues with the Podman socket or other related errors, make sure that your user is in the appropriate group to manage Podman containers, and check that the socket path in DOCKER_HOST is correct.

7. Consider Podman Compose

Podman team has developed podman-compose which is a script to help Podman manage full application lifecycles using docker-compose format. It might be beneficial to use podman-compose if you face any compatibility issues:

pip3 install podman-compose

Then use it similarly to Docker Compose:

podman-compose up

Conclusion

This guide should help you set up a working environment using Podman and Docker Compose on a Linux system. I hope will this your helpful. Thank you for reading the DevopsRoles page!

Step-by-Step Guide to Installing Podman on Rocky Linux

Rocky Linux is a popular choice for businesses and developers who need a stable, secure Linux distribution. It’s especially valuable for containerized applications, which brings us to Podman – an excellent alternative to Docker that doesn’t require root access to run containers. In this comprehensive guide step-by-step Installing Podman, we’ll explore how to install and run Podman on Rocky Linux, covering everything from the initial installation to deploying your first container.

Why Podman?

Podman is an open-source, Linux-native tool designed to develop, manage, and run OCI Containers on your Linux system. Its daemonless architecture increases security and makes it easier to manage containers without the need for root privileges. This security feature is one speculated reason why Red Hat shifted its container tool support from Docker to Podman.

What You Need

  • A running instance of Rocky Linux
  • A user account with sudo privileges

Checking for installing Podman

Podman is typically installed by default on Rocky Linux. To verify, you can open a terminal and type the following command:

podman -v

If Podman is installed, you should see an output like:

podman version 4.6.1

If you receive an error indicating the command is not found, you will need to install Podman by executing:

sudo dnf install podman -y

Step 1: Pulling an Image

With Podman installed, your first task is to pull a container image from a registry. We will use the Nginx image as an example. To find the Nginx image, use:

podman search nginx

You’ll see various entries, including official builds and other versions hosted on different registries. To pull the latest official Nginx image from Docker’s registry, run:

podman pull nginx:latest

After selecting the image from the list (using arrow keys if needed), the image will download, ending with a confirmation of the image ID.

Step 2: Deploying a Container

Now that you have your image, it’s time to run a container using it. Execute the following command to deploy an Nginx container:

podman run --name podman-nginx -p 8080:80 -d nginx

Here’s what each part of the command means:

  • podman run: Command to create and start a container.
  • --name podman-nginx: Names the container.
  • -p 8080:80: Maps port 80 in the container to port 8080 on the host.
  • -d: Runs the container in detached mode.
  • nginx: The image used to create the container.

You can verify that your container is running by listing all active containers:

podman ps -a

Interacting with Your Container

To interact with the running Nginx container, use:

podman exec -it podman-nginx /bin/bash

This command opens a bash shell inside the container. You can now manage files and services inside the container as if you were logged into a regular Linux server.

Stopping and Removing Containers

When you’re done, you can stop the container using:

podman stop [ID]

And remove it with:

podman rm [ID]

Replace [ID] with the first few characters of your container’s ID.

An Easier Method: Using Cockpit

Rocky Linux offers Cockpit, a web-based management interface that includes support for managing Podman containers. To use it, start the Cockpit service:

sudo systemctl enable --now cockpit.socket

Then, open a web browser and navigate to https://[SERVER]:9090, replacing [SERVER] with your server’s IP address. Log in with your sudo user credentials. You’ll see an interface where you can manage Podman containers, including starting, stopping, and inspecting containers.

Conclusion

Congratulations! You’ve installed Podman on Rocky Linux and deployed your first container. With these skills, you can now begin using Rocky Linux to host containers in a secure, efficient environment. Podman’s integration into Rocky Linux, along with tools like Cockpit, makes it a powerful platform for developing and deploying containerized applications. Thank you for reading the DevopsRoles page!