Windows Docker for development, pitfall analysis
- Tutorial
This publication is a discussion of the features of Docker container virtualization under Windows. It does not claim to be an exhaustive one and will be updated and supplemented as necessary.
For practical guidance from scratch, I advise you to refer to this publication .
Content
- Presets
- Choose between Docker Toolbox on Windows or Docker for Windows
- Windows containers and Linux containers
- Folder Mount Features
- Mount from host or volume
- GPT and MBR Partitioning Features
- Docker Toobox to Windows
- Docker swarm
- Encoding Issues
- useful links
- Conclusion
Presets
Container virtualization or virtualization at the Docker operating system level natively only works on Linux and FreeBSD distributions (experimental) .
On Windows, you will need a Linux guest system or a special minimalistic virtual machine with a Linux kernel from Docker developers, which is put out of the box.
It goes without saying that you have enabled virtualization in your BIOS / UEFI.
The setting item can be called differently: VT-x, VT-d, Intel VT, AMD-V, Virtualization Technology.
Another minimum system requirement will be the x64 system capacity and version no lower than Windows 7 Pro.
Choose between Docker Toolbox on Windows or Docker for Windows
The advent of the Docker Toolbox on Windows and the Docker Toolbox on Mac was a big event.
The assembly includes docker itself, docker-compose utility, docker-machine virtual machine utility, and Kitematic client.
It uses a virtual machine (by default on VirtualBox) with a minimalistic Linux environment.
Later, Docker for Windows and Docker for Mac were released for new operating systems , which is currently the current version and continues to develop.
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 you enable the Hyper-V service, you will no longer be able to run and create x64 virtual machines on VirtualBox.
- If you have a different 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 of the Docker Toolbox are deprecated, working with it differs slightly from Docker for Windows.
Together with the installation of the Docker Toolbox, a virtual machine will be created.
In VirtualBox itself, it will be possible to 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 the Windows version.
In Windows containerization mode, you can only run Windows applications.
I note that in May 2018 in the official Docker Hub there are only 13 images for Windows .
After enabling Windows containerization, be sure to add an external network.
In the docker-compose.yml configuration file, it looks like this:
networks:
default:
external:
name: nat
Folder Mount Features
On mounted volume-events, file system events are not thrown, so inotify-tools does not work.
Thanks to eee user.
If you are developing your project and using docker-compose outside the 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 shared folders.
The peculiarity is that the disk mounted inside the container will be mounted both from the remote machine //10.0.75.1/DISK_DRIVE via the SMB protocol.
For the Docker Toolbox, disks are mounted in VirtualBox itself on the “Shared Folders” tab.
Example for a “D” drive:

Access rights to mounted files and folders
How would you not like, but for all files and folders mounted from the host machine, the rights will be 755 (rwx rx rx) and you will not be able to change them.
There is an acute question when mounting a private SSH key inside a file, the rights to which should only belong to the owner (for example 600).
In this case, they either generate a key when creating the image, or throw the ssh-agent socket from the host machine.
Mount from host or volume
Mounting inside the container occurs using the network and the SMB protocol, therefore, inside the container, the “D: \” drive will be mounted from the //10.0.75.1/D source.
Using volume inside the container is displayed as mounting the local drive / dev / sda1, which affects the speed work.
Using a simple test, copying a file to a regular HDD turned out to have the following speed:
| A type | Reading | Record |
| Mounting | ~ 85 MB / s | ~ 50 MB / s |
| Volume | ~ 340 MB / s | ~ 220 MB / s |
This 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 Partitioning Features
This item is not true since I could not find the disproving or confirming information on the Internet.
If the host table has the MBR partition table, then the container with MySQL / MariaDB may fail with the error:
InnoDB: File ./ib_logfile101: 'aio write' returned OS error 122. Cannot continue operationBy default, the innodb_use_native_aio parameter is included in the melon database , which is responsible for asynchronous input / output and it will need to be turned off.
This problem also occurs on some versions of MacOS.
Docker Toobox to Windows
The main rule: start by launching the shortcut on the desktop "Docker Quickstart Terminal", this solves 80% of the problems.
- There are problems with the lack of environment variables, it is solved by the command:
eval $(docker-machine env default)
- If you still encounter problems from the "docker: error during connect" category, 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 - there is no way to use running daemons as clients of a cluster (swarm members).
Thanks to stychos
Encoding Issues
Using the Docker Toolbox (on Docker for Windows it was not possible to reproduce), there was a problem with the fact that Russian comments in the docker-compose.yml file led to an error:
Traceback (most recent call last):
File "docker-compose", line 6, in
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
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
[4176] Failed to execute script docker-compose
useful links
Docker Toolbox on Windows
Docker for Windows Docker
Practical Guide
Conclusion
Features of working with Docker containerization on a Windows system is no different from working on Linux with the exception of those discussed above.
In the article, I deliberately did not mention the noticeably low speed of containers and overhead using Windows for granted.
I will be glad to hear your feedback. Feel free to suggest improvements or point out my mistakes.
Only registered users can participate in the survey. Please come in.
What version of Docker are you using?
- 33.1% Docker Toolbox on Windows 61
- 66.8% Docker for Windows 123