This repository has been archived on 2023-06-27. You can view files and clone it, but cannot push or open issues or pull requests.
salt-states_old/podman/README.md

76 lines
2.2 KiB
Markdown
Raw Normal View History

2022-11-04 08:59:12 +00:00
# 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
```