
This publication is a review of the features of Docker container virtualization under Windows.
It does not claim to be exhaustive and will be updated and supplemented as necessary.
For practical guidance from scratch, I advise you to refer to
this publication .
')
Content
Presets
Container virtualization or virtualization at the level of the Docker operating system works natively only on Linux and
FreeBSD distributions
(experimentally) .
On Windows, you will need a Linux guest system or a special minimalistic virtual machine with the Linux kernel from Docker developers, which is installed out of the box.
It goes without saying that you have enabled virtualization in your BIOS / UEFI
The configuration item can be called differently: VT-x, VT-d, Intel VT, AMD-V, Virtualization Technology.
Another minimum system requirement is the x64 system width and the version not lower than Windows 7 Pro.
Choose between Docker Toolbox on Windows or Docker for Windows
The appearance of
Docker Toolbox on Windows and
Docker Toolbox on Mac was a big event.
The build includes docker itself, the docker-compose utility, the docker-machine virtual machine utility and the Kitematic client.
A virtual machine is used (default on VirtualBox) with a minimalist Linux environment.
Later for new operating systems,
Docker for Windows and
Docker for Mac were released , which is currently the current version and continues to evolve.
The choice between versions is not difficult:
- If you have Windows 10 x64 Pro, Enterprise or Education, then turn on the Hyper-V service and install Docker for Windows.
Note that after enabling the Hyper-V service, you will not be able to start and create x64 virtual machines on VirtualBox.
- If you have another version of Windows (7 Pro, 8, 8.1, 10 Home), then we install VirtualBox and Docker Toolbox on Windows.
Despite the fact that the developers recognized the obsolete Docker Toolbox work with it is slightly different from Docker for Windows.
Along with the installation of Docker Toolbox, a virtual machine will be created.
In VirtualBox itself, you can add RAM and processor cores at your discretion.
Windows containers and Linux containers
Docker for Windows provides the ability to switch containerization between Linux and Windows version.
In the Windows containerization mode, you can run only Windows applications.
I note that as of May 2018 there are only
13 Windows images in the official Docker Hub.
After enabling Windows containerization, remember to add an external network.
In the docker-compose.yml configuration file, it looks like this:
networks: default: external: name: nat
Folder Mounting Features
On mounted volume, the file system events are not thrown, therefore inotify-tools does not work.
Thanks to eeeIf you are developing your project and using docker-compose outside your home folder, then you will need to do some manipulations.
Using Docker for Windows to mount a new disk, your local user must have a password that will be used to access the shared folder.
The peculiarity is that the disk mounted inside the container will be mounted as from a remote machine //10.0.75.1/DISK_DRIVE using the SMB protocol.
For Docker Toolbox, disks are mounted in VirtualBox itself on the Shared Folders tab
Example for the “D” disc:

Permissions to mount files and folders
As much as you would like, but for all files and folders mounted from the host machine, there will be 755 rights (rwx rx rx) and you cannot change them.
An acute question arises when mounting a private SSH key inside a file, the rights to which should only be owned by the owner (for example, 600).
In this case, they either generate the key when creating the image, or they pass the ssh-agent socket from the host machine.
Mount from host or volume
Mounting inside the container occurs using the network and SMB protocol, therefore, inside the container the “D: \” disk will be mounted from the source //10.0.75.1/D
Using volume inside the container is displayed as mounting the local disk / dev / sda1, which affects the speed of work.
By a simple test copying a file on a normal HDD, the speed of operation was the following:
Type of | Reading | Record |
Mounting | ~ 85 MB / s | ~ 50 MB / s |
Volume | ~ 340 MB / s | ~ 220 MB / s |
Such a difference in speed is most likely due to the fact that in volume the data is flushed to disk gradually, using the cache in RAM.
GPT and MBR disk partitioning features
This clause is not true as I could not find any refuting or confirming information on the Internet.
If the host machine has an MBR partition table, then the container with MySQL / MariaDB may fall with the error:
InnoDB: File ./ib_logfile101: 'aio write' returned OS error 122. Cannot continue operation
By default, the innodb_use_native_aio parameter, which is responsible for asynchronous I / O, is enabled in the melon database and must be turned off.
This problem is also found on some versions of MacOS.
Docker Toobox to Windows
The main rule is to start work by launching a shortcut on the desktop “Docker Quickstart Terminal”, this solves 80% of the problems.
- There are problems with the lack of environment variables, solved by the command:
eval $(docker-machine env default)
- If you still have problems from the category of "docker: error during connect", you must perform:
docker-machine env --shell cmd default @FOR /f "tokens=*" %i IN ('docker-machine env --shell cmd default') DO @%i
The default Docker Machine name is default.
Docker swarm
Neither in Docker for Mac, nor in Docker for Windows, it is not possible to use running daemons as cluster clients (swarm members).
Thanks to user stychosEncoding problems
Using the Docker Toolbox (on Docker for Windows could not be reproduced) there was a problem with the fact that Russian comments in the docker-compose.yml file resulted in an error:
Traceback (most recent call last): File "docker-compose", line 6, in <module> File "compose\cli\main.py", line 71, in main File "compose\cli\main.py", line 124, in perform_command File "compose\cli\command.py", line 41, in project_from_options File "compose\cli\command.py", line 109, in get_project File "compose\config\config.py", line 283, in find File "compose\config\config.py", line 283, in <listcomp> File "compose\config\config.py", line 183, in from_filename File "compose\config\config.py", line 1434, in load_yaml File "site-packages\yaml\__init__.py", line 94, in safe_load File "site-packages\yaml\__init__.py", line 70, in load File "site-packages\yaml\loader.py", line 24, in __init__ File "site-packages\yaml\reader.py", line 85, in __init__ File "site-packages\yaml\reader.py", line 124, in determine_encoding File "site-packages\yaml\reader.py", line 178, in update_raw File "c:\projects\compose\venv\lib\encodings\cp1251.py", line 23, in decode UnicodeDecodeError: 'charmap' codec can't decode byte 0x98 in position 1702: character maps to <undefined> [4176] Failed to execute script docker-compose
useful links
Docker Toolbox on WindowsDocker for WindowsDocker Practical GuideConclusion
The specifics of working with Docker in containerization on a Windows system is no different from working on Linux with the exception of the ones disassembled above.
In the article, I deliberately did not mention the markedly low container speed and overhead using Windows as a matter of course.
I will be glad to hear your feedback. Feel free to suggest improvements or point out my mistakes.