Can't start Docker Desktop due to Windows group policy - windows

I've updated Docker Desktop from 4.6.1 to 4.11.1, but after that I can't start Docker Desktop nor docker service. I looked in the logs and found this message:
[2022-08-12T19:27:53.379639400Z][com.docker.backend.exe][F] fork/exec C:\WINDOWS\System32\WindowsPowerShell\v1.0\powershell.exe: This program is blocked by group policy. For more information, contact your system administrator.
I see the error is provoked by a policy that the company where I work at has on every computer and it's something I can't change, so my question is:
Is there any way to configure Docker to start using CMD instead of Powershell? Or do I have to reinstall previous version and avoid updating?

Related

Docker container as Windows service start before login

I have created a container via Docker Desktop on a Windows PC and would now like to start this container like a service or daemon during system startup. If successful, the container would be accessible from its own network via 192.168.178.35:80 without a user having to log in and start Docker.
This is really not my favorite topic but I tried to learn about Windows task scheduling.
As you can see here I wrote a short powershell script that starts Docker Desktop.exe and then the container.
start "C:\Program Files\Docker\Docker\Docker Desktop.exe"
sleep 10
docker start 9df2014cdb06
exit
I assigned the script to the SYSTEM user in the task scheduler. (see screenshot 1)
Unfortunately, 192.168.178.35:80 cannot be reached when the system is booted. When I log in, I see that various Docker background processes in Task manager. (See screenshot 2).
However, Docker is no longer accessible in Powershell. (See error message)
PS C:\WINDOWS\system32> docker ps
error during connect: In the default daemon configuration on Windows, the docker client must be
run with elevated privileges to connect.: Get "http://%2F%2F.%2Fpipe%2Fdocker_engine/v1.24/containers/json":
open //./pipe/docker_engine: The system cannot find the file specified.
And starting it from the desktop icon does not succeed either. Instead, the message appears that Docker is already running.
But my container is not running.
How do I get my container running and accessible on Windows after system startup and before user login?

Auto Start Docker on Windows reboot

I created a task to autostart docker on windows server using TaskScheduler
referred to https://stackoverflow.com/a/59467740/12768108
As admin created a local "task-executor" user and added it to the administrator group.
As admin added the same user to the docker-users group
Now after logging into the system using another user account(already in the docker users group), I run the task manually from the task scheduler the docker services started with daemon mode and I am able to run all docker commands like "docker ps".
But when restarting the machine it only started two services of docker ie "docker desktop" and "docker desktop backend" and not others, also when tried to run docker ps gives below error
error during connect: This error may indicate that the docker daemon is not running.: Get "http://%2F%2F.%2Fpipe%2Fdocker_engine/v1.24/containers/json": open //./pipe/docker_engine: The system cannot find the file specified.
I have also tried https://github.com/tfenster/dockeraccesshelper but this helps me achieve only point 1 of the description.
Can someone please let me know what i am missing here ?

Permissions to run docker container on self-hosted windows azure devops agent

In an azure devops build pipeline running on a self-hosted windows agent, I am trying to execute a tool that run a docker container.
Unfortunately I get this error :
Failed to start: failed to create container: Error response from daemon: CreateFile c:\Users\BUILDAGENT\.aerokube\selenoid: Access is denied.
The build agent is configured with its own windows local user "BUILDAGENT", so he has permissions on the C:\Users\BUILDAGENT\ folder
Looking at the process manager, I see that except com.docker.service, the others docker processes are running with the user that launched the Docker Desktop (my coworker).
If I restart windows and relaunch docker myself, the settings selected by my coworker ("Disk Image Location" for instance), are not restored...
Is there a way to make docker run as a daemon on startup with a specific user (service or system user, but not mine or my coworker) ?
Once this is done I guess I just have to give permissions for that specific user on the C:\Users\BUILDAGENT\ folder to solve my issue, right ?
Update :
I added my BUILDAGENT user in docker-users group, and it solves the permission issue, but I still would like to run docker as a service, instead of login as my local user to launch it with its GUI...
but I still would like to run docker as a service, instead of login as my local user to launch it with its GUI
You could try to create a task scheduler to run docker with that specific user when your PC starts.
Please check this thread How to create an automated task using Task Scheduler on Windows 10 for some more details.
In this case, docker will start automatically every time you start your computer.

Can I develop with VS Code in containers on a remote host running Windows/WSL2?

