我只想在Windows Server 2019上build 基于Linux的Docker
周末回家忘了帶筆記本電源,電源耗盡,只能在家里的Windows Server 2019上繼續工作,而當我在Windows Server 2019中用Docker Build我的Docker鏡像的時候,出現如下錯誤:
Using default tag: latest latest: Pulling from library/node no matching manifest for unknown in the manifest list entries
我才意識到Windows Server 2019上安裝的Docker是Windows容器的:
PS C:\Users\Administrator> docker version Client: Docker Engine - Enterprise Version: 18.09.4 API version: 1.39 Go version: go1.10.8 Git commit: c3516c43ef Built: 03/27/2019 18:22:15 OS/Arch: windows/amd64 Experimental: false Server: Docker Engine - Enterprise Engine: Version: 18.09.4 API version: 1.39 (minimum version 1.24) Go version: go1.10.8 Git commit: c3516c43ef Built: 03/27/2019 18:20:29 OS/Arch: windows/amd64 Experimental: false
我第一個想到要在Windows Server 2019構建基于Linux OS的Docker的方法就是安裝WSL(Windows Subsystem for Linux), 然后在WSL中安裝Docker。
開始行動,參考這篇文章:https://docs.microsoft.com/en-us/windows/wsl/install-on-server
首先,開啟WSL:
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux
然后按照這篇文章下載自己喜歡的Linux 子系統:https://docs.microsoft.com/en-us/windows/wsl/install-manual

我選擇的是Ubuntu 18/04,下載后解壓出來,然后運行:
Rename-Item ./Ubuntu-1804.appx ./Ubuntu.zip
Expand-Archive ./Ubuntu.zip ./Ubuntu
解壓出來:

直接執行ubuntu1804.exe安裝ubuntu子系統,安裝后進入ubuntu執行初始化工作,然后準備在WSL中安裝docker:
sudo apt-get update sudo apt-get install docker-ce docker-ce-cli containerd.io sudo docker run hello-world Hello from Docker! This message shows that your installation appears to be working correctly. To generate this message, Docker took the following steps: 1. The Docker client contacted the Docker daemon. 2. The Docker daemon pulled the "hello-world" image from the Docker Hub. (amd64) 3. The Docker daemon created a new container from that image which runs the executable that produces the output you are currently reading. 4. The Docker daemon streamed that output to the Docker client, which sent it to your terminal. To try something more ambitious, you can run an Ubuntu container with: $ docker run -it ubuntu bash Share images, automate workflows, and more with a free Docker ID: https://hub.docker.com/ For more examples and ideas, visit: https://docs.docker.com/get-started/
恭喜你安裝成功
期間遇到很多問題:解決方法當時沒有記錄下來,可以參考下面幾篇文章:
https://zhuanlan.zhihu.com/p/39187620
但是還是有點問題,DNS問題,使用npm install的報錯:
npm ERR! code EAI_AGAIN npm ERR! errno EAI_AGAIN npm ERR! request to https://registry-node.aliyun.com/org/1502272316663857/registry/cmgp/@cmgp%2fcommon failed, reason: getaddrinfo EAI_AGAIN registry-node.aliyun.com registry-node.aliyun.com:443 npm ERR! A complete log of this run can be found in: npm ERR! /root/.npm/_logs/2020-01-04T04_22_31_732Z-debug.log The command '/bin/sh -c npm install' returned a non-zero code: 1
目前還在尋找解決方案中

浙公網安備 33010602011771號