Code Monkey home page Code Monkey logo

windows-docker-machine's Introduction

Windows Docker Machine

Build status

This Vagrant environment creates a "Docker Machine" to work on your MacBook with Windows containers. You can easily switch between Docker Desktop Linux containers and the Windows containers.

Docker Context asciinema

Many flavors

There are several versions of Windows Server. This is where you decide which Vagrant VM should be started.

  • 2022-box - Windows Server 2022 (10.0.20348) LTS Channel, prebuilt from Vagrant Cloud
  • 2022 - Windows Server 2022 (10.0.20348) LTS Channel
  • 2019-box - Windows Server 2019 (10.0.17763) LTS Channel, prebuilt from Vagrant Cloud
  • 2019 - Windows Server 2019 (10.0.17763) LTS Channel
  • 1903 - Windows Server, version 1903 (10.0.18362) Semi-Annual Channel
  • 1809 - Windows Server, version 1809 (10.0.17763) Semi-Annual Channel
  • 1803 - Windows Server, version 1803 (10.0.17134) Semi-Annual Channel
  • 2016-box - Windows Server 2016 (10.0.14393) LTS channel, *prebuilt from Vagrant Cloud
  • 2016 - Windows Server 2016 (10.0.14393) LTS channel
  • insider - Windows Server Insider builds
  • lcow - Windows Server, version 1809 with LCOW enabled

So with a vagrant up 2019 you spin up the LTS version, with vagrant up 1903 the 1903 semi-annual version and with vagrant up insider the Insider build.

If you don't want to run the packer step, you can run vagrant up 2019-box or vagrant up 2022-box to get your box image downloaded directly from Vagrant Cloud. That uses the box images windows_2019_docker, respectively windows_2022_docker.

