Skip to main content


Docker Tips and Tricks

Delete all stopped containers.

docker rm $(docker ps -a -q)

Docker and VM-Ware can finally co-exits on Windows

Thanks to a co-operation between Microsoft and VMWare it is now possible to run VM-Ware workstation with the Hyper-V feature enabled. Prior to this change enabling Hyper-V would prevent VM-Ware workstation from running.

As docker relied on Hyper-V it was up to this point not supported to run the two pieces of technology in parallel. (It was possible in the past to get these technologies to run alongside in parallel but it required a lot of registry voodoo.)

Fortunately, those problems are behind us and starting with Windows Pro 10 May 2020, VM Ware workstation, Docker, Hyper-V as well as the Linux subsytem can all happily co-exist on windows.

Windows 10 Installation Issues

Installing Docker v2.3.0.3 (45519) on my main machine was, unfortunately, not as trouble-free as was the case on my Dell Latitude laptop.

Both systems were running Windows 10 Pro [Windows 10 May 2020] - (OS Build 19041.388) and while the installation worked flawlessly on my laptop getting docker working on my workstation required some troubleshooting before the docker service would start.

There were no reported problems during the docker installation, and the docker client appeared to be running as expected in the system tray. However, the docker icon signalled trouble with a deep red colour as well as the notification "Cannot stop from an unstable state".

The docker log showed:

Docker.ApiServices.StateMachines.InvalidTransitionException: Cannot stop from an unstable state at Docker.ApiServices.StateMachines.UnstableState.Docker.ApiServices.StateMachines.IInternalEngineState.BeginStopAsync() at Docker.ApiServices.StateMachines.EngineStateMachine.d__15.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Docker.Engines.Engines.d__29.MoveNext()

Windows 2020 May update introduced some fundamental changes to the Windows subsystem for Linux (WSL), and it seemed that the problem was related.

I suspect the root cause of my troubles were my previous experiments with various virtualisation and containerisation technologies which involved enabling and disabling the window hypervisor technology as well as installing and removing various Linux subsystem distributions.

Below are the steps which resolved the problem and enabled the docker service to run as expected. The information was acquired from a comment posted by "solovyov-private" on the docker windows issue tracker.

  1. Uninstall Docker

  2. PowerShell (with administrator priviledge)

    wsl -set-default-version 2
  3. Install Docker

Unfortunately, I was not able to confirm that the above steps alone resolve the issue. Therfore, I detail below, all the troubleshooting I performed prior to the previously listed steps.

  • Downloaded and installed the WS2 subsystem as per this article.
  • Enable Hyper-V Windows Search: "Turn Windows feature on or off" Enabled: Hyper-V and the submenu items Hyper-V Management Tools, and Hyper-V Platform.
  • Confirm system environment variables required by docker PowerShell script are present and re-arrange order. (this is unlikely to be required) Windows Search: "Edit the System Environment variables" System variables: PSModulePath

Windows 10 Docker Conflict with VM Work Station

I experienced an issue which prevented my from accessing a web server container mapped to port 443. What was happending was that I was able to launch the container but any attempt to access the web server through port 443 or port 80 resulted in a 403 access denied.

Troubleshooting revealed that by default VMWare workstation automatically binds to port 443 as part of its Virtual Machine sharing feature.

To free port 443 open VM-Ware workstation. Edit - Preferences - Shared VM's. Click Change Settings. Click Disable Sharing. Change the port to something unused for example 8444. Then re-enable sharing and click ok.

VMWare will now bind to the new port freeing port 443 for use by docker. (Note you may need to restart the container or docker.)

Windows 10 Docker Failed to Initialize Windows

Docker unexpectedly stopped working one day. It may have been related to uninstalling VM Workstation Professional, upgrading to docker 4.0.1 or some other unknown factor. However, the docker icon was no longer showing in the task-bar and launching docker-desktop from an icon results in docker reporting "Docker failed to initialize".

Ultimately what solved the issue was to delete the folder: "%AppData%\Docker"

While the above action ultimately resolved the issue I did the following in the progress of troubleshooting. Some of these steps may have complicated the issue, as such I would suggest tryint the above action first.

The full steps to resolve this issue are as follows.

  1. Uninstall Docker-Desktop through Windows Add/Remove programs.
  2. Reboot Windows
  3. Install Docker Desktop

The problem persisted (docker desktop could not be opened) also checking wsl in powershell confirmed that the virtual images required by docker were missing.

wsl -v -l

Only showed "Ubuntu-20.04 Running 2"

Due to space constraints, I have moved the location of WSL images. Checking the location showed that the docker installer did not install the required docker-desktop and docker-desktop-data machine folders. There appeared to be no way to get the installer to create the required machines in WSL.

Luckily, Docker was still working on my laptop running the same version of windows 10 and docker as the problem machine. I exported the required docker images and then re-imported them on the problem machine. Using the following commands.

  1. Quit Docker
On the source machine.
wsl --shutdown
wsl --export docker-desktop-data c:\Users\myuser\docker-desktop-data.tar
wsl --export docker-desktop c:\Users\myuser\docker-desktop
  1. Copy the tar files to the target (problem) machine and import into the WSL.

    Note: I imported the wsl to a non default location that has more space.

On the target machine.
wsl --shutdown
wsl --import docker-desktop-data D:\wsl\docker-desktop-data\ L:\tmp\docker-desktop-data.tar --version 2
wsl --import docker-desktop D:\wsl\docker-desktop\ L:\tmp\docker-desktop.tar --version 2
wsl -v -l

Should now also show the docker-desktop-data and docker-desktop machines.

After confirming docker machines are installed in WSL and deleting the "%AppData%\Docker" folder I was able to successfully start docker again