PowerShell Command to automatically switch to Docker Windows container

Anyone using Docker Desktop should be pretty much familiar with the pesky and common error since you forget to switch to Docker windows container while performing "docker-compose up". The error appears in different forms but here is one:

failed to register layer: Error processing tar file(exit status 1): link /Files/Program Files/common files/Microsoft Shared/Ink/en-US/micaut.dll.mui /Files/Program Files (x86)/common files/Microsoft Shared/ink/en-US/micaut.dll.mui: no such file or directory

So, why perform this switching manually when there is PowerShell to rescue, stick this line to your up.ps1 

 & "C:\Program Files\Docker\Docker\DockerCli.exe" -SwitchWindowsEngine

Also, corresponding command to switch to linux engine just for reference, although this might not be necessary for our scenario:

 & "C:\Program Files\Docker\Docker\DockerCli.exe" -SwitchLinuxEngine

up.ps1 for reference:



and, the above line takes care of switching the container automatically if daemon is running on Linux:


The best part is, the command silently continues in case if the daemon is already in windows mode!

Comments

Popular Posts