+
remix
tcl
+
ocaml
<-
+
โŠ‚
!==
+
+
lit
+
puppet
+
sinatra
phoenix
+
+
+
+
linux
=
hapi
gcp
+
+
+
scheme
+
+
jquery
graphdb
+
+
+
bbedit
+
+
fauna
โˆˆ
ray
rails
+
+
+
soap
+
oauth
+
+
+
mysql
+
vercel
+
+
kotlin
+
remix
+
+
julia
json
alpine
+
gin
linux
argocd
+
kotlin
+
nuxt
+
+
+
+
bsd
jenkins
lisp
nim
โˆ‰
linux
gitlab
+
clj
+
+
+
Back to Blog
๐Ÿณ Running Containers with Podman: Simple Guide
Alpine Linux Podman Containers

๐Ÿณ Running Containers with Podman: Simple Guide

Published Jun 4, 2025

Easy tutorial for running containers using Podman in Alpine Linux. Perfect for beginners with step-by-step instructions and clear examples.

12 min read
0 views
Table of Contents

๐Ÿณ Running Containers with Podman: Simple Guide

Want to run containers without Docker? This guide shows you how with Podman! ๐Ÿ˜Š Weโ€™ll learn how to pull images, run containers, and manage them easily. Itโ€™s rootless and secure! ๐Ÿ’ป

๐Ÿค” What is Podman?

Podman (Pod Manager) is a container engine that lets you run containers without a daemon. Itโ€™s like Docker but safer and doesnโ€™t need root access!

Podman helps with:

  • ๐Ÿ“ Running containers without root privileges
  • ๐Ÿ”ง Managing container images and pods
  • ๐Ÿ’ก Building custom container images easily

๐ŸŽฏ What You Need

Before we start, you need:

  • โœ… Alpine Linux system with basic setup
  • โœ… Regular user account (no root required!)
  • โœ… Internet connection for downloading images
  • โœ… Access to the command line interface

๐Ÿ“‹ Step 1: Install Podman

Install from Alpine Packages

Letโ€™s install Podman on your Alpine system! ๐Ÿ˜Š

What weโ€™re doing: Installing Podman and its dependencies.

# Update package list
apk update

# Install Podman
apk add podman

# Install additional container tools
apk add buildah skopeo

# Check Podman version
podman --version

# Check Podman system info
podman system info

What this does: ๐Ÿ“– Installs Podman container engine and related tools.

Example output:

podman version 4.7.2
โœ… Podman installed successfully

What this means: Podman is ready to run containers! โœ…

๐Ÿ’ก Important Tips

Tip: Podman works as regular user - no sudo needed! ๐Ÿ’ก

Warning: First run might take time to set up namespaces! โš ๏ธ

๐Ÿ› ๏ธ Step 2: Run Your First Container

Pull and Run Basic Container

Time to run your first container! ๐Ÿ˜Š

What weโ€™re doing: Downloading and running a simple container image.

# Pull a basic Alpine image
podman pull alpine:latest

# List downloaded images
podman images

# Run interactive Alpine container
podman run -it alpine:latest /bin/sh

# Inside container - test commands
cat /etc/os-release
echo "Hello from container!"
exit

# Run container with command and auto-remove
podman run --rm alpine:latest echo "Container says hello!"

Code explanation:

  • podman pull downloads container images
  • podman run -it runs interactive containers
  • --rm automatically removes container after exit

Expected Output:

Alpine Linux v3.18
Hello from container!
Container says hello!
โœ… Container ran successfully

What this means: Youโ€™re now running containers with Podman! ๐ŸŽ‰

๐Ÿ”ง Step 3: Container Management

List and Control Containers

Letโ€™s learn how to manage running containers! This is powerful! ๐ŸŽฏ

What weโ€™re doing: Running containers in background and managing them.

# Run container in background (detached)
podman run -d --name my-web-server -p 8080:80 nginx:alpine

# List running containers
podman ps

# List all containers (including stopped)
podman ps -a

