> docker run --rm -ti -v C:\Users\user\work:/work alpine
# unix-like path
> docker run --rm -ti -v /c/Users/user/work:/work alpine ls /work
# gitbash
> docker run --rm -ti -v C:\\Users\\user\\work:/work alpine
# -- to identify the errors are generated from your script or not --
> MSYS_NO_PATHCONV=1 docker run --rm -ti -v $(pwd):/work alpine ls /work
[#65: [PROXY] Cannot find path 'C:[..]\DockerMsftProvider\DockerDefault_DockerSearchIndex.json' because it does not exist.](https://github.com/OneGet/MicrosoftDockerProvider/issues/65)
As of May 23rd 2023 the backing service for this provider has been shutdown. You can find alternative options at [Windows Container Documentation - Setup Environment](https://learn.microsoft.com/en-us/virtualization/windowscontainers/quick-start/set-up-environment?tabs=dockerce#windows-server-1). For more information on the deprecation please see the following blog posts: [Updates to the Windows Container Runtime support](https://techcommunity.microsoft.com/t5/containers/updates-to-the-windows-container-runtime-support/ba-p/2788799) [Reminder - Updates to Windows Container Runtime Support](https://techcommunity.microsoft.com/t5/containers/reminder-updates-to-windows-container-runtime-support/ba-p/3620989)
> Find-Package -Name docker -ProviderName DockerMsftProvider -Proxy http://squid.tls.renault.fr:911 -Verbose
VERBOSE: Using the provider 'DockerMsftProvider' for searching packages.
VERBOSE: Download size: 0.02MB
VERBOSE: Free space on the drive: 199788.78MB
VERBOSE: Downloading https://dockermsft.blob.core.windows.net/dockercontainer/DockerMsftIndex.json to C:\Users\Administrator\AppData\Local\Temp\DockerMsftProvider\DockerDefault_DockerSearchIndex.json
VERBOSE: About to download
VERBOSE: Finished downloading
VERBOSE: Downloaded in 0 hours, 0 minutes, 0 seconds.
Name Version Source Summary
---- ------- ------ -------
Docker 19.03.1 DockerDefault Contains Docker EE for use with Windows Server.
check module and resource
> Get-PackageSource -ProviderName DockerMsftProvider
Name ProviderName IsTrusted Location
---- ------------ --------- --------
DockerDefault DockerMsftPro... False https://go.microsoft.com/fwlink/?LinkID=825636&clcid=0x409
> Get-Package -Name Docker -ProviderName DockerMsftProvider
Name Version Source ProviderName
---- ------- ------ ------------
docker 20.10.9 DockerDefault DockerMsftProvider
# info: C:\Program Files\WindowsPowerShell\Modules\DockerMsftProvider\1.0.0.8
> Get-InstalledModule -Name "DockerMsftProvider"
Version Name Repository Description
------- ---- ---------- -----------
1.0.0.8 DockerMsftProvider PSGallery PowerShell module with commands fo...
update DockerMsftProvider
> Update-Module DockerMsftProvider
upgrade to latest version
> Install-Package -Name Docker -ProviderName DockerMsftProvider -Update -Force
Name Version Source Summary
---- ------- ------ -------
Docker 20.10.9 DockerDefault Contains Docker EE for use with Windows Server.
> Get-Package -Name Docker -ProviderName DockerMsftProvider
Name Version Source ProviderName
---- ------- ------ ------------
docker 20.10.9 DockerDefault DockerMsftProvider
> docker --version
Docker version 20.10.9, build 591094d
> Start-Service Docker
# On an online machine, download the zip file.
> Invoke-WebRequest -UseBasicParsing -OutFile docker-19.03.3.zip https://download.docker.com/components/engine/windows-server/19.03/docker-19.03.3.zip
# Stop Docker service if eralier version of Docker is already installed
> Stop-Service docker
# Extract the archive.
> Expand-Archive docker-19.03.3.zip -DestinationPath $Env:ProgramFiles -Force
# Clean up the zip file.
> Remove-Item -Force docker-19.03.3.zip
# Install Docker. This requires rebooting.
> $null = Install-WindowsFeature containers
> Restart-Computer -Force
# Add Docker to the path for the current session.
> $env:path += ';$env:ProgramFiles\docker'
# Optionally, modify PATH to persist across sessions.
> $newPath = '$env:ProgramFiles\docker;' +
[Environment]::GetEnvironmentVariable('PATH', [EnvironmentVariableTarget]::Machine)
[Environment]::SetEnvironmentVariable('PATH', $newPath, [EnvironmentVariableTarget]::Machine)
# Register the Docker daemon as a service.
> dockerd --register-service
# Start the Docker service.
> Start-Service docker
# verify
> docker pull hello-world:nanoserver
> docker images
> docker container run hello-world:nanoserver
pull and run windows image
> docker pull mcr.microsoft.com/dotnet/samples:dotnetapp-nanoserver-2009
> docker run mcr.microsoft.com/dotnet/samples:dotnetapp-nanoserver-2009
# or
> docker pull mcr.microsoft.com/windows/servercore:ltsc2019
# inspired from http://man.hubwiz.com/docset/Docker.docset/Contents/Resources/Documents/docs.docker.com/install/windows/docker-ee.html
# On an online machine, download the zip file.
Invoke-WebRequest -UseBasicParsing -OutFile docker-18.09.5.zip https://download.docker.com/components/engine/windows-server/18.09/docker-18.09.5.zip
# Stop Docker service
Stop-Service docker
# Extract the archive.
Expand-Archive docker-18.09.5.zip -DestinationPath $Env:ProgramFiles -Force
# Clean up the zip file.
Remove-Item -Force docker-18.09.5.zip
# Install Docker. This requires rebooting.
$null = Install-WindowsFeature containers
# Add Docker to the path for the current session.
$env:path += ";$env:ProgramFiles\docker"
# Optionally, modify PATH to persist across sessions.
$newPath = "$env:ProgramFiles\docker;" +
[Environment]::GetEnvironmentVariable("PATH",
[EnvironmentVariableTarget]::Machine)
[Environment]::SetEnvironmentVariable("PATH", $newPath,
[EnvironmentVariableTarget]::Machine)
# Register the Docker daemon as a service.
dockerd --register-service
# Start the Docker service.
Start-Service docker
> docker info
...
Docker Root Dir: E:\docker_home
...
WARNING: API is accessible on http://0.0.0.0:2376 without encryption.
Access to the remote API is equivalent to root access on the host. Refer
to the 'Docker daemon attack surface' section in the documentation for
more information: https://docs.docker.com/go/attack-surface/
> docker -H tcp://localhost:2376 images
REPOSITORY TAG IMAGE ID CREATED SIZE
hello-world nanoserver e33d37034c87 33 hours ago 258MB
Windows Server Core and Nanoserver are the most common base images to target. The key difference between these images is that Nanoserver has a significantly smaller API surface. PowerShell, WMI, and the Windows servicing stack are absent from the Nanoserver image.
# On an online machine, download the zip file.
Invoke-WebRequest -UseBasicParsing -OutFile docker-19.03.3.zip https://download.docker.com/components/engine/windows-server/19.03/docker-19.03.3.zip
install
# Stop Docker service if eralier version of Docker is already installed
> Stop-Service docker
# Extract the archive.
> Expand-Archive docker-19.03.3.zip -DestinationPath $Env:ProgramFiles -Force
# Clean up the zip file.
> Remove-Item -Force docker-19.03.3.zip
# Install Docker. This requires rebooting.
> $null = Install-WindowsFeature containers
> Restart-Computer -Force
# Add Docker to the path for the current session.
> $env:path += ';$env:ProgramFiles\docker'
# Optionally, modify PATH to persist across sessions.
> $newPath = '$env:ProgramFiles\docker;' +
[Environment]::GetEnvironmentVariable('PATH', [EnvironmentVariableTarget]::Machine)
[Environment]::SetEnvironmentVariable('PATH', $newPath, [EnvironmentVariableTarget]::Machine)
# Register the Docker daemon as a service.
> dockerd --register-service
# Start the Docker service.
> Start-Service docker
# Sample Dockerfile
# Indicates that the windowsservercore image will be used as the base image.
FROM mcr.microsoft.com/windows/servercore:ltsc2019
# Metadata indicating an image maintainer.
LABEL maintainer="jshelton@contoso.com"
# Uses dism.exe to install the IIS role.
RUN dism.exe /online /enable-feature /all /featurename:iis-webserver /NoRestart
# Creates an HTML file and adds content to this file.
RUN echo "Hello World - Dockerfile" > c:\inetpub\wwwroot\index.html
# Sets a command or process that will run each time a container is run from the new image.
CMD [ "cmd" ]
sample
FROM mcr.microsoft.com/dotnet/framework/sdk:4.8-windowsservercore-ltsc2019
RUN Install-PackageProvider NuGet -Force
RUN Install-Module -Name DockerMsftProvider -Repository PSGallery -Force
RUN Import-Packageprovider -Name DockerMsftProvider -Force
RUN Find-Package -ProviderName DockerMsftProvider | Install-Package -Verbose -Force; exit 0
RUN Find-Package -ProviderName DockerMsftProvider | Install-Package -Verbose -Force
or
FROM mcr.microsoft.com/windows/servercore:ltsc2019
USER ContainerAdministrator
SHELL ["powershell", "-command"]
RUN Set-ExecutionPolicy -ExecutionPolicy RemoteSigned
RUN [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
RUN Install-PackageProvider -Name NuGet -Force
RUN Install-Module -Name DockerMsftProvider -Force
RUN Import-Module -Name DockerMsftProvider -Force
RUN Import-Packageprovider -Name DockerMsftProvider -Force
RUN Install-Package -Name docker -ProviderName DockerMsftProvider -Verbose -Update -Force
In Server Manager, on the Manage menu, click Add Roles and Features.
On the Before you begin page, verify that your destination server and network environment are prepared for the role and feature you want to install. Click Next.
On the Select installation type page, select Role-based or feature-based installation and then click Next.
On the Select destination server page, select a server from the server pool and then click Next.
On the Select server roles page, select Hyper-V.
To add the tools that you use to create and manage virtual machines, click Add Features. On the Features page, click Next.
On the Create Virtual Switches page, Virtual Machine Migration page, and Default Stores page, select the appropriate options.
On the Confirm installation selections page, select Restart the destination server automatically if required, and then click Install.
When installation is finished, verify that Hyper-V installed correctly. Open the All Servers page in Server Manager and select a server on which you installed Hyper-V. Check the Roles and Features tile on the page for the selected server.
SET DOCKER_CERT_PATH= $null, "User"
SET DOCKER_HOST= $null, "User"
SET DOCKER_MACHINE_NAME= $null, "User"
SET DOCKER_TLS_VERIFY= $null, "User"
SET DOCKER_TOOLBOX_INSTALL_PATH= $null, "User"