I've been attempting to containerize a Java application with Docker. When I have the container run this process as a user other than root, CPU usage goes to 100% and stays there. However, with root, it is much more well behaved, sitting around 2%.
# docker run -d -p 8006:8006 -u root --name root app:latest
# docker run -d -p 8007:8006 -u nonroot --name nonroot app:latest
# ps aux | grep java
root 26537 9.2 4.1 174800 115636 ? Sl 10:14 0:02 /opt/app/jvm16/bin/java -Xmx128M -Xms128M […]
nonroot 26808 94.8 6.2 202744 175368 ? Sl 10:15 0:08 /opt/app/jvm16/bin/java -Xmx128M -Xms128M […]
The application functions identically with either root or a non-root user (it's not hung). But if I run this same application on a real (not inside a container) server, the CPU usage is fine for either root or non-root, hinting at a container-related cause.
Nothing (that I could find) on the Docker host lends insight, and java dumps inside the container don't point me to anything.
My question is: what could be an explanation for this?