2.1 安裝Docker
Docker官方建議在Ubuntu中安裝,因為Docker是基於Ubuntu發布的,而且一般Docker出現的問題Ubuntu是最先更新或者打補丁的。在很多版本的CentOS中是不支持更新最新的一些補丁包的。
由於我們學習的環境都使用的是CentOS,因此這里我們將Docker安裝到CentOS上。注意:這里建議安裝在CentOS7.x以上的版本,在CentOS6.x的版本中,安裝前需要安裝其他很多的環境而且Docker很多補丁不支持更新。
(1)yum 包更新到最新:sudo yum update
(2)安裝需要的軟件包, yum-util 提供yum-config-manager功能,另外兩個是devicemapper驅動依賴的
sudo yum install -y yum-utils device-mapper-persistent-data lvm2
(3)設置yum源為阿里雲
sudo yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
(4)安裝docker
sudo yum install docker-ce
(5)安裝后查看docker版本
docker -v
2.2 設置ustc的鏡像
ustc是老牌的linux鏡像服務提供者了,還在遙遠的ubuntu 5.04版本的時候就在用。ustc的docker鏡像加速器速度很快。ustc docker mirror的優勢之一就是不需要注冊,是真正的公共服務。
[https://lug.ustc.edu.cn/wiki/mirrors/help/docker](https://lug.ustc.edu.cn/wiki/mirrors/help/docker)
編輯該文件:
vi /etc/docker/daemon.json
在該文件中輸入如下內容:
{ "registry-mirrors": ["https://docker.mirrors.ustc.edu.cn"] }
2.3 Docker的啟動與停止
systemctl命令是系統服務管理器指令
1.啟動docker:
systemctl start docker
2.停止docker:
systemctl stop docker
3.重啟docker:
systemctl restart docker
4.查看docker狀態:
systemctl status docker
5.開機啟動:
systemctl enable docker
6.查看docker概要信息
docker info
7.查看docker幫助文檔
docker --help