Docker windows 10 vmware

Install docker on VMware Windows10 virtual machine

This article records how to install docker on a windows virtual machine.

Precondition:
Host PC: Windows 10 Professional
VMware Workstation 12 Pro: 12.5.9 build-7535481

Install win10 pro virtual machine and set

The hyper-v in the host must be disabled, otherwise the virtual machine cannot be started

  1. Get the image of windows 10 pro:https://www.microsoft.com/zh-cn/software-download/windows10/
    Install the download tool, and then follow the prompts to create the installation media.
  2. VM ware creates a new virtual machine and installs the win10.iso image generated in the previous step.
  3. Successfully log in with an existing windows account, skip the part that needs to be activated. (Due to the computer configuration, this step is slow, about half an hour)
  4. Close the installed client and selectEdit virtual machine settings, In the virtual machine settings -> hardware -> processor -> virtualization engine, checkVirtualization Intel VT-x/EPT or AMD-V/RVI(V)

Docker configuration of the virtual machine client

All the following operations are on the VMware windows10 client:

  1. enable Hyper-V
  2. Install Docker for Windows Installer.exe

If it fails to start docker, it prompts «because one of the Hyper-V components is not running».
inadmin permissionsEnter the following two commands in cmd or power shell:
https://stackoverflow.com/questions/48255871/failed-to-start-the-virtual-machine-mobylinuxvm-because-one-of-the-hyper-v-com/51153126

Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V -All -Verbose
Enable-WindowsOptionalFeature -Online -FeatureName Containers -All -Verbose

problem

Although the current docker can run and the image can be downloaded, it always prompts «docker: Error response from daemon: CreateComputeSystem: The virtual machine not be started because q required feature is not installed» when running the image.
The same image I run on the host machine (enable Hyper-V).

https://stackoverflow.com/questions/48255871/failed-to-start-the-virtual-machine-mobylinuxvm-because-one-of-the-hyper-v-com/51153126
If you know the reason, please leave a message.

August 2020 Update: now that VMware Workstation can run with Hyper-V installed, there’s a better alternative to running Docker on Windows 10. Check out this guide for more information.

Docker is one of the most useful tools for a developer nowadays, but setting it up on a Windows machine can be really painful, specially if you don’t want to enable Hyper-V and prefer to use another hypervisor such as VMware Workstation.

Fortunately, there’s an «easy» way to do exactly that with Chocolatey, the self-proclaimed package manager for Windows. Let’s get started!

First of all, we need to open a Powershell window with administrative privileges and run the following command to install the Docker CLI and the VMware Docker machine driver:

PS> choco install docker-cli docker-machine-vmware

As Docker is runtime-agnostic, we can create a custom Docker machine running inside a VMware VM instead of using Hyper-V and then connect that instance to the Docker CLI. Let’s create the Docker machine:

PS> docker-machine create --driver=vmware default

This command will take a few minutes. After it’s done, make sure it was successful by listing the available Docker machines:

PS> docker-machine ls

NAME      ACTIVE   DRIVER   STATE     URL                          SWARM   DOCKER     ERRORS
default   -        vmware   Running   tcp://192.168.142.136:2376           v19.03.5

Great, we’re almost done! The final step is to tell the CLI to use this machine for any Docker-related commands:

PS> docker-machine env | Invoke-Expression

And that’s it! Docker running on Windows using VMware Workstation instead of Hyper-V. Keep in mind you’ll need to start the Docker machine and connect it to Docker CLI every time you boot your device:

PS> docker-machine start default; docker-machine env | Invoke-Expression

Last but not least, here are some relevant URLs you can visit to learn more:

  • Docker machine VMware driver
  • Docker machines documentation

The purpose of this blog post is to show how to setup Docker Community Edition in a Windows 10 with VMware Workstation to be use in Windows Subsystem for Windows (WSL).

There are a few blog post that helped me figure out what’s needed to get this to work and I’ll be sharing these links at the end of this post.

My current environment

My current environment consist of the following components:

  • Windows 10 Build 17763
  • VMware Workstation Pro 12
  • *Oracle Virtualbox 5.2
  • WSL – Ubuntu 18.04
  • SQL Server 2017 Developer Edition
  • Windows PowerShell (v5.1.17763.316)
  • PowerShell Core GA v6.3.1 (both Windows and Linux)
  • PowerShell Core Preview v6.2.0-preview.4 (both Windows and Linux)

*Note: This is not the latest version  of Virtualbox but it’s still supported.

Remember, the purpose of this environment is to build a “developer sandbox” that can allow me to learn and work with Docker containers.

What’s needed!

