Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docker Desktop running as scheduled task in Windows Server 2022 with no logged user not working #13790

Open
D3vil0p3r opened this issue Nov 10, 2023 · 6 comments

Comments

@D3vil0p3r
Copy link

D3vil0p3r commented Nov 10, 2023

Description

I installed Docker Desktop with WSL engine to run a docker container in a Windows Server 2022. What I need is to create a scheduled task in Task Scheduler in order to run docker daemon/Docker Desktop with no user login.

I tried solutions like #2632 and https://stackoverflow.com/questions/51252181/how-to-start-docker-daemon-windows-service-at-startup-without-the-need-to-log but they don't work.

I created a scheduled task in Task Scheduler as:
image

image

image

where the ps1 script that is run contains the following:

start "C:\Program Files\Docker\Docker\Docker Desktop.exe"
start-service -Name com.docker.service

I also tested it by running directly:

C:\Program Files\Docker\Docker\Docker Desktop.exe

After created this task, once ensured all docker processes are down, when I click on Run to test it, on Task Manager I get several docker processes starting and running, but, if I open CMD and run docker ps -a to check if docker is running, I get the following message:

request returned Internal Server Error for API route and version http://%2F%2F.%2Fpipe%2Fdocker_engine/v1.24/containers/json?all=1, check if the server supports the requested API version

Why a scheduled task is not able to run the docker daemon?

Reproduce

On Windows Server 2022, create a scheduled task to run at startup Docker Desktop application, and run the scheduled task to verify if the docker daemon is starting.

Expected behavior

Docker daemon running after running the scheduled task.

docker version

Client:
 Version:           24.0.7
 API version:       1.43
 Go version:        go1.20.10
 Git commit:        afdd53b
 Built:             Thu Oct 26 09:08:44 2023
 OS/Arch:           windows/amd64
 Context:           default

Server: Docker Desktop 4.25.0 (126437)
 Engine:
  Version:          24.0.6
  API version:      1.43 (minimum version 1.12)
  Go version:       go1.20.7
  Git commit:       1a79695
  Built:            Mon Sep  4 12:32:16 2023
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.6.22
  GitCommit:        8165feabfdfe38c65b599c4993d227328c231fca
 runc:
  Version:          1.1.8
  GitCommit:        v1.1.8-0-g82f18fe
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

docker info

Client:
 Version:    24.0.7
 Context:    default
 Debug Mode: false
 Plugins:
  buildx: Docker Buildx (Docker Inc.)
    Version:  v0.11.2-desktop.5
    Path:     C:\Program Files\Docker\cli-plugins\docker-buildx.exe
  compose: Docker Compose (Docker Inc.)
    Version:  v2.23.0-desktop.1
    Path:     C:\Program Files\Docker\cli-plugins\docker-compose.exe
  dev: Docker Dev Environments (Docker Inc.)
    Version:  v0.1.0
    Path:     C:\Program Files\Docker\cli-plugins\docker-dev.exe
  extension: Manages Docker extensions (Docker Inc.)
    Version:  v0.2.20
    Path:     C:\Program Files\Docker\cli-plugins\docker-extension.exe
  init: Creates Docker-related starter files for your project (Docker Inc.)
    Version:  v0.1.0-beta.9
    Path:     C:\Program Files\Docker\cli-plugins\docker-init.exe
  sbom: View the packaged-based Software Bill Of Materials (SBOM) for an image (Anchore Inc.)
    Version:  0.6.0
    Path:     C:\Program Files\Docker\cli-plugins\docker-sbom.exe
  scan: Docker Scan (Docker Inc.)
    Version:  v0.26.0
    Path:     C:\Program Files\Docker\cli-plugins\docker-scan.exe
  scout: Docker Scout (Docker Inc.)
    Version:  v1.0.9
    Path:     C:\Program Files\Docker\cli-plugins\docker-scout.exe

