Podman » Historie » Version 7
Jeremias Keihsler, 07.10.2021 11:41
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 | |||
74 | h2. compose pod |
||
75 | |||
76 | create @~/compose.user/nextcloud.user/compose.yml@ |
||
77 | |||
78 | <pre><code class="yaml"> |
||
79 | version: '3' |
||
80 | |||
81 | services: |
||
82 | |||
83 | db: |
||
84 | image: mariadb |
||
85 | container_name: nextcloud-mariadb |
||
86 | networks: |
||
87 | - nextcloud_network |
||
88 | volumes: |
||
89 | - db:/opt/nextcloud/mysql |
||
90 | - /etc/localtime:/etc/localtime:ro |
||
91 | environment: |
||
92 | - MYSQL_ROOT_PASSWORD=XXXXX |
||
93 | - MYSQL_PASSWORD=XXXXX |
||
94 | - MYSQL_DATABASE=nextcloud |
||
95 | - MYSQL_USER=nextcloud |
||
96 | restart: unless-stopped |
||
97 | |||
98 | app: |
||
99 | image: nextcloud:latest |
||
100 | container_name: nextcloud-app |
||
101 | ports: |
||
102 | - 9099:80 |
||
103 | networks: |
||
104 | - nextcloud_network |
||
105 | depends_on: |
||
106 | - db |
||
107 | volumes: |
||
108 | - nextcloud:/var/www/html |
||
109 | - ./app/config:/var/www/html/config |
||
110 | - ./app/custom_apps:/var/www/html/custom_apps |
||
111 | - ./app/data:/var/www/html/data |
||
112 | - ./app/themes:/opt/nextcloud/www/html/themes |
||
113 | - /etc/localtime:/etc/localtime:ro |
||
114 | environment: |
||
115 | - VIRTUAL_HOST=ak-i40-cloud.openfab.org |
||
116 | restart: unless-stopped |
||
117 | |||
118 | volumes: |
||
119 | nextcloud: |
||
120 | db: |
||
121 | |||
122 | networks: |
||
123 | nextcloud_network: |
||
124 | </code></pre> |
||
125 | 4 | Jeremias Keihsler | |
126 | <pre><code class="shell"> |
||
127 | podman-compose -f ~/compose.user/nextcloud.user/compose.yml up |
||
128 | </code></pre> |