mkdir /var/log/journal creates a journal directory
Then refer to the log directory under the host
ll -d /run/log/journal/
chown root:systemd-journal /var/log/journal to modify the group
chmod 2755 /var/log/journal/ modify permissions
systemctl restart systemd-journald restart systemd-journald service
ls /var/log/journal/ Check the folder at this time and you will find that there are files generated
cp -rf /var/log/journal/f874df04639f474cb0a9881041f4f7d4/*.journal /home/wallah/container_logfile/ to copy the file into this folder
chown -R wallah:wallah /home/wallah/ Modify the owner of the path to wallah
Then exit and switch to wallah user
(1004 is redundant, if it appears, it is wrong before)
Pay attention to the file permissions, if it is wrong, cut the root user to modify
After the above preparations are completed, use podman to create a container
podman login registry.domain250.example.com login server
podman search registry.domain250.example.com/ to find the mirror under the server
podman run -d --name logserver -v /home/wallah/container_logfile:/var/log/journal:Z registry.domain250.example.com/rhel8/rsyslog
(-v mounts the host directory to the container directory -Z is the last image of selinux permissions and one of the searched ones)
You can use podman ps to see if the container is started
Stop the container podman stop logserver because it requires the use of systemd to start
mkdir -p .config/systemd/user creates this directory under the current user's home directory
cd .config/systemd/user/
podman generate systemd -n logserver -f Use podman to create a microservice, -f refers to the current directory -n and write the container name
ls view service name
systemctl --user enable --now container-logserver.service Use systemctl to start the service (the last one is the service name seen in the previous step)
systemctl --user status container-logserver.service View service status
loginctl enable-linger Let the user instance start automatically with the system
Can use loginctl show-user wallah to confirm