Server:
 Containers: 1
  Running: 1
  Paused: 0
  Stopped: 0
 Images: 1
 Server Version: 24.0.6
 Storage Driver: overlay2
  Backing Filesystem: extfs
  Supports d_type: true
  Using metacopy: false
  Native Overlay Diff: true
  userxattr: false
 Logging Driver: json-file
 Cgroup Driver: cgroupfs
 Cgroup Version: 1
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
 Swarm: inactive
 Runtimes: io.containerd.runc.v2 runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: 8165feabfdfe38c65b599c4993d227328c231fca
 runc version: v1.1.8-0-g82f18fe
 init version: de40ad0
 Security Options:
  seccomp
   Profile: unconfined
 Kernel Version: 5.15.90.1-microsoft-standard-WSL2
 Operating System: Docker Desktop
 OSType: linux
 Architecture: x86_64
 CPUs: 8
 Total Memory: 7.758GiB
 Name: XDA-DEV-HHC-01
 ID: 12f7211b-48bf-430d-87ee-3f936be501a5
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 HTTP Proxy: http.docker.internal:3128
 HTTPS Proxy: http.docker.internal:3128
 No Proxy: hubproxy.docker.internal
 Experimental: false
 Insecure Registries:
  hubproxy.docker.internal:5555
  127.0.0.0/8
 Live Restore Enabled: false

WARNING: No blkio throttle.read_bps_device support
WARNING: No blkio throttle.write_bps_device support
WARNING: No blkio throttle.read_iops_device support
WARNING: No blkio throttle.write_iops_device support
WARNING: daemon is not using the default seccomp profile

Diagnostics ID

A0E8E9B0-FC58-4DEF-9660-6E503734F8B8/20231110205349

Additional Info

No response

@paulgolter
Copy link

paulgolter commented Nov 16, 2023

Hey I have the exact same issue on my end. Tried it with Docker 25.1 on windows 11.

Any solutions so far? My goal is to run a container when my windows machine boots, independent of user login.

@DevHHM
Copy link

DevHHM commented Dec 4, 2023

@D3vil0p3r @paulgolter

Hi, I have succeeded in getting docker to run without login as a task scheduler on windows10.

This error means that there is an error in communication with docker's backend api server.
I checked how the execution process are different in my case.
Check if your symptoms are similar.

When I run docker desktop directly, vmmem runs to occupy virtual memory and docker desktop api proxy for wsl2 runs.
However, when I run it through the task scheduler, vmmem doesn't run and docker desktop api proxy for wsl2 doesn't run.

As it turns out, this is an issue with WSL.
There is a problem that the current version of WSL does not run when executed by the task scheduler.
MS confirmed the issue and pre released an fixed version of WSL in September.
If you install this version, WSL will run normally in Task Scheduler.

wsl --update --pre-release

now, my wsl version is 2.0.14.0 and docker desktop is 4.18.0.0.
When I get a chance, I'll check it out in the latest version of Docker.

I'm using a translator, so I apologize if my English is weird.

@amoscatelli
Copy link

I can confirm I can run WSL2 (after the prerelease update) via Scheduled Task ...

Yet Docker Desktop still doesn't work.
I can see all the Docker Desktop processes up and running but the WSL2 ones start and terminate right away.
Also I see all the WSL2 distros are deregister in this process (docker-desktop-data and docker-desktop).

Help ?
Is this supposed to work now ?

@amoscatelli
Copy link

@DevHHM does the same work on Windows 11 ?

@DevHHM
Copy link

DevHHM commented Jan 24, 2024

@DevHHM does the same work on Windows 11 ?

well... i don't know that.
but, I'll test it out soon.
The company's computer was Windows 10, the computer at home is Windows 11.

@DevHHM
Copy link

DevHHM commented Jan 24, 2024

I can confirm I can run WSL2 (after the prerelease update) via Scheduled Task ...

Yet Docker Desktop still doesn't work. I can see all the Docker Desktop processes up and running but the WSL2 ones start and terminate right away. Also I see all the WSL2 distros are deregister in this process (docker-desktop-data and docker-desktop).

Help ? Is this supposed to work now ?

Can you post a detailed description of how you set it up?
Please capture the script, version, and process state.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants