Docker doesn't get 100% of the CPU Docker doesn't get 100% of the CPU docker docker

Docker doesn't get 100% of the CPU


Friends, I'm full of shame: the own MacOS Docker desktop client has a setting to enable more or less cores. Don't know if it's something added in the last version, but I didn't notice. By default, it gets two cores instead of four, which seems savvy.

Here's how the screen appears:

enter image description here

By the way, only for the information, on the same machine:

  • Running the .jar takes 64,973 millis
  • Running the Docker image that runs the .jar takes 83,449 millis


The Docker for MacOS and Docker for Windows is where your issues are appearing. Docker doesn't run natively on either of these platforms (yet), so the installers for them spin up a VM running boot2docker. These VM's are controlled by VirtualBox and have limits on the numbers of CPU's assigned to the VM. These limits can be adjusted, so I'd start there (review your VirtualBox configuration for Docker instance, changing this will likely require a restart of the VM).

To get a proper comparison of the overhead from containers, you'd want to run your "outside the container" test inside the VM that's running your Docker host. That, or install Docker on a machine that's running Linux on the physical machine, rather than inside of a VM.


There are a lot of Docker command line flags related to CPU sets and CPU shares. Make sure that those aren't being set, or specified by default. Once your container is running you can find it with docker ps and see the settings with something like docker inspect gloomy_archimedes and look under the HostConfig section for things like CpuShares, CpusetCpus, etc.

It is also possible that your Docker daemon itself has been limited by its init script or systemd unit definition. You can check that by finding your Docker daemon's PID and cat /proc/1199/status. Look for Cpus_allowed: Should be set to ff.

Or if you are running Docker on Windows or Apple OS X, then Docker will need to use a virtual machine. As far as I know, all Docker images are expecting a Linux operating system environment (although I suppose it is possible someone is building Windows images which would need a VM to run on Linux). That virtual machine will have a configured number of CPU cores. You'll need to find a way to adjust that and make sure it is what you want.