'Windows Container Access is denied. (0x5). using Powershell. But still accessible on Docker Desktop CLI tool

I am running a docker-compose up and spinning up my Windows containers. Then I want to attach to a container.

I tried docker attach <container id>, but it crashes the entire docker container for whatever reason. Then, I tried docker exec <container name> C:\ to login to C:\.

This gives me the error: container 8504af497601933a0c2e7126e00665da77b9fa71db03c37ce30eb5fa94ee2ee6 encountered an error during hcsshim::System::CreateProcess: failure in a Windows system call: Access is denied. (0x5)

On my Windows 10 machine, I can still access the CLI for the containers using Docker Desktop (even though its inaccessible through CLI), however, I need to use CLI to access it on my Windows Server 2019 machine. I've tried C:\, C:\Users, etc , and they all give the same error.



Solution 1:[1]

I was running this erroneous command:

&$Env:ProgramFiles\Docker\docker run hello-world:nanoserver .

Which resulted in:

docker: Error response from daemon: container encountered an error during hcsshim::System::CreateProcess: failure in a Windows system call: Access denied. (0x5).

This is due to . after hello-world:nanoserver which specify the shell to use. The error Access denied was coming from inside the container I think.

So try to check if you are specifying a shell which is incorrect.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Gabriel Devillers