Windows 10上使用Hyper-V虛擬機(jī)安裝docker
在windows上使用Docker大概有三種方式:
Docker desktop for windows
Microsoft store app來安裝linux子系統(tǒng)
Hyper-V創(chuàng)建虛擬機(jī)來安裝docker
以上三種方式,比較推薦使用Hyper-V的虛擬機(jī)來安裝docker,使用Hyper-V來安裝linux虛擬機(jī)在操作系統(tǒng)和設(shè)置上的坑比較少,以下使用windows 10的Hyper-V虛擬機(jī)來安裝docker。
首先需要啟用windows的Hyper-V管理器:
在打開Hyper-V管理器創(chuàng)建VM前需要啟用Hyper-V相關(guān)計(jì)算服務(wù),如:
有時(shí)啟動(dòng)服務(wù)或在Hyper-V管理虛擬機(jī)時(shí)會(huì)報(bào)異常,可以確認(rèn)如下配置:
Windows安全中心中的:
完成如上正常打開:
可通過原生centos或其他linux iso更改安裝源完成操作系統(tǒng)的安裝:
完成linux系統(tǒng)的安裝后可通過共享網(wǎng)卡的方式實(shí)現(xiàn)虛擬機(jī)上網(wǎng),在網(wǎng)卡設(shè)置中設(shè)置internet共享:
通過yum完成docker的安裝,docker從公網(wǎng)拉取鏡像,可以通過設(shè)置docker的proxy:
可參考https://docs.docker.com/config/daemon/systemd/,如下:
Create a systemd drop-in directory for the docker service:
$?sudo?mkdir?-p?/etc/systemd/system/docker.service.d
2.Create a file called?/etc/systemd/system/docker.service.d/http-proxy.conf?that adds the?HTTP_PROXY?environment variable:
[Service]Environment="HTTP_PROXY=http://proxy.example.com:80/"
Or, if you are behind an HTTPS proxy server, create a file called?/etc/systemd/system/docker.service.d/https-proxy.conf?that adds the?HTTPS_PROXY?environment variable:
[Service]Environment="HTTPS_PROXY=https://proxy.example.com:443/"
3.If you have internal Docker registries that you need to contact without proxying you can specify them via the?NO_PROXY?environment variable.
The?NO_PROXY?variable specifies a string that contains comma-separated values for hosts that should be excluded from proxying. These are the options you can specify to exclude hosts:
Config examples:
[Service]???? Environment="HTTP_PROXY=http://proxy.example.com:80/"?"NO_PROXY=localhost,127.0.0.1,docker-registry.example.com,.corp"
Or, if you are behind an HTTPS proxy server:
[Service]???? Environment="HTTPS_PROXY=https://proxy.example.com:443/"?"NO_PROXY=localhost,127.0.0.1,docker-registry.example.com,.corp"
example.com?matches?example.com?and?foo.example.com, and
.example.com?matches only?foo.example.com
IP address prefix (1.2.3.4)
Domain name, or a special DNS label (*)
A domain name matches that name and all subdomains. A domain name with a leading “.” matches subdomains only. For example, given the domains?foo.example.com?and?example.com:
A single asterisk (*) indicates that no proxying should be done
Literal port numbers are accepted by IP address prefixes (1.2.3.4:80) and domain names (foo.example.com:80)
Flush changes:
$?sudo?systemctl?daemon-reload
Restart Docker:
$?sudo?systemctl?restart?docker
Verify that the configuration has been loaded:
$?systemctl?show?--property=Environment?dockerEnvironment=HTTP_PROXY=http://proxy.example.com:80/
Or, if you are behind an HTTPS proxy server:
$?systemctl?show?--property=Environment?dockerEnvironment=HTTPS_PROXY=https://proxy.example.com:443/
完成如上正常能從公網(wǎng)拉取鏡像等:
在使用代理時(shí),如果需要?jiǎng)?chuàng)建容器網(wǎng)絡(luò),需要避免使用的網(wǎng)段與proxy的網(wǎng)絡(luò)產(chǎn)生沖突,會(huì)導(dǎo)致代理失效。
后續(xù)的虛擬機(jī)管理可以通過Hyper-V管理器來進(jìn)行管理:
Windows Docker
版權(quán)聲明:本文內(nèi)容由網(wǎng)絡(luò)用戶投稿,版權(quán)歸原作者所有,本站不擁有其著作權(quán),亦不承擔(dān)相應(yīng)法律責(zé)任。如果您發(fā)現(xiàn)本站中有涉嫌抄襲或描述失實(shí)的內(nèi)容,請聯(lián)系我們jiasou666@gmail.com 處理,核實(shí)后本網(wǎng)站將在24小時(shí)內(nèi)刪除侵權(quán)內(nèi)容。
版權(quán)聲明:本文內(nèi)容由網(wǎng)絡(luò)用戶投稿,版權(quán)歸原作者所有,本站不擁有其著作權(quán),亦不承擔(dān)相應(yīng)法律責(zé)任。如果您發(fā)現(xiàn)本站中有涉嫌抄襲或描述失實(shí)的內(nèi)容,請聯(lián)系我們jiasou666@gmail.com 處理,核實(shí)后本網(wǎng)站將在24小時(shí)內(nèi)刪除侵權(quán)內(nèi)容。