docker是一個(gè)開源的應(yīng)用容器引擎斟薇,讓開發(fā)者可以打包他們的應(yīng)用以及依賴包到一個(gè)可移植的鏡像中牛曹,然后發(fā)布到任何流行的 Linux或Windows操作系統(tǒng)的機(jī)器上角虫,也可以實(shí)現(xiàn)虛擬化预伺。
1 安裝過程
# 01 更新并安裝依賴
yum -y update
yum install -y conntrack ipvsadm ipset jq sysstat curl iptables libseccomp
# 02 卸載低版本的docker(如果存在的話)
sudo yum remove docker docker latest docker-latest-logrotate \
docker-logrotate docker-engine docker-client docker-client-latest docker-common
# 03 安裝必要依賴
sudo yum install -y yum-utils device-mapper-persistent-data lvm2
# 04 添加軟件源信息
sudo yum-config-manager \
--add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
yum list | grep docker-ce
# 05 更新yum緩存
sudo yum makecache fast
# 06 安裝docker茬故,可以指定安裝docker版本
sudo yum install -y docker-ce-18.09.0 docker-ce-cli-18.09.0 containerd.io
# 07 啟動docker并設(shè)置開機(jī)啟動
sudo systemctl start docker && sudo systemctl enable docker
# 08 測試docker安裝是否成功
sudo docker run hello-world
如果打印如下信息則提示安裝成功
Hello from Docker!
This message shows that your installation appears to be working correctly.
2 可能存在的問題
2.1 拉取不到鏡像
Unable to find image 'hello-world:latest' locally
docker: Error response from daemon: Get https://registry-1.docker.io/v2/library/hello-world/manifests/latest: Get https:
//auth.docker.io/token?scope=repository%3Alibrary%2Fhello-world%3Apull&service=registry.docker.io: net/http: request can
celed (Client.Timeout exceeded while awaiting headers).```
這個(gè)是因?yàn)槟J(rèn)使用國外的鏡像源,拉取鏡像會有問題氏涩,需要配置docker中國鏡像
創(chuàng)建或修改 /etc/docker/daemon.json 文件届囚,修改為如下內(nèi)容:
{
"registry-mirrors": [
"https://registry.docker-cn.com",
"http://hub-mirror.c.163.com",
"https://docker.mirrors.ustc.edu.cn",
"https://registry.cn-hangzhou.aliyuncs.com"
]
}
修改之后需要重啟一下docker
systemctl restart docker.service