Hey everyone! I'm reaching out for some guidance on a project I'm working on. I need to set up a private build agent using Azure DevOps to push a Windows-based image to a private container registry. My struggle is with getting Docker Desktop in Windows container mode up and running for use in my pipeline. I've been trying to use chocolatey for the installation, but I'm facing an exit code -5 error that I can't find any info on. Am I missing something or is there a better method to achieve this? I've even attempted to run a startup PowerShell script, but that introduced a host of other problems.
3 Answers
Installing Docker Desktop inside a Windows Docker container image is not going to work. Instead, you should create a Windows Server VM that matches your base image version. From there, you can execute a PowerShell script to set up the Docker runtime and Docker CE. Make sure to test if Docker is running by using commands like `docker version` and `docker ps`. After everything is good, set up your Azure Pipelines Agent and you should be set!
I have a different approach that’s a lot simpler to manage. Why not install WSL 2 instead? First, go to Control Panel > Program and Features > Turn Windows Features on or off, and enable the Windows Hypervisor Platform. Then, restart and open PowerShell as an administrator to run `wsl --install --no-distribution`. After that, you can install Debian as your distro. Once that’s set up, you can easily follow the Docker installation guide for Debian. This way, your Docker setup will be cleaner and you can avoid a lot of the headaches!
It’s worth noting that Windows containers aren’t ideally suited for Docker Desktop, but rather the Windows container service itself. If you are using Docker Desktop, make sure you've switched it to Windows mode. Have you done that yet?
Thanks for the suggestion! However, since I'm building a Windows image, I believe it has to run in a Windows environment. I don't think WSL is suitable for this scenario.