Tested environments

  • macOS with Vagrant 2.2.19
    • VMware Fusion Pro 11.0.3
    • VirtualBox 5.2.26 and 6.1.34
  • Windows with Vagrant 2.2.4
    • VMware Workstation Pro 15.0.3
    • (VirtualBox see issue #2)
    • (Hyper-V see issue #1)

Getting started

First you need a Windows Server VM for your hypervisor. I prefer "Infrastructure as Code", so every build step is available on GitHub.

packer vagrant docker

  1. (optional) packer build to build a Vagrant base box, it's like a Docker image, but for Vagrant VM's.
  2. vagrant up to create a running VM instance of Windows Server, either using the packer build or by using one of the pre-built Vagrant Cloud binaries 2022-box, 2019-box, or 2016-box.
  3. docker run to run Windows containers in that Windows VM

Step 1 (building the headless Vagrant box) can be done with these steps:

$ git clone https://github.com/StefanScherer/packer-windows
$ cd packer-windows

$ packer build --only=vmware-iso windows_2022_docker.json
$ vagrant box add windows_2022_docker windows_2022_docker_vmware.box

- or -

$ packer build --only=vmware-iso windows_2019_docker.json
$ vagrant box add windows_2019_docker windows_2019_docker_vmware.box

- or -

$ packer build --only=vmware-iso --var iso_url=~/path-to-1903.iso windows_server_1903_docker.json
$ vagrant box add windows_server_1903_docker windows_server_1903_docker_vmware.box

- or -

$ packer build --only=vmware-iso --var iso_url=~/path-to-1809.iso windows_server_1809_docker.json
$ vagrant box add windows_server_1809_docker windows_server_1809_docker_vmware.box

- or -

$ packer build --only=vmware-iso --var iso_url=~/path-to-1803.iso windows_server_1803_docker.json
$ vagrant box add windows_server_1803_docker windows_server_1803_docker_vmware.box

- or -

$ packer build --only=vmware-iso --var iso_url=~/path-to-insider.iso windows_server_insider_docker.json
$ vagrant box add windows_server_insider_docker windows_server_insider_vmware_docker.box

- or -

$ packer build --only=vmware-iso --var iso_url=~/path-to-2016.iso windows_2016_docker.json
$ vagrant box add windows_2016_docker windows_2016_docker_vmware.box

Of course you can build only the box version you need. If you are using VirtualBox instead of VMware, swap vmware for virtualbox in the vagrant commands above.

Working on macOS & Linux

Create the Docker Machine

Spin up the headless Vagrant box you created earlier. It will create the TLS certificates and a corresponding Docker context called 2022-box or 2019-box.

$ git clone https://github.com/StefanScherer/windows-docker-machine
$ cd windows-docker-machine
$ vagrant up --provider vmware_desktop 2019-box

- or -

$ vagrant up --provider virtualbox 2019-box

If you want to use Windows Server 2022, type 2022-box here instead.

List your new Docker machine

$ docker context ls
NAME                DESCRIPTION                               DOCKER ENDPOINT               KUBERNETES ENDPOINT                ORCHESTRATOR
2019-box            2019-box windows-docker-machine           tcp://192.168.65.130:2376
default *           Current DOCKER_HOST based configuration   unix:///var/run/docker.sock   https://localhost:6443 (default)   swarm
dummy                                                         tcp://1.2.3.4:2375

Switch to Windows containers

$ docker context use 2019-box

Now your Mac Docker client talks to the Windows Docker engine:

$ docker version
Client: Docker Engine - Community
 Version:           19.03.0-beta1
 API version:       1.39 (downgraded from 1.40)
 Go version:        go1.12.1
 Git commit:        62240a9
 Built:             Thu Apr  4 19:15:32 2019
 OS/Arch:           darwin/amd64
 Experimental:      false

Server: Docker Engine - Enterprise
 Engine:
  Version:          18.09.5
  API version:      1.39 (minimum version 1.24)
  Go version:       go1.10.8
  Git commit:       be4553c277
  Built:            04/11/2019 06:43:04
  OS/Arch:          windows/amd64
  Experimental:     false

Switch back to Docker Desktop

$ docker context use default

This removes all DOCKER environment variables and you can use your Docker for Mac installation.

$ docker version
Client: Docker Engine - Community
 Version:           19.03.0-beta1
 API version:       1.39 (downgraded from 1.40)
 Go version:        go1.12.1
 Git commit:        62240a9
 Built:             Thu Apr  4 19:15:32 2019
 OS/Arch:           darwin/amd64
 Experimental:      false

Server: Docker Engine - Community
 Engine:
  Version:          18.09.2
  API version:      1.39 (minimum version 1.12)
  Go version:       go1.10.6
  Git commit:       6247962
  Built:            Sun Feb 10 04:13:06 2019
  OS/Arch:          linux/amd64
  Experimental:     false

Mounting volumes from your Mac machine

Just use C:$(pwd) to prepend a drive letter.

$ docker run -it -v C:$(pwd):C:$(pwd) mcr.microsoft.com/windows/servercore:1809 powershell

This mounts the current working directory through the Windows VM into the Windows Container.

Accessing published ports of Windows containers

When you run Windows containers with publish ports then you can use the IP address of the Windows Docker host to access it. The docker context command in combination with jq can give your the IP address with a command. Alternatively docker-machine ip also gives you the IP address.

Example: Run the whoami Windows container and open it in the default macOS browser.

$ docker run -d -p 8080:8080 stefanscherer/whoami
$ open http://$(docker context inspect 2019-box | jq -r '.[0].Endpoints.docker.Host | .[6:] | .[:-5]'):8080

- or -

$ open http://$(docker-machine ip 2019-box):8080

Working on Windows

Spin up the headless Vagrant box you created earlier. It will create the TLS certificates and a corresponding Docker context called 2022-box or 2019-box.

If you haven't worked with docker context yet, create the .docker directory in your user profile manually.

PS C:\> mkdir $env:USERPROFILE\.docker

Create the Docker Machine

Choose your hypervisor and start the VM

PS C:\> git clone https://github.com/StefanScherer/windows-docker-machine
PS C:\> cd windows-docker-machine
PS C:\> vagrant up --provider vmware_desktop 2019-box

- or -

PS C:\> vagrant up --provider virtualbox 2019-box

- or -

PS C:\> vagrant up --provider hyperv 2019-box

If you want to use Windows Server 2022, type 2022-box here instead.

Notice: The provider hyperv does mount the volumes with SMB into the Windows Server VM. It seems that there is a problem mounting that further into a Windows container. The provisioning (creating the TLS certs and copying them back to the Windows host) will fail.

List your new Docker machine

PS C:\> docker context ls
NAME                DESCRIPTION                               DOCKER ENDPOINT               KUBERNETES ENDPOINT                ORCHESTRATOR
2019-box            2019-box windows-docker-machine           tcp://192.168.65.130:2376
default *           Current DOCKER_HOST based configuration   unix:///var/run/docker.sock   https://localhost:6443 (default)   swarm

Switch to Windows containers

PS C:\> docker context use 2019-box

Now your Windows Docker client talks to the Windows Docker engine:

PS C:\> docker version
Client: Docker Engine - Community
 Version:           19.03.0-beta1
 API version:       1.39 (downgraded from 1.40)
 Go version:        go1.12.1
 Git commit:        62240a9
 Built:             Thu Apr  4 19:15:32 2019
 OS/Arch:           darwin/amd64
 Experimental:      false

Server: Docker Engine - Enterprise
 Engine:
  Version:          18.09.5
  API version:      1.39 (minimum version 1.24)
  Go version:       go1.10.8
  Git commit:       be4553c277
  Built:            04/11/2019 06:43:04
  OS/Arch:          windows/amd64
  Experimental:     false

Switch to back to Docker for Windows

PS C:\> docker context use default

This removes all DOCKER environment variables and you can use your Docker for Windows installation.

PS C:\> docker version
Client: Docker Engine - Community
 Version:           19.03.0-beta1
 API version:       1.39 (downgraded from 1.40)
 Go version:        go1.12.1
 Git commit:        62240a9
 Built:             Thu Apr  4 19:15:32 2019
 OS/Arch:           darwin/amd64
 Experimental:      false

Server: Docker Engine - Community
 Engine:
  Version:          18.09.2
  API version:      1.39 (minimum version 1.12)
  Go version:       go1.10.6
  Git commit:       6247962
  Built:            Sun Feb 10 04:13:06 2019
  OS/Arch:          linux/amd64
  Experimental:     false

Mounting volumes from your Windows machine

Just use $(pwd) in PowerShell.

PS C:\> docker run -it -v "$(pwd):$(pwd)" mcr.microsoft.com/windows/servercore:1809 powershell

This mounts the current working directory through the Windows VM into the Windows Container.

Accessing published ports of Windows containers

When you run Windows containers with publish ports then you can use the IP address of the Windows Docker host to access it. The docker context inspect command can give your the IP address with a command.

Example: Run the whoami Windows container and open it in the default browser.

PS C:\> docker run -d -p 8080:8080 stefanscherer/whoami
PS C:\> start http://$(docker-machine ip 2019-box):8080

Further commands

Here is a list of vagrant and docker commands for typical actions. I use a bash function dm in my dotfiles repo to simplify all the tasks without switching to the Vagrant folder each time. The dm started as a shortcut for docker-machine commands. I have updated the function to work with docker context, but rolled back for now as I prefer the environment variables to have different "contexts" per terminal tab.

dm shortcut Vagrant / Docker command
dm start 2019-box vagrant up --provider xxx 2019-box
dm regenerate-certs 2019-box vagrant provision 2019-box
dm stop 2019-box vagrant halt 2019-box
dm start 2019-box vagrant up 2019-box
dm rdp 2019-box vagrant rdp 2019-box
dm rm [-f] 2019-box vagrant destroy [-f] 2019-box
dm 2019-box docker context use 2019-box or
eval $(docker-machine env 2019-box)
dm ip 2019-box docker context inspect 2019-box | jq -r '.[0].Endpoints.docker.Host | .[6:] | .[:-5]' or
docker-machine ip 2019-box

Insider builds

If you want to follow the Windows Server Insider builds then this is for you. It is tested on a Mac with the following steps.

  1. Register at Windows Insider program https://insider.windows.com

  2. Download the Windows Server ISO from https://www.microsoft.com/en-us/software-download/windowsinsiderpreviewserver?wa=wsignin1.0

  3. Build the Vagrant basebox with Packer

git clone https://github.com/StefanScherer/packer-windows
cd packer-windows
packer build --only=vmware-iso --var iso_url=~/Downloads/Windows_InsiderPreview_Server_en-us_18356.iso windows_server_insider_docker.json
vagrant box add windows_server_insider_docker windows_server_insider_docker_vmware.box

Then spin up your Insider machine with

vagrant up insider

This Vagrant box has Docker installed and the following base images are already pulled from Docker Hub:

  • mcr.microsoft.com/windows/servercore/insider
  • mcr.microsoft.com/windows/nanoserver/insider

LCOW

You can try the Linux Container on Windows feature in a separate machine lcow. It is preconfigured to use the Windows Server, version 1903. But you can also use Windows Insider Server Preview as base box.

vagrant up lcow
docker context use lcow
docker run alpine uname -a

Cleanup

If you want to cleanup your machine again after playing with Windows Containers, use the following commands

vagrant destroy -f
vagrant box remove StefanScherer/windows_2019_docker
docker context rm 2019-box

windows-docker-machine's People

Contributors

amotl avatar bobbravo2 avatar bormaa avatar jantimon avatar jaraco avatar rorpage avatar stefanscherer avatar tgriek avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

windows-docker-machine's Issues

.dockerignore file not respected on MacOS X (VMware)

First of all thank you for this project, I couldn't have mad this this far without out.

It seems that my .dockeringore file does nothing.

If I run the following command:

docker build -t dynamite .
docker run -it -v C:$(pwd):C:/src -p 8181:8181 dynamite

and I have a local node_modules folder I'll always end up with that folder inside my container.
Is there something special I should be doing instead ?

    Directory: C:\src
Mode                LastWriteTime         Length Name
----                -------------         ------ ----
d-----         6/6/2021   4:35 PM                node_modules

I did setup my windows docker machine with VMware.

Dockerfile:

# escape=`

# Use the latest Windows Server Core image with .NET Framework 4.8.
FROM mcr.microsoft.com/dotnet/framework/sdk:4.8-windowsservercore-ltsc2019

WORKDIR C:/src
EXPOSE 8181

# Restore the default Windows shell for correct batch processing.
SHELL ["cmd", "/S", "/C"]

# Download the Build Tools bootstrapper.
ADD https://aka.ms/vs/16/release/vs_buildtools.exe C:\TEMP\vs_buildtools.exe

# Install Build Tools with the Microsoft.VisualStudio.Workload.AzureBuildTools workload, excluding workloads and components with known issues.
RUN C:\TEMP\vs_buildtools.exe --quiet --wait --norestart --nocache `
    --installPath C:\BuildTools `
    --add Microsoft.VisualStudio.Workload.AzureBuildTools `
    --remove Microsoft.VisualStudio.Component.Windows10SDK.10240 `
    --remove Microsoft.VisualStudio.Component.Windows10SDK.10586 `
    --remove Microsoft.VisualStudio.Component.Windows10SDK.14393 `
    --remove Microsoft.VisualStudio.Component.Windows81SDK `
 || IF "%ERRORLEVEL%"=="3010" EXIT 0

RUN powershell "Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'));`
    mkdir PCFCLI;`
    Register-PackageSource -ProviderName Nuget -Name Nuget -Location https://www.nuget.org/api/v2 -Confirm:$false -Verbose -Force;`
    Install-Package -Name Microsoft.PowerApps.CLI -ProviderName NuGet -Destination ../PCFCLI -Confirm:$false -Verbose -Force;`
    choco install nodejs-lts --force --confirm;`
    choco install yarn --force --confirm;`
    choco install netfx-4.6.2-devpack --force --confirm"
RUN powershell "$path = $env:path + ';' + $(Resolve-Path 'C:\PCFCLI\Microsoft.PowerApps.CLI*\tools' | Select -ExpandProperty Path); `
    Set-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment\' -Name Path -Value $path"

# Define the entry point for the docker container.
# This entry point starts the developer command prompt and launches the PowerShell shell.
ENTRYPOINT ["C:\\BuildTools\\Common7\\Tools\\VsDevCmd.bat", "&&", "powershell.exe", "-NoLogo", "-ExecutionPolicy", "Bypass"]

.dockerignore:

.git
dist
node_modules
yarn-error.log

building via docker-compose

Hi Stefan - ty so much for your contributions -- brilliant!
From a mac ... I have built your packer vm and successfully can build and deploy docker containers to it ... but cannot figure out how to use docker-compose? I have 2 docker contexts, default (regular linux vm) and 2019-box (as created per directions here. If I create a new dockerfile and build, docker build . works fine when docker context is 2019-box. But a docker-compose build that refers to the child Dockerfile fails with the dasterdly "no matching manifest." Seems like an issue with docker-compose not supporting docker context?? I provided my details on https://stackoverflow.com/questions/59911481/docker-no-matching-manifest-for-docker-compose-build-but-docker-build-works-wh/59911623#59911623. Any thoughts on how to use docker-compose to target a windows context from a mac?

packer build reduce disk size

Hi Stefan,

I want to deploy a dev environment for the developers that works in the project. All got mac and this tutorials fits perfectly but I wan to know if there is a way to recue the size of the build of windows server.By the other hand I want to know if there is a change that you caa explain to me the difference of the two container images:

1709 - Windows Server, version 1709 (10.0.16299) Semi annual channel
1803 - Windows Server, version 1803 (10.0.17134) Semi annual channel

There is a way to run in mac only the containers insted off the vm and container?. Sorry if I ask too many thing but I never touch a windows server in my life.

Thanks in advance.

Federico

windows_2016_docker.json: unknown configuration key: "post_shutdown_delay"

when running

packer validate virtualbox-iso windows_2016_docker.json

I get a weird error msg:

Template validation failed. Errors are shown below.

Errors validating build 'virtualbox-iso'. 1 error(s) occurred:

* unknown configuration key: "post_shutdown_delay"

but the cmd is valid and I can't see anything wrong with it.

my version of packer is recent:

packer --version
1.1.2

How to update a box?

Ahoi!

First, thank you for this great project which allows me to easily test windows containers on OSX.

Now my question: I've create a 2019 vm with docker a few months back and played around a bit. Now, I wanted to restart work on it but I'm wondering if there's anything I should and can do to update the box and the docker installation, as a few releases have happened in the meantime.
Please be aware that I'm relatively new to the vagrant/box setup stuff and only understand half of the techniques you use.

Looking forward to your advise!

Licensing

This might be a stupid question, but how does licensing Windows for the VM work here? I installed the prebuilt 2019-box image from Vagrant Cloud on macOS and it seems to be working perfectly, but I was never asked for a license key.

Is this a trial version that will stop working at some point? Or is Windows Server free for local development purposes or something, and it's on users to follow the honor system and purchase a license if they know they need one?

Just a bit confused about whether there's anything I need to do outside of what's in the readme to stay above board (and not have this setup unexpectedly die on me), and Microsoft's website hasn't made things any clearer.

Non windows input encoding

Thank you for the great tool and tutorial! I was able to get up an running very smoothly with mac and VirtualBox.

After running docker run -it microsoft/windowsservercore powershell
I noticed few keyboard problems.

  1. when I'm trying to type non-English characters (Cyrillic) it displayes ??? I.e.
PS C:\> ?^??^????^??^?
  1. If I try to run another powershell instance from it, stdio redirection looks broken and I cannot type in the second one.

stuck on 'vmware-iso: Running'

Hey,

After following up to this stage:

$ git clone https://github.com/StefanScherer/packer-windows
$ cd packer-windows

$ packer build --only=vmware-iso windows_2016_docker.json

It gets to the point where the windows vm displays the cmd with:

Press Ctrl-Alt-Del to unlock

And the packer script repeatedly prints:

==> vmware-iso: Provisioning with powershell script: ./scripts/docker/docker-pull.ps1
    vmware-iso: Installing microsoft/windowsservercore ...
    vmware-iso: Running
    vmware-iso: Running
    vmware-iso: Running
    vmware-iso: Running
    vmware-iso: Running

Any idea on what I could be missing here? It hasn't created the 'windows_2016_docker_vmware.box' file which is why the following command shows an error:

$ vagrant box add windows_2016_docker windows_2016_docker_vmware.box
==> box: Box file was not detected as metadata. Adding it directly...
==> box: Adding box 'windows_2016_docker' (v0) for provider:
    box: Downloading: windows_2016_docker_vmware.box
An error occurred while downloading the remote file. The error
message, if any, is reproduced below. Please fix this error and try
again.

Couldn't open file /Users/name/stackstorm-project/windows-docker/packer-windows/windows_2016_docker_vmware.box

Note: I am using Mac Sierra 10.12.6

Disable Autostart for 2016 and 2016-box

Hey @StefanScherer

I saw that for 2016 and 2016-box the autostart: false is missing:

config.vm.define "2016" do |cfg|
cfg.vm.box = "windows_2016_docker"
cfg.vm.provision "shell", path: "scripts/create-machine.ps1", args: "-machineHome #{home} -machineName 2016"
end
config.vm.define "2016-box" do |cfg|
cfg.vm.box = "StefanScherer/windows_2016_docker"
cfg.vm.provision "shell", path: "scripts/create-machine.ps1", args: "-machineHome #{home} -machineName 2016-box"
end

Was that done on purpose or should I create a PR to fix that?

Volume mount via docker-compose file

I can't for the life of me figure out how to translate the example of mounting a volume from the macOS host to the docker container to work in docker-compose.yml:

docker run -it -v C:$(pwd):C:$(pwd) microsoft/windowsservercore powershell

I get errors pretty much every way I try it in a docker-compose file that I am running via macOS (docker-compose 1.16). Any ideas?

update the base box to work with VirtualBox 6.0

I have just updated VirtualBox to the latest 6.0 and now I cannot run WDM:

> vagrant up --provider virtualbox 2019-box
The provider 'virtualbox' that was requested to back the machine
'2019-box' is reporting that it isn't usable on this system. The
reason is shown below:

Vagrant has detected that you have a version of VirtualBox installed
that is not supported by this version of Vagrant. Please install one of
the supported versions listed below to use Vagrant:

4.0, 4.1, 4.2, 4.3, 5.0, 5.1, 5.2

A Vagrant update may also be available that adds support for the version
you specified. Please check www.vagrantup.com/downloads.html to download
the latest version.

I would like to try out WDM but I don't want to de-upgrade my system... is there a solution?

Support for insecure-registries

Hi Stefan,

first of all I wanted to say that I'm impressed by this project and am using it on a daily basis for cross-platform development. It's really helping a lot! Thanks for the great work so far.

One of the things that I'm missing currently is the support for easily defining insecure-registries within the daemon.json on the windows hosts.

I was able to quickly hack in a solution for me that works but was wondering if that could be something that might be of interest to more people.

what I did so far was simply extending the create-machine.ps1 Powershell script by a single line

  $config = $config | Add-Member(@{ `
    hosts = @("tcp://0.0.0.0:2376", "npipe://"); `
    tlsverify = $true; `
    tlscacert = "$serverCertsPath\ca.pem"; `
    tlscert = "$serverCertsPath\server-cert.pem"; `
    tlskey = "$serverCertsPath\server-key.pem"; `
    "insecure-registries" = @("my.insecure.registry:4567"); `
    experimental = $experimental `
    }) -Force -PassThru

It probably would be great to be able to define this within the Vagrant environment.
I'm not a Powershell nor a Vagrant guru, so sorry for not providing a potential solution already.

Best,
Matthias

access into the docker

Hi
I have created the VM
can someone tell me how do i access into it ?
i can RDP it but i don't have the user/pass even if i create new one inside the vm it's still not working

please advise

Self signed server certificate not meeting RFC 5280

Issue
The current self-signed server certificate does not contain a subject line. Apparently it is not meeting RFC 5280 ยง4.2.1.6 standards according to this post.

This results in some libraries not accepting the certificate as valid.

java.security.cert.CertificateParsingException: X.509 Certificate is incomplete: SubjectAlternativeName extension MUST be marked critical when subject field is empty

Solution
Add a subject line

Subject = "CN=serverCert";

Virtualbox customization --clipboard renamed in version 6.1

The Virtual box --clipboard command was renamed in version 6.1 to --clipboard-mode

The vagrant up command fails with error:

==> 2019-box: Running 'pre-boot' VM customizations...
A customization command failed:

["modifyvm", :id, "--clipboard", "bidirectional"]

The following error was experienced:

#<Vagrant::Errors::VBoxManageError: There was an error while executing VBoxManage, a CLI used by Vagrant
for controlling VirtualBox. The command and stderr is shown below.

Command: ["modifyvm", "", "--clipboard", "bidirectional"]

Stderr: Oracle VM VirtualBox Command Line Management Interface Version 6.1.2
(C) 2005-2020 Oracle Corporation
All rights reserved.

Can't download windows_server_1709

Hi! Could you pls provide some other link for download 1709 version it seems that old one is not valid now?
Thanks in advance.

$ packer build --only=virtualbox-iso windows_server_1709_docker.json
virtualbox-iso output will be in this color.

==> virtualbox-iso: Downloading or copying ISO
    virtualbox-iso: Downloading or copying: https://software-download.microsoft.com/pr/en_windows_server_version_1709_x64_dvd_100090904.iso
    virtualbox-iso: Error downloading: checksums didn't match expected: ca1108d5be2c091bfb57e8f3db3be1e8baa9c32802131f7a6e43e63f7b596591
==> virtualbox-iso: ISO download failed.
Build 'virtualbox-iso' errored: ISO download failed.

==> Some builds didn't complete successfully and had errors:
--> virtualbox-iso: ISO download failed.

==> Builds finished but no artifacts were created.

Compatibility with Cisco AnyConnect.

First of all thankyou for your contributions. I am a lifetime linux developer that is now learning the .NET/c#/Windows world and looking to set up a development environment for building docker stacks of our services in .NET 4.7.2 or lower... This repo is a great help! One question I have is about connecting over VPN to authenticate to the companies network. As soon as i connect to vpn, my host machine does not even recognize a docker deamon running. Do you know how i should go about this?

Cisco AnyConnect Client.

docker doesn't get the ip

Hey,

Am I missing a step potentially? I'm unable to see the ip of my windows docker machine so I can't connect to it or anything:

docker-machine ls
NAME   ACTIVE   DRIVER    STATE     URL   SWARM   DOCKER    ERRORS
2016   *        generic   Running                 Unknown   IP address is not set

When doing vagrant up:

 vagrant up --provider virtualbox 2016-box
Bringing machine '2016-box' up with 'virtualbox' provider...
==> 2016-box: Checking if box 'StefanScherer/windows_2016_docker' is up to date...
==> 2016-box: Clearing any previously set forwarded ports...
==> 2016-box: Clearing any previously set network interfaces...
==> 2016-box: Preparing network interfaces based on configuration...
    2016-box: Adapter 1: nat
    2016-box: Adapter 2: hostonly
==> 2016-box: Forwarding ports...
    2016-box: 3389 (guest) => 3389 (host) (adapter 1)
    2016-box: 5985 (guest) => 55985 (host) (adapter 1)
    2016-box: 5986 (guest) => 55986 (host) (adapter 1)
    2016-box: 22 (guest) => 2222 (host) (adapter 1)
==> 2016-box: Running 'pre-boot' VM customizations...
==> 2016-box: Booting VM...
==> 2016-box: Waiting for machine to boot. This may take a few minutes...
    2016-box: WinRM address: 127.0.0.1:55985
    2016-box: WinRM username: vagrant
    2016-box: WinRM execution_time_limit: PT2H
    2016-box: WinRM transport: negotiate
==> 2016-box: Machine booted and ready!
==> 2016-box: Checking for guest additions in VM...
    2016-box: The guest additions on this VM do not match the installed version of
    2016-box: VirtualBox! In most cases this is fine, but in rare cases it can
    2016-box: prevent things such as shared folders from working properly. If you see
    2016-box: shared folder errors, please make sure the guest additions within the
    2016-box: virtual machine match the version of VirtualBox you have installed on
    2016-box: your host and reload your VM.
    2016-box:
    2016-box: Guest Additions Version: 5.2.4
    2016-box: VirtualBox Version: 5.1
==> 2016-box: Configuring and enabling network interfaces...
==> 2016-box: Mounting shared folders...
    2016-box: /Users/z => /Users/z
==> 2016-box: Machine already provisioned. Run `vagrant provision` or use the `--provision`
==> 2016-box: flag to force provisioning. Provisioners marked to run always will still run.

My Vagrantfile:

# -*- mode: ruby -*-
# vi: set ft=ruby :

VAGRANTFILE_API_VERSION = "2"

Vagrant.require_version ">= 1.8.4"

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
  config.vm.communicator = "winrm"

  config.vm.synced_folder ".", "/vagrant", disabled: true
  home = ENV['HOME'].gsub('\\', '/')
  config.vm.synced_folder home, home

  config.vm.define "2016" do |cfg|
    cfg.vm.box     = "windows_2016_docker"
    cfg.vm.provision "shell", path: "scripts/create-machine.ps1", args: "-machineHome #{home} -machineName 2016"
  end

  config.vm.define "2016-box" do |cfg|
    cfg.vm.box     = "StefanScherer/windows_2016_docker"
    cfg.vm.provision "shell", path: "scripts/create-machine.ps1", args: "-machineHome #{home} -machineName 2016"
  end

  config.vm.define "1709", autostart: false do |cfg|
    cfg.vm.box     = "windows_server_1709_docker"
    cfg.vm.provision "shell", path: "scripts/create-machine.ps1", args: "-machineHome #{home} -machineName 1709"
  end

  config.vm.define "insider", autostart: false do |cfg|
    cfg.vm.box     = "windows_server_insider_docker"
    cfg.vm.provision "shell", path: "scripts/create-machine.ps1", args: "-machineHome #{home} -machineName insider"
  end

  config.vm.define "lcow", autostart: false do |cfg|
    cfg.vm.box     = "windows_server_1709_docker"
    cfg.vm.provision "shell", path: "scripts/create-machine.ps1", args: "-machineHome #{home} -machineName lcow -enableLCOW"
    ["vmware_fusion", "vmware_workstation"].each do |provider|
      config.vm.provider provider do |v, override|
        v.memory = 4096
      end
    end
  end

  ["vmware_fusion", "vmware_workstation"].each do |provider|
    config.vm.provider provider do |v, override|
      v.gui = false
      v.memory = 2048
      v.cpus = 2
      v.enable_vmrun_ip_lookup = false
      v.linked_clone = true
      v.vmx["vhv.enable"] = "TRUE"
      v.ssh_info_public = true
    end
  end

  config.vm.provider "virtualbox" do |v, override|
    v.gui = false
    v.memory = 2048
    v.cpus = 2
    v.linked_clone = true
    override.vm.network :private_network, ip: "192.168.99.90", gateway: "192.168.99.1"
  end

  config.vm.provider "hyperv" do |v|
    v.cpus = 2
    v.maxmemory = 2048
    v.differencing_disk = true
  end
end

Using:

  • Mac Sierra 10.12.6
  • Docker version 17.12.0-ce, build c97c6d6
  • Vagrant 2.0.2

Support for virtualbox 6.1.6

OS: Mac OS Catalina 10.15.4
Virtualbox: 6.1.6
Docker version 19.03.5

Description:
after running vagrant up --provider virtual box 2019-box
and switching the docker context
docker run shows the following error : Cannot connect to the Docker daemon at tcp://192.168.99.90:2376. Is the docker daemon running?.

I tried the following:

  • Change the private ip address in the Vagrant file to 192.168.40.130 this did not work
  • I RDP'd the guest and was able to ping the host
  • Switched off the firewall on the guest and from the guest tried to ping the box didn't work
  • Tried to telnet the box on all ports didn't work
  • Tried to do nmap -nP GUEST that also didn't work

PS: docker-machine ls shows the status 2019-box "Timedout"

I ran out of options so I downgraded to version 5.2.26 and that fixed the issue.

now am having this issue

2019-box   -        generic   Running   tcp://192.168.65.130:2376           Unknown   Unable to query docker version: 400 Bad Request: client version 1.15 is too old. Minimum supported API version is 1.24, please upgrade your client to a newer version

I know that this issue has been addresses moby/moby#28072.

Support kubernetes

Is there a way to support basic kubernetes ? ie similar to the kubernetes tickbox in docker for desktop ?

Thanks.

'docker context ls' does not show '2019-box'

On a Mac, I did
$ git clone https://github.com/StefanScherer/windows-docker-machine
$ cd windows-docker-machine
$ vagrant up --provider virtualbox 2019-box
However 'docker context ls' does not show '2019-box'. It shows only the default one that was there before.

Here is the output of vagrant up
$ vagrant up --provider virtualbox 2019-box
==> vagrant: A new version of Vagrant is available: 2.2.9 (installed version: 2.2.7)!
==> vagrant: To upgrade visit: https://www.vagrantup.com/downloads.html

/opt/vagrant/embedded/gems/2.2.7/gems/vagrant-2.2.7/lib/vagrant/util/which.rb:37: warning: Insecure world writable dir /Volumes/SamsungUSB/work/windows-docker-machine in PATH, mode 040777
Bringing machine '2019-box' up with 'virtualbox' provider...
==> 2019-box: Checking if box 'StefanScherer/windows_2019_docker' version '2020.04.15' is up to date...
==> 2019-box: Clearing any previously set forwarded ports...
==> 2019-box: Clearing any previously set network interfaces...
==> 2019-box: Preparing network interfaces based on configuration...
2019-box: Adapter 1: nat
2019-box: Adapter 2: hostonly
==> 2019-box: Forwarding ports...
2019-box: 3389 (guest) => 3389 (host) (adapter 1)
2019-box: 5985 (guest) => 55985 (host) (adapter 1)
2019-box: 5986 (guest) => 55986 (host) (adapter 1)
2019-box: 22 (guest) => 2222 (host) (adapter 1)
==> 2019-box: Running 'pre-boot' VM customizations...
==> 2019-box: Booting VM...
==> 2019-box: Waiting for machine to boot. This may take a few minutes...
2019-box: WinRM address: 127.0.0.1:55985
2019-box: WinRM username: vagrant
2019-box: WinRM execution_time_limit: PT2H
2019-box: WinRM transport: negotiate
==> 2019-box: Machine booted and ready!
==> 2019-box: Checking for guest additions in VM...
2019-box: The guest additions on this VM do not match the installed version of
2019-box: VirtualBox! In most cases this is fine, but in rare cases it can
2019-box: prevent things such as shared folders from working properly. If you see
2019-box: shared folder errors, please make sure the guest additions within the
2019-box: virtual machine match the version of VirtualBox you have installed on
2019-box: your host and reload your VM.
2019-box:
2019-box: Guest Additions Version: 6.1.4
2019-box: VirtualBox Version: 5.2
==> 2019-box: Configuring and enabling network interfaces...
==> 2019-box: Mounting shared folders...
2019-box: /Users/ajoseph => /Users/ajoseph
==> 2019-box: Machine already provisioned. Run vagrant provision or use the --provision
==> 2019-box: flag to force provisioning. Provisioners marked to run always will still run.

Problem with hyperv provider and synced_folder

Running the Vagrant box from a Windows 10 host with Hyper-V shows the following error:

bildschirmfoto 2017-01-14 um 22 30 29

The Vagrant box mounts the current user directory into the Windows 2016 VM through SMB.
It seems that this kind of mount can't be mapped into a Windows container as the docker engine complains with Access denied.

Creating two windows-docker-machine instances destroys docker

If you run two windows-docker-machine instances in parallel the second provisioning will destroy docker.

Any try to run docker (e.g. docker --help) will break with the following error:

parse "tcp://192.168.99.90 169.254.170.177:2376": invalid character " " in host name

The only way to repair docker is to remove the currentContext entry from ~/.docker/config.json.

The reason is that windows-docker-machine will create the following docker context meta.json:

{
  "Name": "2019-box",
  "Metadata": {
    "Description": "2019-box windows-docker-machine"
  },
  "Endpoints": {
    "docker": {
      "Host": "tcp://192.168.99.90 169.254.170.177:2376",
      "SkipTLSVerify": false
    }
  }
}

As you can see the Endpoints.docker.Host includes a space.
My assumption is that the following code detects 2 ip addresses:

if (!$machineIp) {
$machineIp=(Get-NetIPAddress -AddressFamily IPv4 `
| Where-Object -FilterScript { `
( ! ($_.InterfaceAlias).StartsWith("vEthernet (") ) `
-And $_.IPAddress -Ne "127.0.0.1" `
-And $_.IPAddress -Ne "10.0.2.15" `
}).IPAddress
} else {
$ipAddresses = "$ipAddresses,$machineIp"
}

Support for virtualbox 6.1.6

OS: Mac OS Catalina 10.15.4
Virtualbox: 6.1.6

Description:
after running vagrant up --provider virtualbox 2019-box
and switching the docker context
docker run shows the following error : Cannot connect to the Docker daemon at tcp://192.168.99.90:2376. Is the docker daemon running?.

I tried the following:

  • Change the private ip address in the Vagrantfile to 192.168.40.130 this did not work
  • I RDP'd the guest and was able to ping the host
  • Switched off the firewall on the guest and from the guest tried to ping the box didn't work
  • Tried to telnet the box on all ports didn't work
  • Tried to do nmap -nP GUEST that also didn't work

PS: docker-machine ls shows the status 2019-box "Timedout"

I ran out of options so I downgraded to version 5.2.26 and that fixed the issue.

now am having this issue

2019-box   -        generic   Running   tcp://192.168.65.130:2376           Unknown   Unable to query docker version: 400 Bad Request: client version 1.15 is too old. Minimum supported API version is 1.24, please upgrade your client to a newer version

I will try to upgrade as per the error see what that gets me and probably do a pull request.

Having trouble adding box added after using vagrant

Based on the instructions, I have cloned the packer-windows repository and ran the commands:

vagrant box add windows_2019_docker windows_2019_docker_virtualbox.box --force

However, when navigating to the windows-docker-machine and attempting to run "vagrant up --provider virtualbox_dekstop windows_2019_docker", I get an error that machine does not exist for this environment.

Furthermore, when working a bit further, i went back to packer-windows folder, and ran "vagrant init windows_2019_docker" to add to the vagrantfile (maybe wrong repo), but when I instatiate it, i still do not see it under "docker context ls" command.

Instructions need some clarification for sure.

"IP address not set" if --provider virtualbox is not given

I see:

opts.on("--provider PROVIDER", String, "") do |provider|

This means that if you don't explicitly pass --provider virtualbox to vagrant up, the Docker machine will show "IP address not set" and can't be communicated with, even if the default provider is VirtualBox and everything else otherwise completes successfully. Can you detect the provider that is actually used instead?

File not found

I try to install a Windows Docker machine and I get the following output

Rs-MacBook-Pro:packer-windows rebeccaannburton$ ./build_windows_2016_docker.sh
vmware-iso output will be in this color.

==> vmware-iso: Downloading or copying ISO
    vmware-iso: Downloading or copying: file:///Users/rebeccaannburton/projects/packer-windows/iso/en_windows_server_2016_updated_feb_2018_x64_dvd_11636692.iso
==> vmware-iso: Creating floppy disk...
    vmware-iso: Copying files flatly from floppy_files
    vmware-iso: Copying file: ./answer_files/2016/Autounattend.xml
    vmware-iso: Copying file: ./scripts/disable-screensaver.ps1
    vmware-iso: Copying file: ./scripts/disable-winrm.ps1
    vmware-iso: Copying file: ./scripts/docker/enable-winrm.ps1
    vmware-iso: Copying file: ./scripts/docker/2016/install-containers-feature.ps1
    vmware-iso: Copying file: ./scripts/microsoft-updates.bat
    vmware-iso: Copying file: ./scripts/win-updates.ps1
    vmware-iso: Done copying files from floppy_files
    vmware-iso: Collecting paths from floppy_dirs
    vmware-iso: Resulting paths from floppy_dirs : []
    vmware-iso: Done copying paths from floppy_dirs
==> vmware-iso: Creating virtual machine disk
==> vmware-iso: Building and writing VMX file
==> vmware-iso: Starting virtual machine...

I also get a dialog box that says 'File not found'
screen shot 2018-03-24 at 4 53 38 pm
The script I am using looks like:

packer build \
  --only=vmware-iso \
  --var vhv_enable=true \
  --var iso_url=./iso/en_windows_server_2016_updated_feb_2018_x64_dvd_11636692.iso \
  --var iso_checksum=7ADC82E00F1367B43897BB969A75BBF96D46F588  \
  --var iso_checksum_type=sha1 \
  --var autounattend=./answer_files/2016/Autounattend.xml \
  windows_2016_docker.json

I also get
screen shot 2018-03-24 at 5 34 29 pm

I am using Fusion 10.1.1. Any idea what is wrong?

macOS - Waiting for WinRM to become available

Setup:

Vagrant: v2.0.0
Packer: v1.1.1
Virtualbox: v5.2.0

Procedure:
I attempted to follow the substeps of Step 1, and got as far as packer build --only=virtualbox-iso windows_2016_docker.json.

From there, a VM was created, windows was installed from the downloaded iso, and the installed Windows Guest OS appeared to log into a user called "Vagrant" and run a lot of startup scripts. It gets as far as the "Checking Windows Updates" script and does not seem to finish. On the macOS side, the script continues to hang at the "Waiting for WinRM to become available...", meaning I can't input the final vagrant box add... command.

I'm assuming I screwed something up, but I can't see where that might be the case. Perhaps the new major version of Vagrant isn't playing nicely with the install? Any help would be really appreciated, thank you!

Update:
I downgraded to Vagrant 1.9.2 and I'm no longer seeing a script that hangs without end, it looks like it actually makes progress downloading the updates.

Does not work with latest Insider (17650) builds

Attempted to run packer-windows with Windows Server LTS (17650) and the checksums don't make. Could not find a matching checksum in any of the .json files within packer-windows. Doesn't appear older Insider builds are available from the download site, either:

broot-mac:packer-windows broot$ packer build --only=vmware-iso windows_2019_docker.json
vmware-iso output will be in this color.

==> vmware-iso: Downloading or copying ISO
vmware-iso: Downloading or copying: https://software-download.microsoft.com/db/Windows_InsiderPreview_Server_vNext_en-us_17639.iso
vmware-iso: Error downloading: checksums didn't match expected: ab5a4980d4a7b8e9028124aef7b2a01ed85b3e32762d8bf15ed21b991f63db6f
==> vmware-iso: ISO download failed.
Build 'vmware-iso' errored: ISO download failed.

Document the step to remove it

Hi,

Thanks for your tutorial, it works great! I'd like to know how to decommission it if I don't need it anymore, and free up space.

Would be awesome to have some instructions for that in the README.md.

Thanks!

windows_2019_docker packer build fails on Mac Big sur.

The following is my configuration:

Os Big Sur

sw_vers
ProductName:	macOS
ProductVersion:	11.2.3
BuildVersion:	20D91
packer --version
1.72.

VirtualBox

vboxmanage --version
6.1.18r142142

when I'm running the command

packer build --only=virtualbox-iso windows_2019_docker.json

The following are the logs including the errors that don't allow me to build the box.

virtualbox-iso: SUCCESS: The file (or folder): "C:\Windows\System32\MusNotificationUx.exe" now owned by user "VAGRANT-2019\vagrant".
    virtualbox-iso: processed file: C:\Windows\System32\MusNotificationUx.exe
    virtualbox-iso: Successfully processed 1 files; Failed processing 0 files
==> virtualbox-iso: At C:\Windows\Temp\script-606e298a-efa2-6059-d1af-6af1dd7a79b1.ps1:22 char:5
==> virtualbox-iso: +     Uninstall-WindowsFeature Windows-Defender-Features
==> virtualbox-iso: +     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
==> virtualbox-iso:     + CategoryInfo          : InvalidArgument: (Windows-Defender-Features:String) [Uninstall-WindowsFeature], Exceptio
==> virtualbox-iso:    n
==> virtualbox-iso:     + FullyQualifiedErrorId : NameDoesNotExist,Microsoft.Windows.ServerManager.Commands.RemoveWindowsFeatureCommand
==> virtualbox-iso: Provisioning with powershell script: ./scripts/docker/set-winrm-automatic.ps1
    virtualbox-iso: [SC] ChangeServiceConfig SUCCESS
==> virtualbox-iso: Restarting Machine
==> virtualbox-iso: Waiting for machine to restart...
==> virtualbox-iso: A system shutdown is in progress.(1115)
    virtualbox-iso: vagrant-2019 restarted.
==> virtualbox-iso: Machine successfully restarted, moving on
==> virtualbox-iso: Provisioning with Powershell...
==> virtualbox-iso: Provisioning with powershell script: ./scripts/docker/add-docker-group.ps1
    virtualbox-iso: Creating
    virtualbox-iso: group
    virtualbox-iso: docker
    virtualbox-iso: The command completed successfully.
    virtualbox-iso:
    virtualbox-iso: Adding
    virtualbox-iso: user
    virtualbox-iso: vagrant
    virtualbox-iso: to
    virtualbox-iso: group
    virtualbox-iso: docker
    virtualbox-iso: The command completed successfully.
    virtualbox-iso:
==> virtualbox-iso: Provisioning with powershell script: ./scripts/docker/install-docker.ps1
    virtualbox-iso: Use get.mirantis.com/install.ps1 ...
    virtualbox-iso: Starting docker ...
==> virtualbox-iso: .\$env:TEMP\install.ps1 : The term '.\$env:TEMP\install.ps1' is not recognized as the name of a cmdlet, function,
==> virtualbox-iso: script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is
==> virtualbox-iso: correct and try again.
==> virtualbox-iso: At C:\Windows\Temp\script-606e298a-a2a7-a5cb-3906-4d16c53324b3.ps1:37 char:3
==> virtualbox-iso: +   .\$env:TEMP\install.ps1
==> virtualbox-iso: +   ~~~~~~~~~~~~~~~~~~~~~~~
==> virtualbox-iso:     + CategoryInfo          : ObjectNotFound: (.\$env:TEMP\install.ps1:String) [], CommandNotFoundException
==> virtualbox-iso:     + FullyQualifiedErrorId : CommandNotFoundException
==> virtualbox-iso:
==> virtualbox-iso: Start-Service : Cannot find any service with service name 'docker'.
==> virtualbox-iso: At C:\Windows\Temp\script-606e298a-a2a7-a5cb-3906-4d16c53324b3.ps1:43 char:1
==> virtualbox-iso: + Start-Service docker
==> virtualbox-iso: + ~~~~~~~~~~~~~~~~~~~~
==> virtualbox-iso:     + CategoryInfo          : ObjectNotFound: (docker:String) [Start-Service], ServiceCommandException
==> virtualbox-iso:     + FullyQualifiedErrorId : NoServiceFoundForGivenName,Microsoft.PowerShell.Commands.StartServiceCommand
==> virtualbox-iso:
==> virtualbox-iso: Provisioning step had errors: Running the cleanup provisioner, if present...
==> virtualbox-iso: Cleaning up floppy disk...
==> virtualbox-iso: Deregistering and deleting VM...
==> virtualbox-iso: Deleting output directory...
Build 'virtualbox-iso' errored after 28 minutes 50 seconds: Script exited with non-zero exit status: 1.Allowed exit codes are: [0]

How can I fix it?

docker: failed to register layer: re-exec error: exit status 1

I don't know for sure that this is a window-docker-machine issue, but I'd โค๏ธ if someone could at least repro so I know I'm not doing anything silly.

I followed the Working on macOS
steps using --provider virtualbox 2019-box.

Everything worked great, until I tried to docker run -it python:3.4.3, which fails with:

$ docker run -it python:3.4.3
Unable to find image 'python:3.4.3' locally
3.4.3: Pulling from library/python
Image docker.io/library/python:3.4.3 uses outdated schema1 manifest format. Please upgrade to a schema2 image for better future compatibility. More information at https://docs.docker.com/registry/spec/deprecated-schema-v1/
d4bce7fd68df: Extracting [==================================================>]  51.35MB/51.35MB
a3ed95caeb02: Download complete 
816152842605: Download complete 
5dcab2c7e430: Download complete 
dc54ada22a60: Download complete 
b7b0de78f891: Download complete 
5fced8d9b8b6: Download complete 
399de0505080: Download complete 
c0a4224a41f8: Download complete 
docker: failed to register layer: re-exec error: exit status 1: output: Failed to safefile.OpenRelative failed in Win32: open \\?\C:\ProgramData\docker\windowsfilter\b86205e5963a71bf94a96a08094b50846f138f3ed7afc7811361306a7c478665\usr\share\man\man3\Locale::gettext.3pm.gz: path contains invalid character `:` (0x1f) usr\share\man\man3\Locale::gettext.3pm.gz.
See 'docker run --help'.

I'm going to give it a spin with 2016-box, and will report back.

Edit: Confirmed same error with 2016-box.

[question] switchDaemon to linux

Hi, thanks for these vm's! They are awesome ๐Ÿ’ฅ

I have question though :)

Is it possible to easily switch the daemon to run linux on the windows docker host?

Documentation needs to be updated for 2019

First of all, thanks for the great project! :)

I have attempted the "easy way" and used pre-packaged 2019-box machine instead of building one.

I have found that the default images like the one mentioned in the README did not work:

$ docker run -it -v C:$(pwd):C:$(pwd) microsoft/windowsservercore powershell docker: Error response from daemon: CreateComputeSystem 3688a0c2b55fe5cc3c7a121138d6c711eba35e94d7fa312726971436ad5ee056: The container operating system does not match the host operating system. (extra info: {"SystemType":"Container","Name":"3688a0c2b55fe5cc3c7a121138d6c711eba35e94d7fa312726971436ad5ee056","Owner":"docker","VolumePath":"\\\\?\\Volume{4fea9bc8-62b4-4c5e-a62f-a8cb29ca9372}","IgnoreFlushesDuringBoot":true,"LayerFolderPath":"C:\\ProgramData\\docker\\windowsfilter\\3688a0c2b55fe5cc3c7a121138d6c711eba35e94d7fa312726971436ad5ee056","Layers":[{"ID":"4560e28f-cce3-5587-88e4-b1d5fb26663d","Path":"C:\\ProgramData\\docker\\windowsfilter\\a1d31746d217a068e9563635b64f103371010f686058699170fce7ccfc916b59"},{"ID":"2e7685ca-6a6a-5cbc-baf8-276a9a626d89","Path":"C:\\ProgramData\\docker\\windowsfilter\\afda31f2bcb3d86680cdadd4b662f0b6954a83f6354d165c2f1d55afe1bc8556"}],"HostName":"3688a0c2b55f","MappedDirectories":[{"HostPath":"c:\\users\\nik\\git\\windows-docker\\windows-docker-machine","ContainerPath":"c:\\users\\nik\\git\\windows-docker\\windows-docker-machine","ReadOnly":false,"BandwidthMaximum":0,"IOPSMaximum":0,"CreateInUtilityVM":false}],"HvPartition":false,"EndpointList":["B6B9B423-FF98-4005-B6E8-9D8F1F99F1D7"],"AllowUnqualifiedDNSQuery":true}).

However, everything is fine with the machine:

$ docker version
Client: Docker Engine - Community
 Version:           18.09.0
 API version:       1.39
 Go version:        go1.10.4
 Git commit:        4d60db4
 Built:             Wed Nov  7 00:47:43 2018
 OS/Arch:           darwin/amd64
 Experimental:      false

Server:
 Engine:
  Version:          18.09.2
  API version:      1.39 (minimum version 1.15)
  Go version:       go1.10.6
  Git commit:       1ac774dfdd
  Built:            02/10/2019 04:13:25
  OS/Arch:          windows/amd64
  Experimental:     false

And your test "whoami" image worked fine too.

It seems that with 2019 windows one has to use more recent base images. I went to https://docs.microsoft.com/en-us/virtualization/windowscontainers/deploy-containers/deploy-containers-on-server and then attempted to use "mcr.microsoft.com/windows/servercore:ltsc2019" image - and it worked fine. Same for "mcr.microsoft.com/windows/nanoserver:1809".

Maybe the docs could be updated to reflect this incompatibility?

how to docker cp recursive?

How do I copy files recursively to the docker?

I'm able to copy a single file with

docker cp ../powershell_kernel/powershell_kernel/kernel.py epic_gates:\\Python27\\Lib\\site-packages\\powershell_kernel\\kernel.py

But

docker cp ../powershell_kernel/powershell_kernel epic_gates:\\Python27\\Lib\\site-packages\\powershell_kernel

Doesn't have effect and no error messages.

Googling suggests that it was a problem on old docker versions, but I'm using a new one from edge channel, so should not be old.

Apple Silicon Support

Hi,

Both Parallel and VMWare now support M1 chips. Is it possible for windows-docker-machine to work on M1 machines?

โžœ  ~ docker version
Client:
 Cloud integration: v1.0.22
 Version:           20.10.11
 API version:       1.41
 Go version:        go1.16.10
 Git commit:        dea9396
 Built:             Thu Nov 18 00:36:09 2021
 OS/Arch:           darwin/arm64
 Context:           default
 Experimental:      true

Server: Docker Engine - Community
 Engine:
  Version:          20.10.11
  API version:      1.41 (minimum version 1.12)
  Go version:       go1.16.9
  Git commit:       847da18
  Built:            Thu Nov 18 00:34:44 2021
  OS/Arch:          linux/arm64
  Experimental:     false
 containerd:
  Version:          1.4.12
  GitCommit:        7b11cfaabd73bb80907dd23182b9347b4245eb5d
 runc:
  Version:          1.0.2
  GitCommit:        v1.0.2-0-g52b36a2
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

VirtualBox doesn't allow 192.168.99.0 subnet by default

In VB #20626, I learned that with the release of VirtualBox 6.1.28 dropped support for host-only IP ranges outside of 192.168.56.0/21 (more details here).

The windows-docker-machine uses 192.168.99.90, outside the default allowed range.

Due to other issues on macOS Monterey, it's not possible to downgrade Virtualbox, so the only available workaround seems to be to edit the allowed ranges by creating/amending /etc/vbox/networks.conf to add something like:

* 192.168.99.0/24 192.168.56.0/21

It would be nice if the machine/Vagrantfile could use an address that falls into the allowed ranges such that it works out of the box.

IP address is not set

Everything use to wrok fine, until I accidentally removed a VM vhd.
This time I decided to install the prebuilt image from vagrant up 2016-box, instead of building it with paker myself.

Now I'm getting IP address is not set on any docker-machinecommand.

vors@Sergeis-MacBook:~/dev/windows-docker-machine$ docker-machine ls
NAME       ACTIVE   DRIVER       STATE     URL   SWARM   DOCKER    ERRORS
2016-box   *        generic      Running                 Unknown   IP address is not set
default    -        virtualbox   Stopped                 Unknown 

I tried re-create it, restart it.

'not enough space on the disk' error on pulling large image

I am on Mac and I am on the 2019-box and I switched my docker context to it. Now I want to pull a large image:

docker pull stabletec/build-core:windows-msvc

But it fails with a disk space error:

windows-msvc: Pulling from stabletec/build-core
65014b3c3121: Already exists
266cffe9d908: Already exists
d8f0e6ed0eb7: Pull complete
d4ef2088e7d6: Pull complete
4c7b07939733: Pull complete
2ecd3ecc40b4: Pull complete
86ba088da90c: Pull complete
014b1ef479aa: Pull complete
555c96118075: Extracting [==================================================>]  1.579GB/1.579GB
b237ad222d9e: Download complete
7b00c157abc5: Download complete
fde9c418b037: Download complete
443d69f9e5f9: Download complete
failed to register layer: re-exec error: exit status 1: output: time="2019-07-09T14:16:21-07:00" level=error msg="hcsshim::ImportLayer failed in Win32: There is not enough space on the disk. (0x70) path=\\\\?\\C:\\ProgramData\\docker\\windowsfilter\\1d1f81b5c26269532b49444b6c0e82a5d0dbe148c864781ee01ddf5eb0fb868d folder=C:\\ProgramData\\docker\\tmp\\hcs754397167"
hcsshim::ImportLayer failed in Win32: There is not enough space on the disk. (0x70) path=\\?\C:\ProgramData\docker\windowsfilter\1d1f81b5c26269532b49444b6c0e82a5d0dbe148c864781ee01ddf5eb0fb868d folder=C:\ProgramData\docker\tmp\hcs754397167

I already expanded the Disk image size in the Docker Desktop preferences to 128 GB. Is there anything else I can do?

Thanks!

BTW: Cool project!!

vagrant up on Mac OS fails: "VBoxManage: error: Unknown option: --nested-hw-virt"

The command

vagrant up --provider virtualbox 2019-box

fails on Mac OS with

==> 2019-box: Running 'pre-boot' VM customizations...
A customization command failed:

["modifyvm", :id, "--nested-hw-virt", "on"]

The following error was experienced:

#<Vagrant::Errors::VBoxManageError: There was an error while executing `VBoxManage`, a CLI used by Vagrant
for controlling VirtualBox. The command and stderr is shown below.

Command: ["modifyvm", "1ffcd621-b990-4112-8942-2e4d03590e71", "--nested-hw-virt", "on"]

Stderr: Oracle VM VirtualBox Command Line Management Interface Version 5.2.22
(C) 2005-2018 Oracle Corporation
All rights reserved.

Workaround
Comment out this line in VagrantFile

    v.customize ["modifyvm", :id, "--nested-hw-virt", "on"]

Windows Server 2016 (virtualbox): Start-Service docker fails on privisioning

Docker Engine failed to start as a service during provisioning:

Bringing machine '2016' up with 'virtualbox' provider...
==> 2016: Clearing any previously set forwarded ports...
==> 2016: Clearing any previously set network interfaces...
==> 2016: Preparing network interfaces based on configuration...
    2016: Adapter 1: nat
    2016: Adapter 2: hostonly
==> 2016: Forwarding ports...
    2016: 3389 (guest) => 3389 (host) (adapter 1)
    2016: 5985 (guest) => 55985 (host) (adapter 1)
    2016: 5986 (guest) => 55986 (host) (adapter 1)
    2016: 22 (guest) => 2222 (host) (adapter 1)
==> 2016: Running 'pre-boot' VM customizations...
==> 2016: Booting VM...
==> 2016: Waiting for machine to boot. This may take a few minutes...
    2016: WinRM address: 127.0.0.1:55985
    2016: WinRM username: vagrant
    2016: WinRM execution_time_limit: PT2H
    2016: WinRM transport: negotiate
==> 2016: Machine booted and ready!
==> 2016: Checking for guest additions in VM...
==> 2016: Configuring and enabling network interfaces...
==> 2016: Mounting shared folders...
    2016: /Users/nolte => /Users/nolte
==> 2016: Running provisioner: shell...
    2016: Running: scripts/create-machine.ps1 as c:\tmp\vagrant-shell.ps1
    2016: === Generating CA
    2016: === Generating CA public key
    2016: === Generating Server certificate
    2016: === Generating Server private key
    2016: === Generating Client certificate
    2016: === Generating Client key
    2016: === Creating / Updating C:\ProgramData\docker\config\daemon.json
    2016: === Creating / Updating C:\Users\vagrant\.docker\machine\machines\2016\config.json
    2016: === Copying Client certificates to C:\Users\vagrant\.docker\machine\machines\2016
    2016: === Copying Docker Machine configuration to C:/Users/nolte\.docker\machine\machines\2016
    2016: Restarting Docker
    2016: Reducing minimum API version from 1.24 to 1.15
    2016: Replacing '1.24' with '1.15' in file 'C:\Program Files\docker\dockerd.exe'
    2016: Fix already applied.
    2016: Opening Docker TLS port
    2016: Start-Service : Failed to start service 'Docker Engine (docker)'.
    2016: At C:\tmp\vagrant-shell.ps1:308 char:1
    2016: + Start-Service docker
    2016: + ~~~~~~~~~~~~~~~~~~~~
    2016:     + CategoryInfo          : OpenError: (System.ServiceProcess.ServiceController:ServiceController) [Start-Service],  
    2016:    ServiceCommandException
    2016:     + FullyQualifiedErrorId : StartServiceFailed,Microsoft.PowerShell.Commands.StartServiceCommand
    2016: Ok.

Error: "Couldn't open file" when starting vagrant up

When running sudo vagrant up --provider virtualbox 2016, then the following output is given:

Bringing machine '2016' up with 'virtualbox' provider...
==> 2016: Box 'windows_2016_docker' could not be found. Attempting to find and install...
    2016: Box Provider: virtualbox
    2016: Box Version: >= 0
==> 2016: Box file was not detected as metadata. Adding it directly...
==> 2016: Adding box 'windows_2016_docker' (v0) for provider: virtualbox
    2016: Downloading: windows_2016_docker
An error occurred while downloading the remote file. The error
message, if any, is reproduced below. Please fix this error and try
again.

Couldn't open file /Users/felixhoffmann/dev/windows-docker-machine/windows_2016_docker

Same happens accordingly when using 2019 image.

docker-compose

I don't know if you tested this .. but I cannot get docker-compose to work via this way of working.

normal docker commands work. but when I am on my mac and try to mount volumes in the compose file I get.

ERROR: for db Cannot create container for service db: invalid volume spec "C": invalid volume specification: 'C'

services:
 db:
  image: microsoft/mssql-server-windows-express
  volumes:
  - ./docker/databases:C:Data

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.