added readme

This commit is contained in:
= 2022-11-04 09:59:12 +01:00
parent 947767bdc9
commit d8deb6778e

75
podman/README.md Normal file
View File

@ -0,0 +1,75 @@
# podman and container state
Will install the following packages:
* podman
It will set `linger` for the user running the podman containers (default user: root) and create user systemd units for that user, create systemd unit files as user and start them.
Each container must have its own state file, named `<container-name>.sls` and placed in the podman state folder.
podman pillars:
```
podman:
user: <podman user, default root if not defined>
```
container pillars:
```
containers:
<container name>:
image: <path to container image>
tag: <image tag>
volumes:
<volume name>: <mount path>
env:
<environment varable name>: <value>
ports:
- host: <port number>
- container: <port number>
```
## Example
```
podman:
user: foo
containers:
mariadb:
image: docker.io/library/mariadb
tag: latest
volumes:
data: /var/lib/mysql
env:
MYSQL_ROOT_PASSWORD: verysecretpassword
ports:
- host: 3306
container: 3306
- host: 1234
container 4321
protocol: udp
```
### Steps done in above example:
* install podman
* set linger for user foo
* Create a firewald service for `mariadb` and add port `3306/tcp` and `1234/ucp`
* add `mariadb` firewalld service to `pillar.container.zone` (default is public)
* Create container controle script `/home/foo/bin/mariadb.sh`
* create podman volume named `mariadb-data`
* Create a podman container named `mariadb`
* Create systemd unit file for container `mariadb` named `mariadb.service`
* start mariadb service
Each container will have a script wrapper for the service and container.
```
Usage mariadb.sh [options..]
-h,-?, --help Show help and exit
-p, --pull pull container image (mariadb:latest)
-v, --volumes create container volumes
-c, --create create mariadb containers
-s, --start start and enables mariadb container
-S, --stop stop mariadb container
-i, --is-running check to see if container service is running
-u, --check-update check if there are image updates avaiable
--update perform image update if it exists
-g, --generate-systemd generate user systemd service unit file
```