# Check container logs
podman logs my-web-server

# Execute command in running container
podman exec -it my-web-server /bin/sh
ls /usr/share/nginx/html
exit

# Stop container
podman stop my-web-server

# Start stopped container
podman start my-web-server

# Remove container
podman rm my-web-server

Code explanation:

  • -d runs container in background
  • --name gives container a friendly name
  • -p maps ports (host:container)
  • exec runs commands inside running containers

Good output looks like:

CONTAINER ID  IMAGE         COMMAND               CREATED         STATUS         PORTS                   NAMES
a1b2c3d4e5f6  nginx:alpine  nginx -g daemon off   10 seconds ago  Up 8 seconds  0.0.0.0:8080->80/tcp    my-web-server
โœ… Container management ready

๐Ÿ› ๏ธ Step 4: Working with Images

Build Custom Images

Letโ€™s create our own container images! Hereโ€™s how:

What weโ€™re doing: Building custom container images using Dockerfile.

# Create project directory
mkdir ~/my-container-app
cd ~/my-container-app

# Create simple HTML file
cat > index.html << 'EOF'
<!DOCTYPE html>
<html>
<head>
    <title>My Podman App</title>
</head>
<body>
    <h1>Hello from Podman Container!</h1>
    <p>This container was built with Podman ๐Ÿณ</p>
</body>
</html>
EOF

# Create Dockerfile
cat > Dockerfile << 'EOF'
FROM nginx:alpine

# Copy our HTML file
COPY index.html /usr/share/nginx/html/

# Expose port 80
EXPOSE 80

# Start nginx
CMD ["nginx", "-g", "daemon off;"]
EOF

# Build custom image
podman build -t my-web-app:latest .

# List images to see our new one
podman images

# Run our custom container
podman run -d --name my-app -p 8080:80 my-web-app:latest

# Test our application
curl http://localhost:8080

# Clean up
podman stop my-app
podman rm my-app

What this does: Creates custom container images from scratch! ๐ŸŒŸ

Working with Container Registries

Letโ€™s learn how to share container images:

What weโ€™re doing: Pushing and pulling images from registries.

# Tag image for registry
podman tag my-web-app:latest localhost:5000/my-web-app:latest

# Save image to file
podman save -o my-app.tar my-web-app:latest

# Load image from file
podman load -i my-app.tar

# Export running container as image
podman run -d --name temp-container alpine:latest
podman commit temp-container my-custom-alpine:latest
podman rm -f temp-container

# Search for images in registries
podman search nginx

# Show image details
podman inspect my-web-app:latest

Code explanation:

  • tag creates new names for images
  • save/load exports/imports image files
  • commit creates images from containers
  • search finds images in registries

๐Ÿ“Š Quick Summary Table

CommandPurposeExample
๐Ÿ”ง podman runStart containersโœ… podman run -it alpine sh
๐Ÿ› ๏ธ podman psList containersโœ… podman ps -a
๐ŸŽฏ podman imagesList imagesโœ… podman images
๐ŸŒ podman buildBuild imagesโœ… podman build -t myapp .

๐ŸŽฎ Practice Time!

Letโ€™s practice what you learned! Try these simple examples:

Example 1: Database Container ๐ŸŸข

What weโ€™re doing: Running a database container for development.

# Run PostgreSQL database
podman run -d \
  --name my-postgres \
  -e POSTGRES_PASSWORD=mypassword \
  -e POSTGRES_DB=testdb \
  -p 5432:5432 \
  postgres:alpine

# Check if database is running
podman ps

# Connect to database
podman exec -it my-postgres psql -U postgres -d testdb

# Inside database
\l
CREATE TABLE users (id serial, name text);
INSERT INTO users (name) VALUES ('Alice'), ('Bob');
SELECT * FROM users;
\q

# Stop and remove database
podman stop my-postgres
podman rm my-postgres

What this does: Runs a complete database in a container! ๐ŸŒŸ

Example 2: Multi-Container Application ๐ŸŸก

What weโ€™re doing: Running multiple connected containers together.

# Create a pod (group of containers)
podman pod create --name my-app-pod -p 8080:80 -p 3306:3306

# Run database in pod
podman run -d \
  --pod my-app-pod \
  --name app-database \
  -e MYSQL_ROOT_PASSWORD=rootpass \
  -e MYSQL_DATABASE=appdb \
  mysql:8.0

# Run web application in same pod
podman run -d \
  --pod my-app-pod \
  --name app-web \
  nginx:alpine

# List pod contents
podman pod ps
podman ps --pod

# Stop entire pod
podman pod stop my-app-pod

# Remove pod and all containers
podman pod rm my-app-pod

What this does: Creates grouped containers that work together! ๐Ÿ“š

๐Ÿšจ Fix Common Problems

Problem 1: Container wonโ€™t start โŒ

What happened: Container exits immediately with error. How to fix it: Check container logs and image!

# Check container logs
podman logs container-name

# Run container interactively for debugging
podman run -it --entrypoint /bin/sh image-name

# Check image details
podman inspect image-name

# Try different command
podman run image-name /bin/ls -la

Problem 2: Port already in use โŒ

What happened: Cannot bind to port because itโ€™s busy. How to fix it: Check whatโ€™s using the port!

# Find what's using port 8080
ss -tulpn | grep 8080

# Use different port
podman run -p 8081:80 nginx:alpine

# Stop container using port
podman stop $(podman ps -q --filter "publish=8080")

Problem 3: Permission denied errors โŒ

What happened: Container cannot access files or directories. How to fix it: Check file permissions and user mapping!

# Run container with your user ID
podman run --user $(id -u):$(id -g) alpine:latest id

# Mount directory with proper permissions
podman run -v ~/data:/data:Z alpine:latest ls -la /data

# Fix SELinux context (if needed)
podman run -v ~/data:/data:z alpine:latest touch /data/test

Donโ€™t worry! These problems happen to everyone. Youโ€™re doing great! ๐Ÿ’ช

๐Ÿ’ก Simple Tips

  1. Use rootless containers ๐Ÿ“… - Safer than running as root
  2. Name your containers ๐ŸŒฑ - Easy to manage with meaningful names
  3. Clean up regularly ๐Ÿค - Remove unused containers and images
  4. Use pods for multi-container apps ๐Ÿ’ช - Better organization

โœ… Check Everything Works

Letโ€™s make sure everything is working:

# Test basic container functionality
podman run --rm alpine:latest echo "Podman test successful!"

# Check images are available
podman images

# Test building images
echo "FROM alpine:latest" | podman build -t test-build -

# Test pod functionality
podman pod create --name test-pod
podman pod rm test-pod

# Check system status
podman system info | grep -E "(version|rootless)"

echo "Podman is working perfectly! โœ…"

Good output:

Podman test successful!
REPOSITORY    TAG      IMAGE ID     CREATED     SIZE
alpine        latest   c059bfaa849c 2 days ago  5.59 MB
test-build    latest   a1b2c3d4e5f6 now        5.59 MB
version: 4.7.2
rootless: true
Podman is working perfectly! โœ…

๐Ÿ† What You Learned

Great job! Now you can:

  • โœ… Install and configure Podman on Alpine Linux
  • โœ… Run and manage containers without root access
  • โœ… Build custom container images with Dockerfile
  • โœ… Use pods to group related containers together!

๐ŸŽฏ Whatโ€™s Next?

Now you can try:

  • ๐Ÿ“š Learning about container networking and volumes
  • ๐Ÿ› ๏ธ Building CI/CD pipelines with Podman
  • ๐Ÿค Setting up container registries and image sharing
  • ๐ŸŒŸ Creating microservices with container orchestration!

Remember: Every container expert was once a beginner. Youโ€™re doing amazing! ๐ŸŽ‰

Keep practicing and youโ€™ll become an expert too! ๐Ÿ’ซ