Podman » Historie » Version 5
Jeremias Keihsler, 07.10.2021 10:36
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 | sudo podman pod create --name=app-example-pod -p 8099:80 |
||
14 | </code></pre> |
||
15 | |||
16 | h3. add container to pod |
||
17 | |||
18 | e.g. wordpress |
||
19 | <pre><code class="shell"> |
||
20 | mkdir /opt/podman.pod |
||
21 | mkdir /opt/podman.pod/app-example |
||
22 | mkdir /opt/podman.pod/app-example/c_db |
||
23 | mkdir /opt/podman.pod/app-example/c_db/var |
||
24 | mkdir /opt/podman.pod/app-example/c_db/var/lib |
||
25 | mkdir /opt/podman.pod/app-example/c_db/var/lib/mysql |
||
26 | mkdir /opt/podman.pod/app-example/c_wp |
||
27 | mkdir /opt/podman.pod/app-example/c_wp/var |
||
28 | mkdir /opt/podman.pod/app-example/c_wp/var/www |
||
29 | mkdir /opt/podman.pod/app-example/c_wp/var/www/html |
||
30 | </code></pre> |
||
31 | |||
32 | |||
33 | <pre><code class="shell"> |
||
34 | sudo podman run -d --restart=always --pod app-example-pod -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 | sudo podman run -d --restart=always --pod=app-example-pod -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 | 1 | Jeremias Keihsler | h2. create container |
39 | |||
40 | see also: |
||
41 | https://www.redhat.com/sysadmin/wordpress-container |
||
42 | https://rancher.com/learning-paths/how-to-build-and-run-your-own-container-images/ |
||
43 | https://docs.podman.io/en/latest/markdown/podman-build.1.html |
||
44 | |||
45 | 2 | Jeremias Keihsler | create @~/container.user/wordpress.user/Dockerfile@ |
46 | 1 | Jeremias Keihsler | |
47 | <pre> |
||
48 | FROM docker.io/rockylinux/rockylinux |
||
49 | MAINTAINER jke <j@keihsler.com> |
||
50 | RUN dnf module enable -y php:7.4 |
||
51 | 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 |
||
52 | RUN systemctl enable mariadb |
||
53 | RUN systemctl enable httpd |
||
54 | RUN systemctl disable systemd-update-utmp.service |
||
55 | ENTRYPOINT ["/sbin/init"] |
||
56 | CMD ["/sbin/init"] |
||
57 | </pre> |
||
58 | |||
59 | <pre><code class="shell"> |
||
60 | cd ~/container.user/wordpress.user/ |
||
61 | podman build -t wordpress_user . |
||
62 | </code></pre> |
||
63 | 3 | Jeremias Keihsler | |
64 | |||
65 | h2. compose pod |
||
66 | |||
67 | create @~/compose.user/nextcloud.user/compose.yml@ |
||
68 | |||
69 | <pre><code class="yaml"> |
||
70 | version: '3' |
||
71 | |||
72 | services: |
||
73 | |||
74 | db: |
||
75 | image: mariadb |
||
76 | container_name: nextcloud-mariadb |
||
77 | networks: |
||
78 | - nextcloud_network |
||
79 | volumes: |
||
80 | - db:/opt/nextcloud/mysql |
||
81 | - /etc/localtime:/etc/localtime:ro |
||
82 | environment: |
||
83 | - MYSQL_ROOT_PASSWORD=XXXXX |
||
84 | - MYSQL_PASSWORD=XXXXX |
||
85 | - MYSQL_DATABASE=nextcloud |
||
86 | - MYSQL_USER=nextcloud |
||
87 | restart: unless-stopped |
||
88 | |||
89 | app: |
||
90 | image: nextcloud:latest |
||
91 | container_name: nextcloud-app |
||
92 | ports: |
||
93 | - 9099:80 |
||
94 | networks: |
||
95 | - nextcloud_network |
||
96 | depends_on: |
||
97 | - db |
||
98 | volumes: |
||
99 | - nextcloud:/var/www/html |
||
100 | - ./app/config:/var/www/html/config |
||
101 | - ./app/custom_apps:/var/www/html/custom_apps |
||
102 | - ./app/data:/var/www/html/data |
||
103 | - ./app/themes:/opt/nextcloud/www/html/themes |
||
104 | - /etc/localtime:/etc/localtime:ro |
||
105 | environment: |
||
106 | - VIRTUAL_HOST=ak-i40-cloud.openfab.org |
||
107 | restart: unless-stopped |
||
108 | |||
109 | volumes: |
||
110 | nextcloud: |
||
111 | db: |
||
112 | |||
113 | networks: |
||
114 | nextcloud_network: |
||
115 | </code></pre> |
||
116 | 4 | Jeremias Keihsler | |
117 | <pre><code class="shell"> |
||
118 | podman-compose -f ~/compose.user/nextcloud.user/compose.yml up |
||
119 | </code></pre> |