I used to build the same systemd image with buildah and tried to execute a simple script and it works fine ; maybe i am missing something :
buildah run -t -v /sys/fs/cgroup:/sys/fs/cgroup:ro onbuild-image-working-container-2 sh -c 'cat /tmp/install.sh'
--> #!/bin/bash
--> echo lol
buildah run -t -v /sys/fs/cgroup:/sys/fs/cgroup:ro onbuild-image-working-container-2 sh -c 'chmod 777 /tmp/install.sh && /tmp/install.sh'
--> lol
OUTPUT :
lol
SINCE your last comment: Using here docker
BUILDAH is meant for building OCI images, so if you are using in parallel podman or docker just use push the image to a local registry using buildah after building systemd-image from Dockerfile and mount /sys/fs/cgroup on /sys/fs/cgroup with read-only options so it wont override your systemd cgroups :
buildah bud --format=docker -f Dockerfile -t onbuild-image <path_to_DockerFile>
docker run -d -p 5000:5000 --restart=always --name registry registry:2
buildah push --tls-verify=false onbuild-image docker://localhost:5000/systemd-centos:latest
docker pull localhost:5000/systemd-centos:latest
ctr1="$(docker run -d -v /sys/fs/cgroup:/sys/fs/cgroup:ro -p 8000:80 localhost:5000/systemd-centos)"
docker exec -it $ctr1 'systemctl'