Podman » Historie » Revision 9
Revision 8 (Jeremias Keihsler, 20.04.2023 10:03) → Revision 9/12 (Jeremias Keihsler, 20.07.2023 08:38)
h1. Podman h2. install <pre><code class="shell"> yum install podman yum install podman-compose </code></pre> h2. create pod <pre><code class="shell"> sudo podman pod create --name=app-example -p 8099:80 </code></pre> h3. add container to pod e.g. wordpress <pre><code class="shell"> sudo mkdir /opt/podman.pod sudo mkdir /opt/podman.pod/app-example sudo mkdir /opt/podman.pod/app-example/c_db sudo mkdir /opt/podman.pod/app-example/c_db/var sudo mkdir /opt/podman.pod/app-example/c_db/var/lib sudo mkdir /opt/podman.pod/app-example/c_db/var/lib/mysql sudo mkdir /opt/podman.pod/app-example/c_wp sudo mkdir /opt/podman.pod/app-example/c_wp/var sudo mkdir /opt/podman.pod/app-example/c_wp/var/www sudo mkdir /opt/podman.pod/app-example/c_wp/var/www/html </code></pre> <pre><code class="shell"> sudo podman run -d --restart=always --pod=app-example -e MYSQL_ROOT_PASSWORD="root" -e MYSQL_DATABASE="wordpress" -e MYSQL_USER="wpuser" -e MYSQL_PASSWORD="password" -v /etc/localtime:/etc/localtime:ro -v /opt/podman.pod/app-example/c_db/var/lib/mysql:/var/lib/mysql:Z --name=app-example-db mariadb sudo podman run -d --restart=always --pod=app-example -e WORDPRESS_DB_NAME="wordpress" -e WORDPRESS_DB_USER="wpuser" -e WORDPRESS_DB_PASSWORD="password" -e WORDPRESS_DB_HOST="127.0.0.1" -v /etc/localtime:/etc/localtime:ro -v /opt/podman.pod/app-example/c_wp/var/www/html:/var/www/html:Z --name app-example-wp wordpress </code></pre> h2. create systemd-unit files <pre><code class="shell"> cd /opt/podman.pod/app-example sudo podman generate systemd --files --name app-example sudo cp pod-*.service /etc/systemd/system/. sudo cp container-*.service /etc/systemd/system/. </code></pre> h2. create container see also: https://www.redhat.com/sysadmin/wordpress-container https://rancher.com/learning-paths/how-to-build-and-run-your-own-container-images/ https://docs.podman.io/en/latest/markdown/podman-build.1.html create @~/container.user/wordpress.user/Dockerfile@ <pre> FROM docker.io/rockylinux/rockylinux MAINTAINER jke <j@keihsler.com> RUN dnf module enable -y php:7.4 RUN yum install -y mariadb-server mariadb php php-apcu php-intl php-mbstring php-xml php-json php-mysqlnd crontabs cronie iputils net-tools;yum clean all RUN systemctl enable mariadb RUN systemctl enable httpd RUN systemctl disable systemd-update-utmp.service ENTRYPOINT ["/sbin/init"] CMD ["/sbin/init"] </pre> <pre><code class="shell"> cd ~/container.user/wordpress.user/ podman build -t wordpress_user . </code></pre> h2. compose pod create @~/compose.user/nextcloud.user/compose.yml@ <pre><code class="yaml"> version: '3' services: db: image: mariadb container_name: nextcloud-mariadb networks: - nextcloud_network volumes: - db:/opt/nextcloud/mysql - /etc/localtime:/etc/localtime:ro environment: - MYSQL_ROOT_PASSWORD=XXXXX - MYSQL_PASSWORD=XXXXX - MYSQL_DATABASE=nextcloud - MYSQL_USER=nextcloud restart: unless-stopped app: image: nextcloud:latest container_name: nextcloud-app ports: - 9099:80 networks: - nextcloud_network depends_on: - db volumes: - nextcloud:/var/www/html - ./app/config:/var/www/html/config - ./app/custom_apps:/var/www/html/custom_apps - ./app/data:/var/www/html/data - ./app/themes:/opt/nextcloud/www/html/themes - /etc/localtime:/etc/localtime:ro environment: - VIRTUAL_HOST=ak-i40-cloud.openfab.org restart: unless-stopped volumes: nextcloud: db: networks: nextcloud_network: </code></pre> <pre><code class="shell"> podman-compose -f ~/compose.user/nextcloud.user/compose.yml up </code></pre> h2. shell-access to inside container <pre><code class="shell"> podman exec -it -u root nc_example.com-nc /bin/sh </code></pre> h2. administration h3. list (dangling) images <pre><code class="shell"> podman images podman images -f dangling=true </code></pre> h3. remove dangling images best is to make sure that all containers needed are up and running before removing dangling containers <pre><code class="shell"> podman system prune </code></pre>