Because I’m using VMware Workstation instead of Hyper-V, there are a few things need to be in place to make this work. Windows 10 need to have the following:

  • All Hyper-V services need to be disable by using “System Configuration” tool.

  •  Install VMWare Workstation Pro. (https://www.vmware.com/products/workstation-pro.html)
  •  Install Oracle Virtualbox version 5.2. (https://www.virtualbox.org/wiki/Download_Old_Builds_5_2)

  •  Install from the Microsoft Store, WSL – Ubuntu 18.04.

  • And, make sure to run “sudo apt update” and “sudo apt upgrade” because images are not updated with latest components.

Installing PowerShell Components

Next, the following Docker components packages from Chocolatey need to be install using Windows PowerShell with administrator privileges:

* Install docker

choco install -y docker

* Install docker-machine-vmwareworkstation

choco install -y docker-machine-vmwareworkstation

Getting WSL Ready for Docker

Now, open the “WSL – Ubuntu 18.04” Linux console and execute the following *commands:

sudo apt update

sudo apt upgrade

*Note: You’ll need to run these two commands manually to keep your Linux distribution up-to-date.

At this point, follow the Docker installation instructions for “Docker-CE for Ubuntu 18.04“. But, in a nutshell, here’s the shortcut:

sudo apt-get install \
apt-transport-https \
ca-certificates \
curl \
gnupg-agent \
software-properties-common

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -

sudo add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable"

sudo apt-get update

sudo apt install docker-ce

sudo usermod -aG docker maxt

exit

At this point. make sure to reopen the WSL linux console.

Setup Docker-Machine in Windows

Back in Windows PowerShell, the next steps show the way to have Docker work in “WSL – Ubuntu 18.04“. Starting with Windows PowerShell console, execute the following commands:

docker-machine --native-ssh create -d vmwareworkstation default
docker-machine create docker-host

These commands should complete without any errors. At the same time, two virtual machines: “default” and “docker-host” will be created and running in *Virtualbox.

*Note: These two *NEED* to be running in order for docker to work with WSL. At the same time, both VMware Workstation and Virtualbox need to be installed or this will not work

To check that for the Docker-Machine environment(s) are working, use the following command:

docker-machine ls

Next, execute the following command to write down “docker-host” environment results to be copied into the Linux user ~/.bashrc file.

docker-machine env docker-host
PS C:\WINDOWS\system32> docker-machine.exe env default
$Env:DOCKER_TLS_VERIFY = "1"
$Env:DOCKER_HOST = "tcp://192.168.220.xxx:2376"
$Env:DOCKER_CERT_PATH = "C:\Users\max_t\.docker\machine\machines\default"
$Env:DOCKER_MACHINE_NAME = "default"
$Env:COMPOSE_CONVERT_WINDOWS_PATHS = "true"
# Run this command to configure your shell:
# & "C:\ProgramData\chocolatey\lib\docker-machine\bin\docker-machine.exe" env default | Invoke-Expression

Open a “WSL – Ubuntu 18.04 console to edit the user “~/.bashrc” file, to add the following Docker variables:

## Added manually for Docker machine docker-host:
export DOCKER_HOST=192.168.99.xxx:2376
export DOCKER_TLS_VERIFY=1
export DOCKER_CERT_PATH=/mnt/c/users/max_t/.docker/machine/machines/docker-host
export DOCKER_MACHINE_NAME=docker-host
export COMPOSE_CONVERT_WINDOWS_PATHS=true

sudo vim ~/.bashrc

Reopen the “WSL – Ubuntu 18.04 console.

Testing Docker in WSL

Now, I can test Docker in my “WSL – Ubuntu 18.04 console session. Open PowerShell Core console, and execute the following command to run the Docker Hello-World demo:

docker run Hello-World

This command download (or pull) the Docker image, then run the Hello-World container. If everything work as expected, then it will display the following text.

To check both Docker image(s) and/or container(s) in WSL , use the following commands: (Picture

# - Check for all pulled images in system:
docker images

# - Check the status of active containers:
docker ps -a

As you can see there no issues executing Docker command lines in Linux PowerShell Core.

To see the full list of docker command line help available click on the following link.

After all this is done! Docker working in my WSL environment.

Limitations

YES! There are limitations. This is a workaround on the issue of using Docker without Hyper-V. And, this will allow you to:

  • Pull images
  • Update containers
  • Save images

In my environment, I found limitations working with Docker Network using WSL which can impact Windows Docker-Machine VM “docker-host” interface. This issue can force you to rebuild both VM interfaces: “default” and “docker-host“.

Make sure to learn how to commit, save, and reload Docker images.  Don’t lose your changes!

So, if you have either VMware Workstation and/or Oracle Virtualbox, consider investing the time creating a Linux virtual machine and then install Docker CE.

Summary

We have accomplished setting up Docker containers in *Windows 10 “WSL – Ubuntu 18.04” using both Windows PowerShell and PowerShell Core in Linux. So, using Oracle Virtualbox v5.2 with VMware Workstation is a required component to make this work.

*Note: These post is meant for people to make Docker work in WSL Linux.

Also, if you’re familiar with PowerShell, Docker commands can execute without any issues. Now, I can use my favorite editor SAPIEN’s PowerShell Studio to build my automation scripts with docker commands.

What’s Next?

Try downloading other Docker images, like SQL Server 2017 and SQL Server 2019. This is the quickest way for providing a built solution using containers.

Learn about Docker Compose, and Kubernetes as these can be use in the Cloud environment as well.

Go and Explores the possibilities of provisioning solutions to your organization!

Resource links

  • Get Docker CE for Ubuntu
  • Running Docker containers on Bash on Windows
  • Is it possible to have docker running inside of vmware?
  • Quickstart: Run SQL Server container images with Docker
  • Configure SQL Server container images on Docker

Время на прочтение3 мин

Количество просмотров16K

Задача было простой, поставить Docker на свой рабочий ноутбук с Windows, на котором уже и так зоопарк. Поставил Docker Desktop создал контейнеры, всё ок, вот только быстро обнаружил, что VMWare Workstation перестала запускать виртуалки с ошибкой:

VMware Workstation and Device/Credential Guard are not compatible. VMware Workstation can be run after disabling Device/Credential Guard.

Работа встала, нужно срочно чинить

Методом гугления было выяснено, что данная ошибка возникает из-за несовместимости VMWare Workstation и Hyper-V на одной машине. Проблема известная и есть официальное решение VMWare как это починить, со ссылкой на базу знаний Microsoft Manage Windows Defender Credential Guard. Решение заключается в отключении Defender Credential Guard (мне помог пункт 4 раздела Disable Windows Defender Credential Guard):

mountvol X: /s
copy %WINDIR%\System32\SecConfig.efi X:\EFI\Microsoft\Boot\SecConfig.efi /Y
bcdedit /create {0cb3b571-2f2e-4343-a879-d86a476d7215} /d "DebugTool" /application osloader
bcdedit /set {0cb3b571-2f2e-4343-a879-d86a476d7215} path "\EFI\Microsoft\Boot\SecConfig.efi"
bcdedit /set {bootmgr} bootsequence {0cb3b571-2f2e-4343-a879-d86a476d7215}
bcdedit /set {0cb3b571-2f2e-4343-a879-d86a476d7215} loadoptions DISABLE-LSA-ISO
bcdedit /set {0cb3b571-2f2e-4343-a879-d86a476d7215} device partition=X:
mountvol X: /d

После перезапуска Windows спросит, действительно ли отключить Defender Credential Guard. Да! Таким образом VMWare Workstation вернется к нормальной работе, и мы окажемся в том же месте, что и до установки докера.

Решения как помирить Hyper-V и VMWare Workstation я так и не нашел, надеюсь в новых версиях они подружатся.

Другой путь

Я уже давно подсел на VMWare Workstation для разных целей, пытался слезть на Hyper-V и VirtualBox, но функционал не удовлетворил моим задачам, так по сей день и сижу. Оказалось есть решение как сдружить VMWare, Docker и VSCode в одной рабочей среде.

Docker Machine — позволяет запускать Docker Engine на виртуальном хосте и подключаться к нему как удаленно, так и локально. И для него есть драйвер совместимости с VMWare Workstation, ссылка на GitHub

Инструкцию по установке особо пересказывать не буду, только список ингридиентов:

  1. Docker Toolbox (Docker Machine в комплекте)
  2. Docker Machine VMware Workstation Driver
  3. Docker Desktop

Да, Docker Desktop, к сожалению, тоже понадобится. Если снесли его, то устанавливаем заново, но на этот раз убрав чекбокс о внесении изменений в ОС, чтоб вновь не сломать VMWare Workstation.

Сразу хочу заметить, что всё прекрасно работает от простого пользователя, программы установки попросят эскалацию прав когда им будет нужно, но все команды в командной строке и скрипты выполняются от текущего пользователя.

В итоге командой:

$ docker-machine create --driver=vmwareworkstation dev

из Boot2Docker будет создана виртуалка dev внутри которой будет Docker.

Эту виртуалку можно прицепить в графический интерфейс VMWare Workstation, открыв соответствующий vmx файл. Но это не обязательно, ведь VSCode теперь потребуется запускать PowerShell скриптом (у меня почему-то docker-machine и docker-machine-driver-vmwareworkstation оказались именно в папке bin):

cd ~/bin
./docker-machine env dev | Invoke-Expression
code

Откроется VSCode для работы кодом на локальной машине и докером в виртуалке. Плагин Docker for Visual Studio Code позволяет удобно управлять контейнерами в виртуалке не залезая в консоль.

Сложности:

В процессе создания docker-machine у меня процесс зависал:

Waiting for SSH to be available...

И через некоторое время завершился с превышением попыток установить соединение с виртуалкой.

Всё дело в политике к сертификатам. При создании виртуальной машины, у вас появится каталог ~\.docker\machine\machines\dev в этом каталоге будут файлы сертификата для подключения по SSH: id_rsa, id_rsa.pub. OpenSSH может отказываться их использовать, так как считает что у них проблемы с правами доступа. Только вот docker-machine вам об этом ничего не скажет, а просто будет переподключаться пока не надоест.

Решение: Как только начнется создание новой виртуальной машины заходим в каталог ~\.docker\machine\machines\dev и меняем права на указанные файлы, по одному.

Владельцем файла должен быть текущий пользователь, полный доступ только у текущего пользователя и SYSTEM, всех остальных пользователей, включая группу администраторов и самих администраторов нужно удалять.

Так же могут быть проблемы с преобразованием абсолютных путей из Windows формата в Posix, и с биндингом томов содержащих symbolic link. Но это уже другая история.

Docker, WSL and VMware Workstation running at the same time on Windows 10

Daniel Nashed – 13 June 2020 17:16:31


This is awesome news! When I updated this week to Windows 10 Pro 2004, I looked into what’s new.
WSL2 got some updates and there is a new Windows Sanbox, which is also pretty cool to test stuff.

You can enable it and start it just like an app. This is similar to starting a Linux desktop like Ubuntu.

WSL2 is around for a while but I never looked into it. The what’s new and the Sandbox made me look into it.

Once you enabled WSL2 and downloaded one of the distributions form the Microsoft store (Ubuntu in my case), you can really run Linux on your Windows machine.

Docker on Windows

But the really cool part is that Docker now supports WSL2 and leverages it instead of leveraging a Linux installed on a Hyper-V VM.

I never liked the Docker integration for Windows. But this is a game changer!
Our Domino on Linux project including all build scripts and the management script just runs in an Ubuntu bash.
And you can look into your containers also with your Docker desktop environment on Windows.

So that means we are now also supporting our Domino Docker project on this new platform.


VMware Workstation 15.5 on the same machine

Of course my development environment will stay on CentOS 7 with Docker CE.
And this continues to run on my VMware workstation installed on the same machine!

This was the biggest surprise I had, when I did some research.

I didn’t use the Linux sub-system or Docker because this conflicted with my VMware workstation.

But since version 15.5 — thanks to VMware and Microsoft working together — both virtualization technologies can work hand in hand.


All the installation was really straight forward. I updated to Windows 2004, installed WSL2 and updated my VMware Workstation, before installing the current Docker version.


Enclosed you find links with background information and also how to set it up!

— Daniel

Image:Docker,  WSL and VMware Workstation running at the same time on Windows 10


References you should check if your want to install it on your own

Docker using WSL2


https://docs.docker.com/docker-for-windows/wsl/

What’s new in Windows 2004


https://docs.microsoft.com/en-us/windows/whats-new/whats-new-windows-10-version-2004
Windows Sandbox


https://techcommunity.microsoft.com/t5/windows-kernel-internals/windows-sandbox/ba-p/301849

VMware Workstation 15.5 Now Supports Host Hyper-V Mode


https://blogs.vmware.com/workstation/2020/05/vmware-workstation-now-supports-hyper-v-mode.html

Windows Subsystem for Linux (WSL): The Ultimate Guide


https://adamtheautomator.com/windows-subsystem-for-linux/

What’s new in WSL»


https://docs.microsoft.com/en-us/windows/wsl/wsl2-index

  • Comments [1]

Понравилась статья? Поделить с друзьями:
0 0 голоса
Рейтинг статьи
Подписаться
Уведомить о
guest

0 комментариев
Старые
Новые Популярные
Межтекстовые Отзывы
Посмотреть все комментарии
  • Windows server radius cisco
  • Как выполнить диагностику сети в windows 10 на ноутбуке
  • Выключил микрофон как включить windows 10
  • Ssd диск не проинициализирован что делать windows 10
  • Как настроить active directory на windows server 2016