Docker/Windows: Difference between revisions
(9 intermediate revisions by the same user not shown) | |||
Line 10: | Line 10: | ||
Docker Community Edition (CE) provides a standard runtime environment for containers with a common API and command-line interface (CLI). It is managed by the open source community as part of the Moby Project. | Docker Community Edition (CE) provides a standard runtime environment for containers with a common API and command-line interface (CLI). It is managed by the open source community as part of the Moby Project. | ||
Invoke-WebRequest -UseBasicParsing "https://raw.githubusercontent.com/microsoft/Windows-Containers/Main/helpful_tools/Install-DockerCE/install-docker-ce.ps1" -o install-docker-ce.ps1 | |||
.\install-docker-ce.ps1 | |||
src: | |||
https://raw.githubusercontent.com/microsoft/Windows-Containers/Main/helpful_tools/Install-DockerCE/install-docker-ce.ps1 | https://raw.githubusercontent.com/microsoft/Windows-Containers/Main/helpful_tools/Install-DockerCE/install-docker-ce.ps1 | ||
--- | |||
Get started: Prep Windows for containers | Get started: Prep Windows for containers | ||
Line 20: | Line 23: | ||
Docker Engine on Windows | Docker Engine on Windows | ||
https://learn.microsoft.com/en-us/virtualization/windowscontainers/manage-docker/configure-docker-daemon | https://learn.microsoft.com/en-us/virtualization/windowscontainers/manage-docker/configure-docker-daemon | ||
Install Docker Community Edition (CE) reference: | |||
Prepare Windows operating system containers | Microsoft Learn | |||
https://learn.microsoft.com/en-us/virtualization/windowscontainers/quick-start/set-up-environment?tabs=dockerce#windows-server-1 | |||
== Install Docker Server Edition == | |||
AS OF 2023 THIS HAS BEEN DISCONTINUED | |||
GitHub - OneGet/MicrosoftDockerProvider: Provider to search, save and install Docker | |||
https://github.com/OneGet/MicrosoftDockerProvider | |||
Reminder - Updates to Windows Container Runtime Support - Microsoft Community Hub | |||
https://techcommunity.microsoft.com/t5/containers/reminder-updates-to-windows-container-runtime-support/ba-p/3620989 | |||
Updates to the Windows Container Runtime support - Microsoft Community Hub | |||
https://techcommunity.microsoft.com/t5/containers/updates-to-the-windows-container-runtime-support/ba-p/2788799 | |||
Don't Panic: Kubernetes and Docker | Kubernetes | |||
https://kubernetes.io/blog/2020/12/02/dont-panic-kubernetes-and-docker/ | |||
Just like Community Edition, but allows for Linux containers | |||
Enable containers: | |||
Enable-WindowsOptionalFeature -Online -FeatureName Containers | |||
Reboot: | |||
Restart-Computer -Force | |||
Install Docker: | |||
Install-Module -Name DockerMsftProvider -Repository PSGallery -Force | |||
Install-Package -Name docker -ProviderName DockerMsftProvider | |||
Restart: | |||
Restart-Computer -Force | |||
Start service: | |||
Start-Service Docker | |||
Stop-Service Docker | |||
Get-Service docker | |||
Server core: | |||
# 2022 | |||
docker pull mcr.microsoft.com/windows/servercore:ltsc2022 | |||
# 2019 | |||
docker pull mcr.microsoft.com/windows/servercore:ltsc2019 | |||
Run Linux Containers (Nested): | |||
Get-VM WinContainerHost | Set-VMProcessor -ExposeVirtualizationExtensions $true | |||
[Environment]::SetEnvironmentVariable("LCOW_SUPPORTED", "1", "Machine") | |||
Restart-Service docker | |||
daemon.conf: | |||
<pre> | |||
$configfile = @” | |||
{ | |||
“experimental”: true | |||
} | |||
“@ | |||
</pre> | |||
$configfile|Out-File -FilePath C:\ProgramData\docker\config\daemon.json -Encoding ascii -Force | |||
LCOW: | |||
Invoke-WebRequest -Uri "https://github.com/linuxkit/lcow/releases/download/v4.14.35-v0.3.9/release.zip" -UseBasicParsing -OutFile release.zip | |||
Expand-Archive release.zip -DestinationPath "$Env:ProgramFiles\Linux Containers\." | |||
Run ubuntu: | |||
docker run -it --rm ubuntu /bin/bash | |||
Switch back to Windows Containers: | |||
[Environment]::SetEnvironmentVariable("LCOW_SUPPORTED", "$null", "Machine") | |||
refs: | |||
Docker: Ejecutar containers Linux en Windows Server 2022 - Blog Virtualizacion | |||
https://www.maquinasvirtuales.eu/docker-ejecutar-containers-linux-en-windows-server-2022/ | |||
Run Docker on Windows Server 2019 / 2022 | ComputingForGeeks | |||
https://computingforgeeks.com/how-to-run-docker-containers-on-windows-server/ | |||
== Linux Ubuntu Container == | |||
Run Linux containers on Windows | Ubuntu | |||
https://ubuntu.com/tutorials/windows-ubuntu-hyperv-containers | |||
== Container Desktop == | |||
container-desktop | |||
https://container-desktop.io/ | |||
Container Desktop is an open-source alternative to Docker Desktop. It enables you to build, push, pull and run Linux containers on Microsoft Windows, by providing a seamless integration with Docker Engine Community Edition running on Windows Subsystem for Linux. The Container Desktop bundles the open-source docker and docker-compose cli clients for a native and simple user experience. | |||
Why Container Desktop?¶ | |||
* Free and open-source; | |||
* Easy and hassle free installation experience; | |||
* Plain and simple, no unnecessary bells and whistles; | |||
Download: | |||
* https://github.com/container-desktop/container-desktop/releases/latest | |||
== Stevedore == | |||
Docker Windows Containers Alternative | |||
GitHub - slonopotamus/stevedore: 🚢 Docker distribution for Windows Containers that Just Works | |||
https://github.com/slonopotamus/stevedore | |||
=== Stevedore Linux Container Support === | |||
Back in summer 2021, when this project was started, there were no known alternatives to Docker Desktop. Container Desktop didn’t exist yet, and Rancher Desktop just released initial 0.1.0 release. | |||
Today, things are very different. Rancher Desktop provides both Docker and Kubernetes support, with a very advanced UI. Stevedore is very unlikely to even come closer to Rancher Desktop functionality due to limited developer resources and lack of motivation. | |||
Thus, starting with 0.10.0 release, Stevedore focuses on its primary goal - providing a convenient way to install Docker for Windows containers. | |||
If you want to run Linux containers, consider one of these projects: | |||
* Rancher Desktop (Windows + Linux + Mac) - https://rancherdesktop.io/ | |||
* Container Desktop (Windows-only) - https://container-desktop.io/ | |||
* Colima (Mac-only) - https://github.com/abiosoft/colima | |||
== Windows Test Image == | == Windows Test Image == | ||
Line 32: | Line 163: | ||
C:\programdata\docker\config\daemon.json | C:\programdata\docker\config\daemon.json | ||
dockerd | Docker Docs | |||
https://docs.docker.com/reference/cli/dockerd/#/windows-configuration-file | |||
ref: | |||
* Configure Docker in Windows | Microsoft Learn - https://learn.microsoft.com/en-us/virtualization/windowscontainers/manage-docker/configure-docker-daemon | |||
== Isolation == | |||
Configure container isolation technology (Windows) | |||
https://docs.docker.com/reference/cli/dockerd/#configure-container-isolation-technology-windows | |||
For Windows containers, you can specify the default container isolation technology to use, using the '''--exec-opt isolation''' flag. | |||
The following example makes '''hyperv''' the default isolation technology: | |||
dockerd --exec-opt isolation=hyperv | |||
dockerd --exec-opt isolation=process | |||
If no isolation value is specified on daemon start, on Windows client, the default is '''hyperv''', and on Windows server, the default is '''process'''. | |||
== Isolation == | == Isolation == | ||
Line 97: | Line 248: | ||
"storage-opts" : [ "size=200G" ] | "storage-opts" : [ "size=200G" ] | ||
} | } | ||
</ | </pre> | ||
== Moby Project == | == Moby Project == |
Latest revision as of 16:18, 5 October 2024
Windows
Windows Containers GitHub
Github microsoft/Windows-Containers https://github.com/microsoft/Windows-Containers
Install Docker Community Edition
Docker Community Edition (CE) provides a standard runtime environment for containers with a common API and command-line interface (CLI). It is managed by the open source community as part of the Moby Project.
Invoke-WebRequest -UseBasicParsing "https://raw.githubusercontent.com/microsoft/Windows-Containers/Main/helpful_tools/Install-DockerCE/install-docker-ce.ps1" -o install-docker-ce.ps1 .\install-docker-ce.ps1
src:
https://raw.githubusercontent.com/microsoft/Windows-Containers/Main/helpful_tools/Install-DockerCE/install-docker-ce.ps1
---
Get started: Prep Windows for containers https://learn.microsoft.com/en-us/virtualization/windowscontainers/quick-start/set-up-environment?tabs=dockerce
Docker Engine on Windows https://learn.microsoft.com/en-us/virtualization/windowscontainers/manage-docker/configure-docker-daemon
Install Docker Community Edition (CE) reference:
Prepare Windows operating system containers | Microsoft Learn https://learn.microsoft.com/en-us/virtualization/windowscontainers/quick-start/set-up-environment?tabs=dockerce#windows-server-1
Install Docker Server Edition
AS OF 2023 THIS HAS BEEN DISCONTINUED
GitHub - OneGet/MicrosoftDockerProvider: Provider to search, save and install Docker https://github.com/OneGet/MicrosoftDockerProvider
Reminder - Updates to Windows Container Runtime Support - Microsoft Community Hub https://techcommunity.microsoft.com/t5/containers/reminder-updates-to-windows-container-runtime-support/ba-p/3620989
Updates to the Windows Container Runtime support - Microsoft Community Hub https://techcommunity.microsoft.com/t5/containers/updates-to-the-windows-container-runtime-support/ba-p/2788799
Don't Panic: Kubernetes and Docker | Kubernetes https://kubernetes.io/blog/2020/12/02/dont-panic-kubernetes-and-docker/
Just like Community Edition, but allows for Linux containers
Enable containers:
Enable-WindowsOptionalFeature -Online -FeatureName Containers
Reboot:
Restart-Computer -Force
Install Docker:
Install-Module -Name DockerMsftProvider -Repository PSGallery -Force
Install-Package -Name docker -ProviderName DockerMsftProvider
Restart:
Restart-Computer -Force
Start service:
Start-Service Docker
Stop-Service Docker
Get-Service docker
Server core:
# 2022 docker pull mcr.microsoft.com/windows/servercore:ltsc2022
# 2019 docker pull mcr.microsoft.com/windows/servercore:ltsc2019
Run Linux Containers (Nested):
Get-VM WinContainerHost | Set-VMProcessor -ExposeVirtualizationExtensions $true
[Environment]::SetEnvironmentVariable("LCOW_SUPPORTED", "1", "Machine")
Restart-Service docker
daemon.conf:
$configfile = @” { “experimental”: true } “@
$configfile|Out-File -FilePath C:\ProgramData\docker\config\daemon.json -Encoding ascii -Force
LCOW:
Invoke-WebRequest -Uri "https://github.com/linuxkit/lcow/releases/download/v4.14.35-v0.3.9/release.zip" -UseBasicParsing -OutFile release.zip Expand-Archive release.zip -DestinationPath "$Env:ProgramFiles\Linux Containers\."
Run ubuntu:
docker run -it --rm ubuntu /bin/bash
Switch back to Windows Containers:
[Environment]::SetEnvironmentVariable("LCOW_SUPPORTED", "$null", "Machine")
refs:
Docker: Ejecutar containers Linux en Windows Server 2022 - Blog Virtualizacion https://www.maquinasvirtuales.eu/docker-ejecutar-containers-linux-en-windows-server-2022/
Run Docker on Windows Server 2019 / 2022 | ComputingForGeeks https://computingforgeeks.com/how-to-run-docker-containers-on-windows-server/
Linux Ubuntu Container
Run Linux containers on Windows | Ubuntu https://ubuntu.com/tutorials/windows-ubuntu-hyperv-containers
Container Desktop
container-desktop https://container-desktop.io/
Container Desktop is an open-source alternative to Docker Desktop. It enables you to build, push, pull and run Linux containers on Microsoft Windows, by providing a seamless integration with Docker Engine Community Edition running on Windows Subsystem for Linux. The Container Desktop bundles the open-source docker and docker-compose cli clients for a native and simple user experience.
Why Container Desktop?¶
- Free and open-source;
- Easy and hassle free installation experience;
- Plain and simple, no unnecessary bells and whistles;
Download:
Stevedore
Docker Windows Containers Alternative
GitHub - slonopotamus/stevedore: 🚢 Docker distribution for Windows Containers that Just Works https://github.com/slonopotamus/stevedore
Stevedore Linux Container Support
Back in summer 2021, when this project was started, there were no known alternatives to Docker Desktop. Container Desktop didn’t exist yet, and Rancher Desktop just released initial 0.1.0 release.
Today, things are very different. Rancher Desktop provides both Docker and Kubernetes support, with a very advanced UI. Stevedore is very unlikely to even come closer to Rancher Desktop functionality due to limited developer resources and lack of motivation.
Thus, starting with 0.10.0 release, Stevedore focuses on its primary goal - providing a convenient way to install Docker for Windows containers.
If you want to run Linux containers, consider one of these projects:
- Rancher Desktop (Windows + Linux + Mac) - https://rancherdesktop.io/
- Container Desktop (Windows-only) - https://container-desktop.io/
- Colima (Mac-only) - https://github.com/abiosoft/colima
Windows Test Image
Hello World:
docker run hello-world:nanoserver
Something more ambition - try run powershell:
docker run -it mcr.microsoft.com/windows/servercore:ltsc2022 powershell
Config
C:\programdata\docker\config\daemon.json
dockerd | Docker Docs https://docs.docker.com/reference/cli/dockerd/#/windows-configuration-file
ref:
- Configure Docker in Windows | Microsoft Learn - https://learn.microsoft.com/en-us/virtualization/windowscontainers/manage-docker/configure-docker-daemon
Isolation
Configure container isolation technology (Windows) https://docs.docker.com/reference/cli/dockerd/#configure-container-isolation-technology-windows
For Windows containers, you can specify the default container isolation technology to use, using the --exec-opt isolation flag.
The following example makes hyperv the default isolation technology:
dockerd --exec-opt isolation=hyperv dockerd --exec-opt isolation=process
If no isolation value is specified on daemon start, on Windows client, the default is hyperv, and on Windows server, the default is process.
Isolation
Windows Server Containers use Hyper-V isolation by default on Windows 10 and 11 to provide developers with the same kernel version and configuration that will be used in production.
Switch to Windows Containers
& $Env:ProgramFiles\Docker\Docker\DockerCli.exe -SwitchDaemon .
Service
See service:
sc qc docker
Service is running as: docker
C:\WINDOWS\system32\dockerd.exe --run-service --service-name docker
Add a Docker Group to allow normal users to manage docker: (run as administrator)
net localgroup docker-users /add
Add user to group:
net localgroup docker-users [USER] /add
Update service to use docker-users group:
# -G, --group string Group for the unix socket (default "docker") sc config docker binPath="C:\WINDOWS\system32\dockerd.exe --run-service --service-name docker -G docker-users"
sc config docker binPath="C:\Windows\System32\dockerd.exe --run-service --config-file=C:\ProgramData\docker\config\daemon.json"
Restart service:
net stop docker net start docker
See updated service:
C:\> sc qc docker [SC] QueryServiceConfig SUCCESS SERVICE_NAME: docker TYPE : 10 WIN32_OWN_PROCESS START_TYPE : 2 AUTO_START ERROR_CONTROL : 1 NORMAL BINARY_PATH_NAME : C:\WINDOWS\system32\dockerd.exe --run-service --service-name docker -G docker-users LOAD_ORDER_GROUP : TAG : 0 DISPLAY_NAME : Docker Engine DEPENDENCIES : SERVICE_START_NAME : LocalSystem
daemon.json option:
C:\ProgramData\docker\config\daemon.json
{ "registry-mirrors": ["https://internal-docker-mirror:6609"], "group": "docker-users", "debug": true, "hosts": ["npipe://", "tcp://0.0.0.0:2375"], "experimental": false, "exec-opts": ["isolation=process"], "max-concurrent-downloads": 100, "max-concurrent-uploads": 100, "data-root": "C:\\docker_data", "storage-opts" : [ "size=200G" ] }
Moby Project
Moby Project https://mobyproject.org/
What is Moby? Moby is an open framework created by Docker to assemble specialized container systems without reinventing the wheel. It provides a “lego set” of dozens of standard components and a framework for assembling them into custom platforms.