Podman » Historie » Version 10
Jeremias Keihsler, 05.12.2024 23:57
1 | 1 | Jeremias Keihsler | h1. Podman |
---|---|---|---|
2 | |||
3 | h2. install |
||
4 | |||
5 | <pre><code class="shell"> |
||
6 | yum install podman |
||
7 | yum install podman-compose |
||
8 | </code></pre> |
||
9 | |||
10 | 5 | Jeremias Keihsler | h2. create pod |
11 | |||
12 | <pre><code class="shell"> |
||
13 | 6 | Jeremias Keihsler | sudo podman pod create --name=app-example -p 8099:80 |
14 | 5 | Jeremias Keihsler | </code></pre> |
15 | |||
16 | h3. add container to pod |
||
17 | |||
18 | e.g. wordpress |
||
19 | <pre><code class="shell"> |
||
20 | 6 | Jeremias Keihsler | sudo mkdir /opt/podman.pod |
21 | sudo mkdir /opt/podman.pod/app-example |
||
22 | sudo mkdir /opt/podman.pod/app-example/c_db |
||
23 | sudo mkdir /opt/podman.pod/app-example/c_db/var |
||
24 | sudo mkdir /opt/podman.pod/app-example/c_db/var/lib |
||
25 | sudo mkdir /opt/podman.pod/app-example/c_db/var/lib/mysql |
||
26 | sudo mkdir /opt/podman.pod/app-example/c_wp |
||
27 | sudo mkdir /opt/podman.pod/app-example/c_wp/var |
||
28 | sudo mkdir /opt/podman.pod/app-example/c_wp/var/www |
||
29 | sudo mkdir /opt/podman.pod/app-example/c_wp/var/www/html |
||
30 | 1 | Jeremias Keihsler | </code></pre> |
31 | |||
32 | 5 | Jeremias Keihsler | |
33 | <pre><code class="shell"> |
||
34 | 7 | Jeremias Keihsler | 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 |
35 | 6 | Jeremias Keihsler | 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 |
36 | </code></pre> |
||
37 | |||
38 | h2. create systemd-unit files |
||
39 | |||
40 | <pre><code class="shell"> |
||
41 | cd /opt/podman.pod/app-example |
||
42 | sudo podman generate systemd --files --name app-example |
||
43 | sudo cp pod-*.service /etc/systemd/system/. |
||
44 | sudo cp container-*.service /etc/systemd/system/. |
||
45 | 5 | Jeremias Keihsler | </code></pre> |
46 | |||
47 | 1 | Jeremias Keihsler | h2. create container |
48 | |||
49 | see also: |
||
50 | https://www.redhat.com/sysadmin/wordpress-container |
||
51 | https://rancher.com/learning-paths/how-to-build-and-run-your-own-container-images/ |
||
52 | https://docs.podman.io/en/latest/markdown/podman-build.1.html |
||
53 | |||
54 | 2 | Jeremias Keihsler | create @~/container.user/wordpress.user/Dockerfile@ |
55 | 1 | Jeremias Keihsler | |
56 | <pre> |
||
57 | FROM docker.io/rockylinux/rockylinux |
||
58 | MAINTAINER jke <j@keihsler.com> |
||
59 | RUN dnf module enable -y php:7.4 |
||
60 | 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 |
||
61 | RUN systemctl enable mariadb |
||
62 | RUN systemctl enable httpd |
||
63 | RUN systemctl disable systemd-update-utmp.service |
||
64 | ENTRYPOINT ["/sbin/init"] |
||
65 | CMD ["/sbin/init"] |
||
66 | </pre> |
||
67 | |||
68 | <pre><code class="shell"> |
||
69 | cd ~/container.user/wordpress.user/ |
||
70 | podman build -t wordpress_user . |
||
71 | </code></pre> |
||
72 | 3 | Jeremias Keihsler | |
73 | h2. compose pod |
||
74 | |||
75 | create @~/compose.user/nextcloud.user/compose.yml@ |
||
76 | |||
77 | <pre><code class="yaml"> |
||
78 | version: '3' |
||
79 | |||
80 | services: |
||
81 | |||
82 | db: |
||
83 | image: mariadb |
||
84 | container_name: nextcloud-mariadb |
||
85 | networks: |
||
86 | - nextcloud_network |
||
87 | volumes: |
||
88 | - db:/opt/nextcloud/mysql |
||
89 | - /etc/localtime:/etc/localtime:ro |
||
90 | environment: |
||
91 | - MYSQL_ROOT_PASSWORD=XXXXX |
||
92 | - MYSQL_PASSWORD=XXXXX |
||
93 | - MYSQL_DATABASE=nextcloud |
||
94 | - MYSQL_USER=nextcloud |
||
95 | restart: unless-stopped |
||
96 | |||
97 | app: |
||
98 | image: nextcloud:latest |
||
99 | container_name: nextcloud-app |
||
100 | ports: |
||
101 | - 9099:80 |
||
102 | networks: |
||
103 | - nextcloud_network |
||
104 | depends_on: |
||
105 | - db |
||
106 | volumes: |
||
107 | - nextcloud:/var/www/html |
||
108 | - ./app/config:/var/www/html/config |
||
109 | - ./app/custom_apps:/var/www/html/custom_apps |
||
110 | - ./app/data:/var/www/html/data |
||
111 | - ./app/themes:/opt/nextcloud/www/html/themes |
||
112 | - /etc/localtime:/etc/localtime:ro |
||
113 | environment: |
||
114 | - VIRTUAL_HOST=ak-i40-cloud.openfab.org |
||
115 | restart: unless-stopped |
||
116 | |||
117 | volumes: |
||
118 | nextcloud: |
||
119 | db: |
||
120 | |||
121 | networks: |
||
122 | nextcloud_network: |
||
123 | </code></pre> |
||
124 | 4 | Jeremias Keihsler | |
125 | <pre><code class="shell"> |
||
126 | podman-compose -f ~/compose.user/nextcloud.user/compose.yml up |
||
127 | 1 | Jeremias Keihsler | </code></pre> |
128 | 9 | Jeremias Keihsler | |
129 | h2. shell-access to inside container |
||
130 | |||
131 | <pre><code class="shell"> |
||
132 | podman exec -it -u root nc_example.com-nc /bin/sh |
||
133 | </code></pre> |
||
134 | |||
135 | 8 | Jeremias Keihsler | h2. administration |
136 | |||
137 | h3. list (dangling) images |
||
138 | |||
139 | <pre><code class="shell"> |
||
140 | podman images |
||
141 | podman images -f dangling=true |
||
142 | </code></pre> |
||
143 | |||
144 | h3. remove dangling images |
||
145 | |||
146 | best is to make sure that all containers needed are up and running before removing dangling containers |
||
147 | |||
148 | <pre><code class="shell"> |
||
149 | 1 | Jeremias Keihsler | podman system prune |
150 | 10 | Jeremias Keihsler | </code></pre> |
151 | |||
152 | h2. debuging |
||
153 | |||
154 | <pre><code class="shell"> |
||
155 | podman inspect --format='{{.HostConfig.LogConfig.Path}}' <container-id> |
||
156 | 8 | Jeremias Keihsler | </code></pre> |