¡Heytale! ¿Quieres saber sobre Podman?
Podman es un motor de contenedores sin daemon para desarrollar, gestionar y ejecutar contenedores OCI en Linux. ¡A diferencia de Docker, no necesita un daemon corriendo, lo que lo hace más seguro y eficiente! Es compatible con imágenes Docker y se integra con Kubernetes para despliegues en la nube.
Características Chingonas
- Sin daemonio:
- Ejecuta contenedores directo desde tu usuario, sin servicios en segundo plano.
- Rootless:
- Corre contenedores sin root, ¡más seguridad!
- Compatibilidad con docker:
- Comandos similares, fácil migrar.
- Integración con k8s:
- Genera YAMLs para clústeres.
- Gestión de imágenes y contenedores:
- Construye, inspecciona y maneja imágenes OCI.
- Soporte para systemd:
- Ejecuta contenedores con systemd para servicios persistentes.
Ejemplo: contenedor con Systemd
¡Vamos a crear un contenedor de CentOS Stream 10 con systemd habilitado y PostgreSQL instalado! Asegúrate de tener Podman instalado.
# podman con systemd
## iniciar contenedor
podman run -di --name cs10-systemd centos:stream10
## instalar systemd y postgresql
podman exec cs10-systemd dnf -y install systemd postgresql-server sudo
## limpiar
podman exec cs10-systemd dnf clean all
## commitear a imagen
podman commit -s cs10-systemd cs10-systemd
## borrar contenedor
podman rm -f cs10-systemd
## correr con systemd
podman run -dt -p 127.0.0.1:5432:5432 --name=cs10-systemd localhost/cs10-systemd /usr/sbin/init
## configurar postgresql
podman exec cs10-systemd postgresql-setup --initdb
## habilitar e iniciar postgresql
podman exec cs10-systemd systemctl enable --now postgresql
## crear usuario y db
podman exec cs10-systemd sudo -u postgres createuser -dRS --no-replication renich
podman exec cs10-systemd sudo -u postgres createdb renich
podman exec cs10-systemd sudo -u postgres psql -c "ALTER USER renich WITH PASSWORD 'MySuperPass';"
## crear pg_hba.conf
cat << EOF > pg_hba.conf
local all all peer
host all renich 127.0.0.1/32 scram-sha-256
host all renich ::1/128 scram-sha-256
EOF
podman cp pg_hba.conf cs10-systemd:/var/lib/pgsql/data/pg_hba.conf
rm -f pg_hba.conf
## verificar
podman exec cs10-systemd systemctl restart postgresql
podman exec cs10-systemd systemctl status postgresql
PGPASSWORD='MySuperPass' psql -h 127.0.0.1 -l
# limpieza
podman rm -f cs10-systemd
podman rmi cs10-systemd
¡Este ejemplo muestra cómo podman facilita contenedores avanzados con systemd y PostgreSQL, perfecto para desarrollo y producción!