First off, thank you for any help and I am very new to Docker and just trying to get something to work, so I can move forward.
Expected behavior
I want to be able to use the VSTS Built in tasks for Building and Pushing a Linux Docker Image (I do not need to host any images, just build and push to host).
Actual behavior
After much searching and multiple attempts at other options, I installed Docker Desktop for Windows and setup Hyper-V and the tasks started to work, but only when someone was logged into the server because Docker Desktop does not run when a user is not logged in. I feel like this is not the correct way to handle things and I am looking for the best solution.
Information
- Windows Server 2016
- Visual Studio 2017
Does anyone know how to setup a self hosted Agent that will allow me to Build and Push Docker Images.
You can try to use experimental LCOW option to run UNIX containers on windows instead of using Docker Desktop.
I am not sure I understand how having “Linux Containers on Windows” (LCOW) to run a container instead of Docker Desktop will help me build and push Docker Images. Can you explain how this would assist me some more? Do I use a different Docker Installation for the Build and Push? If so do I even need LCOW, since I won’t be running any containers?
LCOW can be run in unattanded mode under any user, while Docker Desktop requires that piece of software running and hence the issue you are having.
Ok, so LCOW would still give me access to the Docker Commands Build and Push with a VSTS Build Agent Task?
I have been reading the documentation for LCOW and to setup it up the first thing it asks you to do is follow Docker for Windows install procedure which will just install Docker Desktop for Windows and then you use the instructions to have run a linux container from powershell with a image. What I need is to build and push images to another Docker host from my VSTS Agent. How does having a Linux Container running help me with this? Does Docker run in the background just because I have a linux container running? If so, how is this better than having a user forever logged into the server?
Not sure about docker desktop but docker installed on Windows 2016 runs as service so you can interact with it anytime you want.
Is a LCOW Image different than a standard Docker Image?
LCOW is not an image, it’s the way you can run LInux containers on Windows. Instead of using Docker Desktop which is not supported on WIndows 2016 anyway.
Do you have a link to something that explains more, because looking up LCOW I find three main sources Microsoft Docs (https://docs.microsoft.com/en-us/virtualization/windowscontainers/deploy-containers/linux-containers) which instructs me to install Docker Desktop and then run a container in a different way which I do not think will help me with Building and Pushing Docker Images, since the change is for running containers not running docker . The other link is for a linuxkit tool(https://blog.docker.com/2017/09/preview-linux-containers-on-windows/ which links me to https://github.com/linuxkit/lcow for the latest) that helps build docker images in another way. I see another option in Google about a Ubuntu tutorial (https://tutorials.ubuntu.com/tutorial/tutorial-windows-ubuntu-hyperv-containers) for running Linux containers on Windows with a Ubuntu hosting base, which I assume would have the same problem as the first option since it is about running containers, not building and push images.
What I am truly looking for is a way to Build and Push Docker Images to a seperate Docker Host.
Second link is correct, the one which is NOT Docker desktop
In the documentation it mentions building images differently, basically using the linuxkit to build a LCOW image. Currently the Docker images I am creating work correctly with the Docker Host I push to, but I don’t know if this new image will work correctly. Do you know if the images work differently or if they require the Docker Host to have something else setup to work?
It shall be the same image regardless how you build it as long as you are successfull in building
Thanks, I am going to give it a try and see what happens.
When I tried to follow the install and run process I get a error when trying to run the linux container.
Error here “unsupported os linux”
Which is concerning, but maybe I did something wrong. Have you used this recently on a Windows 2016 server?
I used it on Windows 2019. Make sure all prereqisites are met and that you are using correct command line to launch docker since by default it will try to use windows containers.
I followed the steps and had the prerequisites before following them.
When I user dockerd.exe I get a powershell window that become just a log and then when I run the docker commend and Daemon returns that error. I did notice that none of it works when I don’t have the dockerd.exe powershell window running, is that intended?
Yes, dockerd shall be running since it’s docker daemon. You can configure to run it as service instead so you don’t need to start it manually each time. Once you have it running you shall be able to use LCOW
What allows it to run as a service?
There shall be instructions somewhere how to make dockerd to run as service.