小男孩‘自慰网亚洲一区二区,亚洲一级在线播放毛片,亚洲中文字幕av每天更新,黄aⅴ永久免费无码,91成人午夜在线精品,色网站免费在线观看,亚洲欧洲wwwww在线观看

分享

用windows10家庭版構(gòu)建基礎(chǔ)的開發(fā)環(huán)境

 宇塵埃的圖書館 2021-02-04

一、 搭建目標(biāo)

基于Windows10家庭版,以及自帶的Ubuntu子系統(tǒng),搭建linux開發(fā)環(huán)境以及dokcer運(yùn)行環(huán)境,并實(shí)現(xiàn)Ubuntu和Windows環(huán)境間的相互通信。預(yù)計(jì)搭建時(shí)長1到2h左右(和獲取資源時(shí)的拉取站點(diǎn)有關(guān),建議使用國內(nèi)鏡像站點(diǎn)資源)。


 二、 實(shí)驗(yàn)環(huán)境

硬件設(shè)備:華為MateBook D ,64位,處理器Intel(RCore(TM)i7-8550U CPU@1.80GHZ 2.00 GHz,內(nèi)存16.0 GB

軟件環(huán)境:windows10家庭版,18363.900

三、 實(shí)驗(yàn)步驟

(一) 安裝Ubuntu

我這里選擇的是Ubuntu 20.04 LTS版本,通過windows10自帶的應(yīng)用商店MicrosoftStore進(jìn)行安裝。

會(huì)遇到如下提示:

Installing, this may take a few minutes...

WslRegisterDistribution failed with error: 0x8007019e

The Windows Subsystem for Linux optional component is not enabled. Please enable it and try again.

See https:///wslinstall for details.

Press any key to continue...

按照字面意思,就是要求啟用Linux子系統(tǒng)后再安裝。

右鍵左下角(任務(wù)欄左側(cè))的windows徽標(biāo),點(diǎn)擊“設(shè)置”,選擇“應(yīng)用和功能”,如下圖所示:

滾動(dòng)到最下方,點(diǎn)擊相關(guān)設(shè)置區(qū)域的“程序和功能”:

選擇左側(cè)“啟用或關(guān)閉Windows功能”,選中“適用于Linux的Windows子系統(tǒng)”:

再次啟動(dòng)Ubuntu 20.04 LTS,按照提示輸入用戶名和密碼(不必和Windows的用戶名/密碼相同),即可顯示:“Installation successful!”,安裝成功后啟動(dòng)畫面如下: 

1個(gè)IP應(yīng)該和widows的ip一致,另外兩個(gè)為虛擬網(wǎng)卡IP,可以記下來,后邊通過windows訪問Ubuntu會(huì)用到。

(二) 安裝DockerToolbox

我使用的版本是DockerToolbox-19.03.1,建議從鏡像站點(diǎn)下載安裝文件,如https://get./toolbox/,阿里云站點(diǎn)也可以,但最新版本更新不太及時(shí)。按照提示安裝,可能會(huì)遇到如下報(bào)錯(cuò):

This computer doesn't have VT-X/AMD-v enabled. Enabling it i

以管理員身份打開WINDOWSCMD命令窗口,執(zhí)行bcdedit看最后一行hypervisorlaunchtype的狀態(tài),將其設(shè)置為off:

bcdedit /set hypervisorlaunchtype off

再次安裝DockerToolbox-19.03.1(如果仍然報(bào)錯(cuò)就注銷當(dāng)前用戶重新登錄一下),出現(xiàn)以下報(bào)錯(cuò):

Running pre-create checks...

(default) Image cache directory does not exist, creating it at C:\Users\{用戶名}\.docker\machine\cache...

(default) No default Boot2Docker ISO found locally, downloading the latest release...

Error with pre-create check: "Get https://api.github.com/repos/boot2docker/boot2docker/releases/latest:

上邊的錯(cuò)誤簡單解釋就是從線上拉取鏡像網(wǎng)絡(luò)太慢拉不下來,我們手工下載一個(gè)boot2docker.iso,按照提示從github上或者其他鏡像站點(diǎn)下載都可以,github(https://github.com/boot2docker/boot2docker/releases/download/v19.03.5/boot2docker.iso)很慢,但我還是從上邊下載下來了。把boot2docker.iso放入指定目錄下:

C:\Users\{用戶名}\.docker\machine\cache再次啟動(dòng)DockerToolbox就應(yīng)該可以正常安裝了。安裝完畢后,有三個(gè)圖標(biāo)(默認(rèn)安裝了git,virtualbox,以及可視化docker鏡像管理工具kitematic和docker的快速啟動(dòng)命令行工具Terminal):

我們運(yùn)行“Docker Quickstart Terminal”就好,它其實(shí)是git目錄下的“bash.exe”命令,就會(huì)自動(dòng)啟動(dòng)docker,首次運(yùn)行會(huì)自動(dòng)創(chuàng)建網(wǎng)絡(luò),成功后如下提示:

進(jìn)入Docker Quickstart Terminal,運(yùn)行“docker info”、“docker run hello-world”、“docker images”、“docker-machine ls”等命令,能夠正常反饋,那就說明windows的docker環(huán)境安裝就緒了。

重啟電腦后,只需要打開1次Docker Quickstart Terminal,docker服務(wù)就已經(jīng)處于運(yùn)行狀態(tài),可以關(guān)閉該窗口,直接通過windows的命令行窗口進(jìn)行相應(yīng)的命令操作。

(三) 實(shí)現(xiàn)在Ubuntu上操作Docker

我們回到子系統(tǒng)Ubuntu,要從Ubuntu中操作docker需要做兩件事:

1、 安裝docker組件

(1) 安裝docker

sudo apt install docker.io

(2) 安裝用于定義和運(yùn)行多容器 Docker 應(yīng)用程序的工具

sudo apt install docker-compose

(3) 添加docker權(quán)限給當(dāng)前用戶,使docker命令免sudo

sudo gpasswd -a $USER docker

這時(shí),運(yùn)行docker info報(bào)錯(cuò),需要配置daemon遠(yuǎn)程訪問:

docker: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?

2、 配置遠(yuǎn)程Docker daemon訪問

/etc/profile的最下方添加配置信息

編輯profile文件,vi /etc/profile填加三行:

export DOCKER_HOST=tcp://192.168.99.100:2376

export DOCKER_CERT_PATH=/mnt/c/Users/{名}/.docker/machine/certs

export DOCKER_TLS_VERIFY=1

保存退出后,重新登錄用戶生效,再次運(yùn)行docker info等命令成功。

3、 實(shí)現(xiàn)windows命令行訪問ubuntu

每次需要進(jìn)入ubuntu系統(tǒng)操作還是比較麻煩,所以建議還是要配置其ssh以便于在windows命令行下就能夠連接到ubuntu操作相關(guān)命令。

sudo /etc/init.d/ssh start報(bào)錯(cuò),切換到root用戶執(zhí)行以下命令

#ssh-keygen -t dsa -f /etc/ssh/ssh_host_dsa_key    生成dsa認(rèn)證

#ssh-keygen -t rsa -f /etc/ssh/ssh_host_rsa_key     生成rsa認(rèn)證

#/usr/sbin/sshd       啟動(dòng)ssh服務(wù)

sudo systemctl enable ssh  讓ssh默認(rèn)自動(dòng)啟動(dòng)。

vi /etc/ssh/sshd_config

Port = 22 # 默認(rèn)是22端口,如果和windows端口沖突或你想換成其他的否則不用動(dòng)

#ListenAddress 0.0.0.0 # 如果需要指定監(jiān)聽的IP則去除最左側(cè)的井號,并配置對應(yīng)IP,默認(rèn)即監(jiān)聽PC所有IP

PermitRootLogin no # 如果你需要用 root 直接登錄系統(tǒng)則此處改為 yes

PasswordAuthentication no # 將 no 改為 yes 表示使用賬號密碼方式登錄

windows命令行下執(zhí)行  ssh  {用戶名}@ 192.168.99.1ssh  {用戶名}@ 192.168.56.1輸入密碼進(jìn)行Ubuntu子系統(tǒng)。

    轉(zhuǎn)藏 分享 獻(xiàn)花(0

    0條評論

    發(fā)表

    請遵守用戶 評論公約

    類似文章 更多