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.

  • nginx in docker how to disable http redirects to https
  • How to kill used port of docker
  • Re-Installing Boot2Docker fails due to apparent VirtualBox running - how to shut them down?
  • Pass environment variable to docker
  • How to set UIDs for official Docker images?
  • How to maintain sticky session(session persistence) with docker swarm?
  • We attempt to use other base docker image like openjdk but it change nothing.

    Docker File:

    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"]

    We use:

    • Docker version: 1.13.1, build 092cba3
    • Docker-compose version: 1.11.2, build dfed245
    • Server OS: CentOS

  • How to do gracefully shutdown on dotnet with docker?
  • Installing Pillow requirements on debian Jessie
  • Unable to connect to unix:///var/run/docker.sock (Permission denied) from PHP code
  • How to run custom Docker file?
  • Exception occuring when updating database schema in symfony
  • Docker start container with custom command
  • 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.

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.