Nexus OSS container as systemd service keeps restarting


I have a strange problem:

When I try to run Nexus as a systemd service on RHEL 9.2 / Alma 9, Nexus keeps restarting. If I run about the same command line from the shell with podman, Nexus starts up just fine.

This is my systemd container definition:

Description=Nexus container

Environment=INSTALL4J_ADD_VM_PARAMS="-Xms2703M -Xmx2703M -XX:MaxDirectMemorySize=2703M -Djava.util.prefs.userRoot=/nexus-data/javaprefs"



And this is the shell script with which I can run Nexus

podman run --name=nexus --replace --rm --user 200 \
-v /var/lib/kontti/data/nexus:/nexus-data:Z --publish 8081:8081 \
--env 'INSTALL4J_ADD_VM_PARAMS=-Xms2703M -Xmx2703M -XX:MaxDirectMemorySize=2703M -Djava.util.prefs.userRoot=/nexus-data/javaprefs' \

When Nexus started as a service fails, it suddenly just logs Shutting down. Like this:

<A whole bunch of ACTIVATING/ACTIVATED messages clipped out>
2023-10-30 14:15:24,253+0000 INFO  [FelixStartLevel] *SYSTEM - ACTIVATING []
2023-10-30 14:15:24,270+0000 INFO  [FelixStartLevel] *SYSTEM - ACTIVATED []
2023-10-30 14:15:24,321+0000 INFO  [FelixStartLevel] *SYSTEM - Uptime: 24 seconds and 805 milliseconds (nexus-oss-edition/
2023-10-30 14:15:24,322+0000 INFO  [FelixStartLevel] *SYSTEM - Shutting down
2023-10-30 14:15:24,323+0000 INFO  [FelixStartLevel] *SYSTEM - Stop KERNEL

I’ve tried this on two different VMs: a 6-core, 8GB Vagrant box running Alma 9, and a four-core, 16GB RHEL-9.2 VM running on Hyper-V.

Has anyone else tried running Nexus as a systemd podman container in RHEL 9.2?

(A day later:)
I noticed, that if I clean the directory mounted as a volume into the container, then I can successfully start Nexus. Once. After I reboot the VM, I’m back at the starting loop.

[Edit: added a sample of logs + a mention of the running environments]

Now it works.

I had read somewhere that one wouldn’t have to use enable-linger anymore, and thus I hadn’t done that for the user running containers. Once I enabled lingering for the container user, Nexus managed to start up without any start looping.

1 Like