Nexus OSS container as systemd service keeps restarting

Hi,

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:

[Unit]
Description=Nexus container
After=local-fs.target

[Container]
ContainerName=nexus
Environment=INSTALL4J_ADD_VM_PARAMS="-Xms2703M -Xmx2703M -XX:MaxDirectMemorySize=2703M -Djava.util.prefs.userRoot=/nexus-data/javaprefs"
Image=docker://docker.io/sonatype/nexus3
PublishPort=8081:8081
User=200
Volume=/var/lib/kontti/data/nexus:/nexus-data:Z

[Service]
TimeoutStartSec=900

[Install]
WantedBy=multi-user.target default.target

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' \
docker://docker.io/sonatype/nexus3

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 org.sonatype.nexus.extender.NexusBundleTracker - ACTIVATING com.sonatype.nexus.plugins.nexus-ossindex-plugin [3.61.0.02]
2023-10-30 14:15:24,270+0000 INFO  [FelixStartLevel] *SYSTEM org.sonatype.nexus.extender.NexusBundleTracker - ACTIVATED com.sonatype.nexus.plugins.nexus-ossindex-plugin [3.61.0.02]
2023-10-30 14:15:24,321+0000 INFO  [FelixStartLevel] *SYSTEM org.sonatype.nexus.extender.NexusContextListener - Uptime: 24 seconds and 805 milliseconds (nexus-oss-edition/3.61.0.02)
2023-10-30 14:15:24,322+0000 INFO  [FelixStartLevel] *SYSTEM org.sonatype.nexus.extender.NexusLifecycleManager - Shutting down
2023-10-30 14:15:24,323+0000 INFO  [FelixStartLevel] *SYSTEM org.sonatype.nexus.extender.NexusLifecycleManager - 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