Original Post
I have a Windows workstation with WSL2 and Docker installed that I am able to use for container based development in VS Code. I would like to be able to develop inside the containers on this system remotely. I am able to SSH directly into the WSL2 environment on the workstation and am able to start the docker daemon without logging directly into Windows by creating a Task to start the daemon automatically as described here: https://stackoverflow.com/a/59467740/10692741
However when I try to access Docker on the remote machine by following this guide: https://code.visualstudio.com/docs/remote/containers-advanced#_developing-inside-a-container-on-a-remote-docker-host, I get the following error:
error during connect: Get http://docker/v1.24/version: net/http: HTTP/1.x transport connection broken: malformed HTTP status code "\x00c\x00o\x00m\x00m\x00a\x00n\x00d\x00"
I have also tried connecting via a SSH tunnel as outlined here: https://code.visualstudio.com/docs/remote/troubleshooting#_using-an-ssh-tunnel-to-connect-to-a-remote-docker-host and am unable to connect to Docker as well.
Has anyone had success with a setup like this? Or is this not supported due to limitations with Docker on Windows, WSL2, and/or Windows OpenSSH implementation?
Update: 2021-01-21
When I SSH into the Windows machine remotely, I am able to see the docker containers in the VS Code extension. I am able to start them, stop them, and enter into them with the shell. However, when I try to attach VS Code I get same error shown above.
Things that may have possibly affected this over the past couple days:
Adding SSH keys on my local machine to the ssh-agent via ssh-add /my/key
Exposing Docker daemon on tcp://localhost:2375 without TLS on the remote Windows machine
Also I want to note that the I've tried using Windows, Mac, and Linux as the local machine. With Mac and Linux I am able to open a remote session into the Windows machine, but from the Windows local machine I am able to SSH into the remote Windows machine but cannot open a remote connection in VS Code for some reason.
Ok, I was able to get this working using the port/socket forwarding technique. For sake of clarity, I'll use:
local development workstation, local workstation, or just workstation to indicate the computer from which we wish to use VSCode to access Docker containers on ...
the remote Docker host, remote, or just Docker host
Sanity check -- Do you have Docker Desktop installed on both systems? On the local development workstation, you can skip the WSL2 integration, but you'll at least need the client tools, since the VSCode extension uses them.
Steps I took:
I already had Docker with WSL2 integration set up on my main system (which for the purposes of this exercise, became my remote Docker host), along with VSCode, so I knew everything was working there. It sounds like that was your starting point as well.
On another system on the same network (accessed with RDP to make it simple), I already had VSCode installed as well, with the Remote Development Extension Pack. I also have WSL on that system, but only a v1 instance there. Not that WSL on the workstation should be a factor at all for the purposes of this exercise.
I installed Docker Desktop for Windows on that local development workstation.
I also installed the Docker extension for VSCode, since I didn't yet have it on the local development workstation.
On the workstation, I was not yet set up to SSH from PowerShell into my WSL Ubuntu distro on the remote. From PowerShell on the workstation, I generated an ECDSA key (per this and other documents) and added the public key to my authorized_keys on the the remote.
On the workstation, I started the OpenSSH Authentication Service and added the newly created key to the agent (in PowerShell) with ssh-agent add ~\.ssh\id_ecdsa.
I logged out of the workstation and back in so that the path changes were picked up for the Docker desktop install.
I was then able to ssh from Powershell on the local to Ubuntu/WSL on the remote with the port forwarding. Since I'm using the Windows 10 OpenSSH server as a jumphost to my WSL SSH servers, my command looked slightly different (with a -o "ProxyCommand ... mainly), but overall the structure is the same as the one listed in the "SSH Tunnel" doc you linked in your question.
On the remote (manually, not through any integration from the local), I did a basic docker run -it --rm Ubuntu and left it open.
On the local, from PowerShell, I set the DOCKER_HOST environment variable via [System.Environment]::SetEnvironmentVariable("DOCKER_HOST","tcp://localhost:23750").
I was then able to see the remote container using docker ps on the local. I could also docker exec -it containername bash into it remotely.
Of course, the above two steps aren't needed in the long term for VSCode, they were just part of my process to make sure everything was up and running (since, as you might expect, I did have several points at which I failed during this process).
So with that working, it was a simple matter in VSCode to change the Docker extension's DOCKER_HOST setting to tcp://localhost:23750. And voila, I could see all images on the remote as well as attach to them from VSCode.
Other thing(s) to check
I'll add to this list if we find additional reasons why it might not be working, but for now:
You mention that you are starting the Docker Desktop daemon automatically at startup via Task Manager, but you don't mention anything about the WSL2 instance. However, since you are able to ssh into it, I assume you have a way to bring it up as well? My experience has been that, unless the owning user is logged in, WSL terminates any instances after a few seconds, even if a service is running. There's a workaround, I believe, that I can dust off if this is a problem.

failing to start docker engine open //./pipe/docker_engine

I'm receiving the following error in docker on windows 10 laptop.
I've try to reinstall and restart but nothing helps.
The docker service is running OK but what i understand that i have a problem with the docker daemon (from what i read)
The whole issue started when i run the 2 commands:
net stop com.docker.service
net start com.docker.service
from there on i keep getting the error below and cannot solve it.
C:\Users\xxxx>docker images error during connect: Get
http://%2F%2F.%2Fpipe%2Fdocker_engine/v1.30/images/json: open
//./pipe/docker_engine: The system cannot find the file specified. In
the default daemon configuration on Windows, the docker client must be
run elevated to connect. This error may also indicate that the docker
daemon is not running.
anyone succeed to solve it?
docker client must be run elevated to connect
This indicates that you do not have enough permissions. Try starting the terminal as administrator.
I run Docker remotely as a non admin user.
For this the user running docker should have full permission to location where Docker is installed.
User should be part of docker_users group
docker daemon runs on port 2375 by default. Try to whitelist this port. Allow incoming connections to 2375 in Windows Firewall settings
Restart your docker daemon and Docker service.
Restart the running Docker instance[Docker for Windows] if required. You do not have to reinstall.

Resources