Showing posts with label Linux. Show all posts
Showing posts with label Linux. Show all posts

Podman container as systemd service with quadlet

Since podman generate systemd is depracated, here is a way to create container service. Example on Prometheus. Setup:

$ podman --version
podman version 4.9.3
$ cat /etc/os-release | head -n1
PRETTY_NAME="Ubuntu 24.04.1 LTS"

Create system user only to run containers:

$ adduser --system --disabled-login podman
$ cat /etc/passwd | grep podman
podman:x:110:65534::/home/podman:/usr/sbin/nologin

Decide where to make persistent volumes for container. I chose /home/podman/.

$ mkdir -p /home/podman/prometheus/data
$ mkdir -p /home/podman/prometheus/config
$ chown -R podman:nogroup /home/podman/*
$ tree /home/podman/
/home/podman/
└── prometheus
    ├── config
    │   └── prometheus.yml
    └── data

Create .container file in one of locations as stated in documentation podman-systemd.unit. I created in /etc/containers/systemd/.

$ cat /etc/containers/systemd/prometheus.container
[Unit]
Description=Prometheus container

[Container]
Image=docker.io/prom/prometheus #latest image
ContainerName=prometheus
Volume=/home/podman/prometheus/data:/prometheus
Volume=/home/podman/prometheus/config:/etc/prometheus #containing prometheus.yml config
PublishPort=9090:9090
User=110 # UID of user podman I created

[Service]
# Restart service when failed
Restart=always

[Install]
WantedBy=multi-user.target
DefaultInstance=100
$
$ systemctl daemon-reload
$ service prometheus start
Share:

'Too many open files' in log file - resolution

Too many open files and service crashes. Edit serivce:

systemctl edit [service_name]

Add in file in correct section:

[Service]
LimitNOFILE=65536
LimitSTACK=infinity
LimitNPROC=16384
TasksMax=8192

Reload systemctl:

systemctl daemon-reload

Restart service:

systemctl restart [service_name]
Share:

Add disk to lvm

List of commands to add new disk to lvm and add storage to /.

Format drive fdisk /dev/sdb:

[root@centos7 ~]# fdisk /dev/sdb
Welcome to fdisk (util-linux 2.23.2).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Device does not contain a recognized partition table
Building a new DOS disklabel with disk identifier 0x4507ff75.
Command (m for help): n
Partition type:
   p   primary (0 primary, 0 extended, 4 free)
   e   extended
Select (default p): 
Using default response p
Partition number (1-4, default 1): 
First sector (2048-16777215, default 2048): 
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-16777215, default 16777215): 
Using default value 16777215
Partition 1 of type Linux and of size 8 GiB is set
Command (m for help): t
Selected partition 1
Hex code (type L to list all codes): 8e
Changed type of partition 'Linux' to 'Linux LVM'
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.

Create pv on sdb1

pvcreate /dev/sdb1

Add to vg

vgextend name_of_vg /dev/sdb1

lvresize -l +100%free path_of_lv

find out file system on partition 

grep root /etc/mtab

case:

    xfs: 

xfs_growfs /dev/mapper/...

    ext4:

 resize2fs /dev/mapper/...

done

Share:

3CX manual install on Debian 10 (Buster) - Unsupported by 3CX

Fresh Debian 10 install. This method is unsupported by 3CX for some reason.

apt install gnupg 

wget -O- http://downloads-global.3cx.com/downloads/3cxpbx/public.key | apt-key add - 

echo "deb http://downloads-global.3cx.com/downloads/debian buster main" | tee /etc/apt/sources.list.d/3cxpbx.list

apt update

sudo apt update

sudo apt install -y net-tools dphys-swapfile

sudo apt -y install 3cxpbx 

Share: