【Docker从入门到精通_1】Ubuntu16.04版本安装与配置
??本系列文章用于記錄個(gè)人Ubuntu16桌面版系統(tǒng)上Docker的學(xué)習(xí)與實(shí)戰(zhàn)。【本機(jī)的虛擬機(jī)VMware Pro 12,安裝Ubuntu18虛擬機(jī)失敗,在服務(wù)器上部署的時(shí)候是使用的Ubuntu18版本,演示和練習(xí)就使用Ubuntu16版本吧】
一、環(huán)境介紹
- Ubuntu 16.04 Desktop 64位版本
- Docker 默認(rèn)版本
二、Ubuntu 16.04下載與虛擬機(jī)安裝
Ubuntu16.04 64位版本下載地址: https://mirrors.tuna.tsinghua.edu.cn/ubuntu-releases/16.04.4/??
Ubuntu18.04 64位版本下載地址:?https://mirrors.tuna.tsinghua.edu.cn/ubuntu-releases/18.04/
?
虛擬機(jī)VMware 12 Pro版本:注冊(cè)碼:VY1DU-2VXDH-08DVQ-PXZQZ-P2KV8
官網(wǎng)地址:https://www.vmware.com/?
?三、虛擬機(jī)安裝Ubuntu16.04桌面版
VMware虛擬機(jī)的新建和安裝過程省略。內(nèi)存建議>2G,存儲(chǔ)空間建議>100G(后面相關(guān)的軟件很多)。虛擬機(jī)的設(shè)置參考如下圖:
?
?
虛擬機(jī)核數(shù)可以根據(jù)自己電腦的核數(shù)設(shè)置,例如下圖代表計(jì)算器是4核
?安裝配置Ubuntu過程如下:
直接選擇:Install Ubuntu
勾選下載更新,繼續(xù)
刪除磁盤的數(shù)據(jù),安裝ubutun,直接安裝
disk設(shè)置,默認(rèn)繼續(xù)即可
時(shí)區(qū)選擇
鍵盤布局,直接下一步
?設(shè)置虛擬機(jī)名稱和用戶信息:docker/docker 【安裝的時(shí)候如果窗口太小無法看到選項(xiàng),使用tab鍵切換選項(xiàng),Enter即可】
?
安裝完畢重啟
?
?四、Ubuntu 16的基本設(shè)置
0.克隆虛擬機(jī)
安裝完畢一臺(tái)虛擬機(jī)之后,為了拓展方便,可以先克隆一臺(tái)虛擬機(jī)做備份。
VMware中關(guān)閉虛擬機(jī)-選擇虛擬機(jī)-虛擬機(jī)-管理-克隆
?
?
clone成功后,虛擬機(jī)列表顯示克隆的機(jī)器
1.顯示器分辨率設(shè)置
登錄Ubuntu 16,打開All Settings-Displays-Resolution-Apply.設(shè)置合適的分辨率并保存
2.系統(tǒng)IP設(shè)置
All Settings-Network
打開設(shè)置選項(xiàng)
?勾選General中的這兩個(gè)選項(xiàng)
IPV4設(shè)置中,建議固定IP,使用DHCP也可以
? 3.啟用root用戶并設(shè)置密碼(以后裝服務(wù)的時(shí)候全部使用root賬戶)
查看Ubuntu的版本命令
?
root@docker:~# lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 16.04.4 LTS
Release: 16.04
Codename: xenial
?
$sudo passwd root?
輸入密碼,root有密碼是可以SSH遠(yuǎn)程登錄的基礎(chǔ)
4.開啟SSH服務(wù)并允許root用戶遠(yuǎn)程SSH登錄
- 進(jìn)入su賬戶
$su
$apt-get install openssh-server
- 啟動(dòng)ssh服務(wù)
$service ssh start/stop/restart
- 查看服務(wù)運(yùn)行,如果顯示,表示服務(wù)運(yùn)行中
$ps -ef | grep ssh
- 設(shè)置ssh服務(wù)為開機(jī)時(shí)自動(dòng)啟動(dòng)
$vi /etc/rc.local
在exit 0 之前添加 /etc/init.d ssh start
- 開啟root遠(yuǎn)程SSH登錄權(quán)限
$vi /etc/ssh/sshd_config
修改:"PermitRootLogin *" 修改成 "PermitRootLogin yes"
使用XShell通過root用戶遠(yuǎn)程登錄成功即可:
5.安裝vim
$sudo apt install vim
6.查看服務(wù)器啟動(dòng)的端口
$netstat -ntlp
7.阿里軟件源設(shè)置
默認(rèn)的Ubuntu的軟件源是在國外,安裝軟件的過程有點(diǎn)慢,可以添加阿里的Ubuntu軟件源,安裝軟件的過程會(huì)大大提速。
$vi /etc/apt/sources.list
在文件最前面追加如下信息:
deb http://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universe multiverse
?完整的sources.list如下:
1 #deb cdrom:[Ubuntu 16.04 LTS _Xenial Xerus_ - Release amd64 (20160420.1)]/ xenial main restricted 2 3 deb http://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse 4 deb http://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse 5 deb http://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiverse 6 deb http://mirrors.aliyun.com/ubuntu/ trusty-proposed main restricted universe multiverse 7 deb http://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universe multiverse 8 deb-src http://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse 9 deb-src http://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse 10 deb-src http://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiverse 11 deb-src http://mirrors.aliyun.com/ubuntu/ trusty-proposed main restricted universe multiverse 12 deb-src http://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universe multiverse 13 # See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to 14 # newer versions of the distribution. 15 deb http://cn.archive.ubuntu.com/ubuntu/ xenial main restricted 16 # deb-src http://cn.archive.ubuntu.com/ubuntu/ xenial main restricted 17 18 ## Major bug fix updates produced after the final release of the 19 ## distribution. 20 deb http://cn.archive.ubuntu.com/ubuntu/ xenial-updates main restricted 21 # deb-src http://cn.archive.ubuntu.com/ubuntu/ xenial-updates main restricted 22 23 ## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu 24 ## team, and may not be under a free licence. Please satisfy yourself as to 25 ## your rights to use the software. Also, please note that software in 26 ## universe WILL NOT receive any review or updates from the Ubuntu security 27 ## team. 28 deb http://cn.archive.ubuntu.com/ubuntu/ xenial universe 29 # deb-src http://cn.archive.ubuntu.com/ubuntu/ xenial universe 30 deb http://cn.archive.ubuntu.com/ubuntu/ xenial-updates universe 31 # deb-src http://cn.archive.ubuntu.com/ubuntu/ xenial-updates universe 32 33 ## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu 34 ## team, and may not be under a free licence. Please satisfy yourself as to 35 ## your rights to use the software. Also, please note that software in 36 ## multiverse WILL NOT receive any review or updates from the Ubuntu 37 ## security team. 38 deb http://cn.archive.ubuntu.com/ubuntu/ xenial multiverse 39 # deb-src http://cn.archive.ubuntu.com/ubuntu/ xenial multiverse 40 deb http://cn.archive.ubuntu.com/ubuntu/ xenial-updates multiverse 41 # deb-src http://cn.archive.ubuntu.com/ubuntu/ xenial-updates multiverse 42 43 ## N.B. software from this repository may not have been tested as 44 ## extensively as that contained in the main release, although it includes 45 ## newer versions of some applications which may provide useful features. 46 ## Also, please note that software in backports WILL NOT receive any review 47 ## or updates from the Ubuntu security team. 48 deb http://cn.archive.ubuntu.com/ubuntu/ xenial-backports main restricted universe multiverse 49 # deb-src http://cn.archive.ubuntu.com/ubuntu/ xenial-backports main restricted universe multiverse 50 51 ## Uncomment the following two lines to add software from Canonical's 52 ## 'partner' repository. 53 ## This software is not part of Ubuntu, but is offered by Canonical and the 54 ## respective vendors as a service to Ubuntu users. 55 # deb http://archive.canonical.com/ubuntu xenial partner 56 # deb-src http://archive.canonical.com/ubuntu xenial partner 57 58 deb http://security.ubuntu.com/ubuntu xenial-security main restricted 59 # deb-src http://security.ubuntu.com/ubuntu xenial-security main restricted 60 deb http://security.ubuntu.com/ubuntu xenial-security universe 61 # deb-src http://security.ubuntu.com/ubuntu xenial-security universe 62 deb http://security.ubuntu.com/ubuntu xenial-security multiverse 63 # deb-src http://security.ubuntu.com/ubuntu xenial-security multiverse resources.list8.同步數(shù)據(jù)源與系統(tǒng)更新升級(jí)
?設(shè)置完新的數(shù)據(jù)源之后,同步數(shù)據(jù)源并升級(jí)系統(tǒng)
$apt-get update
$apt-get upgrade
9.重啟虛擬機(jī)
重啟機(jī)器有多種命令:
>$reboot
>$init 6
>$shutdown -h now
10.init的7種級(jí)別
init一共分為7個(gè)級(jí)別,這7個(gè)級(jí)別的所代表的含義如下
0:停機(jī)或者關(guān)機(jī)(千萬不能將initdefault設(shè)置為0)
1:單用戶模式,只root用戶進(jìn)行維護(hù)
2:多用戶模式,不能使用NFS(Net File System)
3:完全多用戶模式(標(biāo)準(zhǔn)的運(yùn)行級(jí)別)
4:安全模式
5:圖形化(即圖形界面)
6:重啟(千萬不要把initdefault設(shè)置為6)
11.建立虛擬機(jī)快照
按照上述步驟設(shè)置完Ubuntu之后,建議建立快照。以便后面做docker及其他軟件安裝的異常的還原點(diǎn)。VMware建立快照的步驟:
?
轉(zhuǎn)載于:https://www.cnblogs.com/forfreewill/articles/9125180.html
總結(jié)
以上是生活随笔為你收集整理的【Docker从入门到精通_1】Ubuntu16.04版本安装与配置的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: JS 函数参数arguments对象(实
- 下一篇: Linux中基于eBPF的恶意利用与检测