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

Windows Containers side by side with Rancher Desktop - for windows containers implementation ideas #3999

Open
the-mentor opened this issue Feb 21, 2023 · 8 comments
Labels
kind/enhancement New feature or request
Projects

Comments

@the-mentor
Copy link

the-mentor commented Feb 21, 2023

Problem Description

Hi,
After talking with Jan on slack here is my documentation on how how I got moby (open source docker) and rancher desktop to install and work side by side on my windows workstation.

  1. I complied dockerd.exe from source for windows from the moby repository https://github.com/moby/moby.
  2. I've enabled the containers feature in Windows via Powershell Enable-WindowsOptionalFeature -Online -FeatureName containers –All
  3. I've installed dockerd.exe and configured it by doing the following:
    a) Copying it to c:\program files\docker\dockerd.exe
    b) Registering it as a service using the following commands: cd c:\program files\docker and dockerd.exe --register-service
    c) Creating the security group and C:\ProgramData\docker\config\daemon.json file using the below PowerShell code
    this will create a security group called docker-users and all members of this group wont need admin privileges to interact with the docker daemon.
# add group that will be allowed to use the docker engine named pipe.
New-LocalGroup `
    -Name docker-users `
    -Description 'Docker engine users' `
    | Out-Null

# configure docker through a configuration file.
# see https://docs.docker.com/engine/reference/commandline/dockerd/#windows-configuration-file
$config = @{
    'experimental' = $false
    'debug' = $false
    'labels' = @('os=windows')
    'exec-opts' = @('isolation=process')
    # allow users in the following groups to use the docker engine named pipe.
    # see https://github.com/moby/moby/commit/0906195fbbd6f379c163b80f23e4c5a60bcfc5f0
    # see https://github.com/moby/moby/blob/8e610b2b55bfd1bfa9436ab110d311f5e8a74dcb/daemon/listeners/listeners_windows.go#L25
    'group' = 'docker-users'
    'hosts' = @(
        'npipe:////./pipe/dockerDesktopWindowsEngine'
    )
}
mkdir -Force "$env:ProgramData\docker\config" | Out-Null
Set-Content -Encoding ascii "$env:ProgramData\docker\config\daemon.json" ($config | ConvertTo-Json -Depth 100)

d) Start the docker engine service via UI or PowerShell Start-Service docker
e) The last step would be to create a docker context using the docker cli docker context create docker-windows --description "docker windows engine" --docker "host=npipe:////./pipe/dockerWindowsEngine"

then once everything is configured we can switch to the windows context using docker context use docker-windows .
running docker system info will show we're running windows containers

PS C:\> docker system info
Client:
 Context:    docker-windows
 Debug Mode: false
 Plugins:
  compose: Docker Compose (Docker Inc., v2.14.0)

Server:
 Containers: 2
  Running: 0
  Paused: 0
  Stopped: 2
 Images: 1
 Server Version: 23.0.1-aroth
 Storage Driver: windowsfilter
  Windows:
 Logging Driver: json-file
 Plugins:
  Volume: local
  Network: ics internal l2bridge l2tunnel nat null overlay private transparent
  Log: awslogs etwlogs fluentd gcplogs gelf json-file local logentries splunk syslog
 Swarm: inactive
 Default Isolation: process
 Kernel Version: 10.0 20348 (20348.1.amd64fre.fe_release.210507-1500)
 Operating System: Microsoft Windows Server Version 21H2 (OS Build 20348.768)
 OSType: windows
 Architecture: x86_64
 CPUs: 4
 Total Memory: 1.999GiB
 Name: BL004-FS2-mcm33
 ID: fde5e762-59e1-4627-afa2-f7db51a5263e
 Docker Root Dir: C:\ProgramData\docker
 Debug Mode: false
 Registry: https://index.docker.io/v1/
 Labels:
  os=windows
 Experimental: false
 Insecure Registries:
  127.0.0.0/8
 Live Restore Enabled: false

we can always switch back to use rancher by running docker context use default

Let me know if this is enough information or if you need anything else

Proposed Solution

Add support for windows containers via moby (open source docker) as outlined above and add support in the rancher-desktop UI.

Additional Information

No response

@the-mentor the-mentor added the kind/enhancement New feature or request label Feb 21, 2023
@github-actions github-actions bot added this to To do in Stripey via automation Feb 21, 2023
@jerome-blanche
Copy link

@the-mentor there is a small typo in step 3. e) it should be:

... --docker "host=npipe:////./pipe/dockerDesktopWindowsEngine"

Working well otherwise, thanks!

@Alexandre-Georges
Copy link

@the-mentor Thank your instructions, it makes sense but I have a question for you regarding that part:

I complied dockerd.exe from source for windows from the Moby repository https://github.com/moby/moby.

According to Moby's documentation it seems that building docker requires to have a docker that runs on Windows... If I am right it means that Docker Desktop is required no matter what to build Moby.

Here is the documentation I am referring to:

Is that correct? Or could you take a moment to explain how you were able to compile Moby on Windows?
You might have compiled the code without a docker container, in that case that would make sense.

@the-mentor
Copy link
Author

@Alexandre-Georges a few things have changed since I wrote the guide.
you can use the binaries provided by docker for the docker community edition rather then compiling yourself
you can find them here https://download.docker.com/win/static/stable/x86_64/

I hope that helps

@michha
Copy link

michha commented Aug 19, 2023

@the-mentor you could update your original post and replace your first step

I would like to also point out on the microsoft documentation Prep Windows for containers that links to a script install-docker-ce.ps1 which does step 1, 2 and most of step 3.

@theTALLish1
Copy link

When I run this locally, using the install-docker-ce.ps1 script or the above doc I typically encounter this error when I run the docker system info command:

Server:
ERROR: error during connect: Get "http://%2F%2F.%2Fpipe%2FdockerWindowsEngine/v1.24/info": open //./pipe/dockerWindowsEngine: The system cannot find the file specified.
errors pretty printing info

Any help in getting past this would be much appreciated. I have WSL2 enabled, features: Containers, HyperV, and using binary: docker-24.0.6

@Nicolas-Arnaise
Copy link

For info, the script install-docker-ce.ps1 is meant to be run in the default version of powershell for your Windows. Do not use the latest versions of powershell, it won't work.

When I run this locally, using the install-docker-ce.ps1 script or the above doc I typically encounter this error when I run the docker system info command:

Server: ERROR: error during connect: Get "http://%2F%2F.%2Fpipe%2FdockerWindowsEngine/v1.24/info": open //./pipe/dockerWindowsEngine: The system cannot find the file specified. errors pretty printing info

Any help in getting past this would be much appreciated. I have WSL2 enabled, features: Containers, HyperV, and using binary: docker-24.0.6

Make sure that your file %ProgramData%\docker\config\daemon.json contains the part

{
    'group' = 'docker-users',
}

If yes, you can check that your user is in the local group :

Get-LocalGroup -Name docker-users  # this should print a line "docker-users"
Get-LocalGroupMember -Name docker-users  # this should print a line with your current user

If there are no local group named "docker-users" add it:

New-LocalGroup -Name docker-users -Description 'Docker engine users'
# Then add your user to the group:
Add-LocalGroupMember -Name docker-users -Member $Env:UserName

Then try restarting your computer.

@erstert3st
Copy link

erstert3st commented May 2, 2024

if you get the Error: hcs::CreateComputeSystem : The container operating system does not match the host operating system.
simpl edit "isolation"="process" to : "isolation=hyperv" in the daemon.json
maybe bc iam on Win10
anyway thanks 👍

@GoingMyWay
Copy link

docker context create docker-windows --description "docker windows engine" --docker "host=npipe:////./pipe/dockerWindowsEngine"

Run

docker context create docker-windows --description "docker windows engine" --docker "host=npipe:////./pipe/dockerDesktopWindowsEngine"

Not docker context create docker-windows --description "docker windows engine" --docker "host=npipe:////./pipe/dockerWindowsEngine".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/enhancement New feature or request
Projects
No open projects
Stripey
To do
Development

No branches or pull requests

8 participants