Podman is a daemon-less container engine for developing, managing, and running Open Container Initiative (OCI)-compliant containers and container images. It follows industry standards to provide a robust container-management tool that you can also integrate into Kubernetes and other services as needed.
Better still, Podman is Docker-compatible to the point that you can simply alias the Docker command-line interface (CLI) to the Podman command (alias docker=podman
) and change nothing about your workflow or scripts.
This article starts a series about Podman's features, and I'll reuse the setup below in my future articles. In this one, I'll show you how to get started with containers in a fast and repeatable way through the familiar interface of shell scripting.
Setting things up
Because containers are designed to be disposable or ephemeral, it's important to make your containers repeatable. You want to be able to create a container with the environment you need, destroy it when you no longer need it, and know that you can recreate it later with no added effort. Many users look to the Dockerfile format for this, but a good shell script can be just as useful and has the added benefit of greater flexibility. For example:
$ podman --version
podman version 3.0.2-dev
I have already pulled some container images that I will use to run my containers and pods:
$ podman image ls
REPOSITORY TAG IMAGE ID CREATED SIZE
docker.io/library/wordpress latest 054741915cf1 2 days ago 629 MB
docker.io/library/mysql latest bbf6571db497 3 days ago 521 MB
docker.io/library/httpd latest ea28e1b82f31 3 days ago 148 MB
Scripting containers
I have created two simple scripts to deploy my pod and containers. The first creates a pod with a WordPress container:
#!/bin/bash
# create_blog.sh
set -e #exit on most errors
podman pod create --name blog --infra --publish 8080:80 --network bridge
podman run --pod blog --name mysql -e MYSQL_USER=alexon \
-e MYSQL_PASSWORD=123456 -e MYSQL_DATABASE=wpdb \
-e MYSQL_ROOT_PASSWORD=567890 \
--volume /var/local/mysql:/var/lib/mysql:Z \
-d docker.io/library/mysql
podman run --pod blog --name wordpress -e WORDPRESS_DB_HOST=mysql \
-e WORDPRESS_DB_USER=alexon \
-e WORDPRESS_DB_PASSWORD=123456 \
-e WORDPRESS_DB_NAME=wpdb \
-d docker.io/library/wordpress
The next one starts a web server:
#!/bin/bash
# create_web.sh
podman run --name=httpd -p 8081:80 \
--volume /var/local/httpd:/usr/local/apache2/htdocs:Z \
-d docker.io/library/httpd
I'm referencing external mount points for my containers. Here are the contents of these directories:
$ ls -R /var/local/
/var/local/:
httpd mysql
/var/local/httpd:
index.html
/var/local/mysql:
$ cat /var/local/httpd/index.html
<html>
<header>
<title>Enable SysAdmin</title>
</header>
<body>
<p>Hello World!</p>
</body>
</html>
[ You might also be interested in reading How Podman runs on Macs and other container FAQs. ]
Deploying the containers
With the proper configuration in place, I deploy my containers using my scripts:
$ ./create_web.sh
7c4c01d99cccf70a0c42ebdba458afb8be6d1563de3a91c99519213a4d8654af
$ ./create_blog.sh
a061ffe41575ca69ec48a2151220ba9462ed87c3c54d0f35bfa74507b56ff902
5bd37169ce0de342e5b86f7d8ba057b06cddb05b6d73520fca8c5ca69f1fe353
055fc7959f58921ef11119b44b1d250558272b523765e639a5e5c3aa2ad3d2a0
Just to make sure my applications are running correctly inside my recently deployed containers, I access them through a web browser. First, the basic httpd
container app:
Then the basic WordPress container app:
Both are up and running properly.
Building familiarity into your container workflow
Containers don't have to be strange concepts to a Linux user. Integrated into the operating system, they're powerful tools for the busy sysadmin. In my next article, I'll demonstrate how Podman provides tools to see information about running pods.
Until then, you can learn more about Podman from 10 Podman guides to do more with containers in 2022, Top 10 container guides for sysadmins, and of course, Podman.io.
Über den Autor
Alexon has been working as a Senior Technical Account Manager at Red Hat since 2018, working in the Customer Success organization focusing on Infrastructure and Management, Integration and Automation, Cloud Computing, and Storage Solutions. He is a part of the TAM Practices LATAM team based in São Paulo, Brazil, where his job is partnering with, advocating, trust-advising, and supporting customers in their success goals while making use of the complete portfolio. He also contributes to produce and enhance documentation, knowledge-base articles, blog posts, presentations, webinars, and workshops. He is a member of numerous communities in addition to the Sudoers, like Red Hat Academy and Red Hat Accelerators. When he’s not at work, he enjoys spending quality time with his family (wife, daughter, and cat) and participating in several volunteer jobs.
Nach Thema durchsuchen
Automatisierung
Das Neueste zum Thema IT-Automatisierung für Technologien, Teams und Umgebungen
Künstliche Intelligenz
Erfahren Sie das Neueste von den Plattformen, die es Kunden ermöglichen, KI-Workloads beliebig auszuführen
Open Hybrid Cloud
Erfahren Sie, wie wir eine flexiblere Zukunft mit Hybrid Clouds schaffen.
Sicherheit
Erfahren Sie, wie wir Risiken in verschiedenen Umgebungen und Technologien reduzieren
Edge Computing
Erfahren Sie das Neueste von den Plattformen, die die Operations am Edge vereinfachen
Infrastruktur
Erfahren Sie das Neueste von der weltweit führenden Linux-Plattform für Unternehmen
Anwendungen
Entdecken Sie unsere Lösungen für komplexe Herausforderungen bei Anwendungen
Original Shows
Interessantes von den Experten, die die Technologien in Unternehmen mitgestalten
Produkte
- Red Hat Enterprise Linux
- Red Hat OpenShift
- Red Hat Ansible Automation Platform
- Cloud-Services
- Alle Produkte anzeigen
Tools
- Training & Zertifizierung
- Eigenes Konto
- Kundensupport
- Für Entwickler
- Partner finden
- Red Hat Ecosystem Catalog
- Mehrwert von Red Hat berechnen
- Dokumentation
Testen, kaufen und verkaufen
Kommunizieren
Über Red Hat
Als weltweit größter Anbieter von Open-Source-Software-Lösungen für Unternehmen stellen wir Linux-, Cloud-, Container- und Kubernetes-Technologien bereit. Wir bieten robuste Lösungen, die es Unternehmen erleichtern, plattform- und umgebungsübergreifend zu arbeiten – vom Rechenzentrum bis zum Netzwerkrand.
Wählen Sie eine Sprache
Red Hat legal and privacy links
- Über Red Hat
- Jobs bei Red Hat
- Veranstaltungen
- Standorte
- Red Hat kontaktieren
- Red Hat Blog
- Diversität, Gleichberechtigung und Inklusion
- Cool Stuff Store
- Red Hat Summit