Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Docker for Windows: The requested resource is in use error when mem_limit is set

The problem

Every so often I stumble upon a Windows container which refuses to run with mem_limit set with the following exception:

Error response from daemon: hcsshim::CreateComputeSystem {container_guid}: The requested resource is in use.

Interestingly, it runs just fine, if I omit the mem_limit setting. The value of mem_limit can be anything and it can affect any container, even those that used to work just fine.

My setup

OS: Windows 10 Pro 20H2, but I've been having this problem on pretty much all the versions of Windows 10 I had. Docker version: 20.10.5, build 55c4c88 RAM: 64 GB

How to reproduce the problem

I don't know, but it seems that restoring Docker to factory defaults helps. (it does seem to help only if your data-root is the default one, which is not the case for me.)

like image 595
VadimG Avatar asked Mar 01 '23 15:03

VadimG


1 Answers

Every single post I came across ended with the author doing a factory reset or docker zap, but in my case I couldn't afford it -- I had way too many Windows images to lose, and if you've done any docker work around Windows container, you know how painful it is to pull new Windows images.

I have managed to find what I believe is a solution to the problem. Here's how I ended up solving it (so far I've not had a single case in which it wouldn't have worked):

  1. Check if the ports used by the container aren't being used by something else,
  2. Check the volumes mounted into the images: the folders you map must exist and docker must have read-write access to them.
  3. Re-pull all the container image. And if it's your own image, re-pull all the base images and rebuild the image.

I hope the above helps anyone who reads this as much as it does help me.

UPD:

It turns out that pulling the base image does not always help for some reason. In this case you may want to try restarting the Hyper-V Host Compute Service (vmcompute).

like image 60
VadimG Avatar answered Mar 05 '23 16:03

VadimG