Docker Java 8 Container with Heavy CPU Usage
We are currently dockerize a Java 8 Application and we have a really strange behaviour. Outside of docker, the application use less than 10% of cpu but when we run the application into a container we have 100% of CPU usage for the container.
Inside of the container (with
docker exec -it [container-id] top), the jar only use 10% of cpu.
We attempt to use other base docker image like
openjdk but it change nothing.
FROM anapsix/alpine-java:8 ADD . /producer WORKDIR /producer COPY ikb-1.0-SNAPSHOT-producer.jar ikb-1.0-SNAPSHOT-producer.jar COPY resources/ /resources/ CMD ["java", "-jar", "ikb-1.0-SNAPSHOT-producer.jar"]
- Docker version: 1.13.1, build 092cba3
- Docker-compose version: 1.11.2, build dfed245
- Server OS: CentOS
One Solution collect form web for “Docker Java 8 Container with Heavy CPU Usage”
As discussed in our chat, there was a thread in the Java application that was spinning in a tight loop because there was no user input. Stopping that thread caused the CPU to go back to where it belonged.