WSL, also known as win10 update, is a friendly point for developers. It is not a virtual machine, but a simulation environment. It does not support various operations in Linux. However, it is very convenient to interact with windows, and the consumption is very low, so it is suitable for me to develop and test.
The benefits of docker will not be mentioned here. You can learn about it (mainly because I also used it for the first time). This article is mainly about how to install it. It will not explain the principles and concepts.
In fact, the reason why I want to build such a development environment is relatively simple, mainly for the following two reasons:
1. The service on the company’s server is the mode of Linux plus docker. I want to simulate such a structure for testing and development, just to learn
2. My development environment is windows. I hope to make my development environment cleaner with the help of docker and WSL (why not use Linux system directly, just because I think a computer dual system can’t stand…)
You can install it directly in the win10 store. There is only one pit here, which is to open the Linux subsystem service
There are more pits here. I hope the pits I stepped on can help you
Environment: win10 home
- Install docker in WSL
Reference blog: https://yeasy.gitbooks.io/docker’u practice / install/
Refer to the installation method of Ubuntu in the above article
After installation, start docker
sudo service docker start
There will be an error here
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
It means that I can’t connect to the daemonic thread. Although I don’t know what the daemonic thread is, I found a blog of a little brother from abroad:
The key point is to install docker in WSL. You must first install docker for windows on your system.
OK, let’s install this.
Go to the official website to download.
Then you’ll find that you can’t install it, because docker doesn’t support win10 home
Some blogs will say to use docker toolbox instead. I don’t recommend it here. Anyway, I didn’t replace success.
Solution step 1: modify the registry so that the installer mistakenly thinks we are win10 Pro
Navigate to HKEY? Local? Machinesoftwaremicrosoft windows ntcurrentversion
Modify editionid value to professional
Then we have to start Hyper-V service, which is not available in win10 home edition, so we need to install it.
dir /b %SystemRoot%servicingPackagesHyper-V.mum >hyper-v.txt
for /f %%i in (‘findstr /i . hyper-v.txt 2^>nul’) do dism /online /norestart /add-package:”%SystemRoot%servicingPackages%%i”
Dism /online /enable-feature /featurename:Microsoft-Hyper-V-All /LimitAccess /ALL
Copy the above to the. CMD file, and then run it with an administrator. After the installation, restart the computerInstall and enable windows featuresOpen the Hyper-V service in and start docker for windows.
At this time, let’s go back to the problem that the daemons are not enabled
Then go back to Ubuntu and type
echo “export DOCKER_HOST=localhost:2375” >> ~/.bash_profile
That is to say, tell docker that its daemons interface and docker version check whether the startup is successful
We can use docker here, and then there is a big hole. We need to change the editionid value to professional. Every time we restart the computer, windows will automatically change it back, and then we can’t start docker for windows again. If I find a solution, I will make it up again.