January 31, 2020

Docker: HNS failed with error

While trying to run a container with a port exposed/published to the host, encountered the following error:

HNS failed with error : The process cannot access the file because it is being used by another process.

Makes it sound like Docker has trouble accessing a file because another process has an exclusive lock...but what is HNS? It stands for Host Networking Service.

It turned out I mistakenly reversed the order of the port numbers. Since my host's port 80 was taken up by IIS already, Docker wasn't able to start the container.

The port command should be:

docker run -p [host port]:[container port] <ImageName>