參考 https://juejin.im/post/5e3032575188252c6e182a55
軟件更新
把相關(guān)軟件都更新
yum update
卸載舊版本
yum remove docker \
docker-client \
docker-client-latest \
docker-common \
docker-latest \
docker-latest-logrotate \
docker-logrotate \
docker-engine
安裝yum-utils
軟件包(提供yum-config-manager
實(shí)用程序)并設(shè)置穩(wěn)定的存儲(chǔ)庫(kù)踱侣。
yum install -y yum-utils
yum-config-manager \
--add-repo \
https://download.docker.com/linux/centos/docker-ce.repo
出現(xiàn)錯(cuò)誤
添加倉(cāng)庫(kù)自:https://download.docker.com/linux/centos/docker-ce.repo
Curl error (28): Timeout was reached for https://download.docker.com/linux/centos/docker-ce.repo [Connection timed out after 30001 milliseconds]
錯(cuò)誤:配置倉(cāng)庫(kù)失敗
添加阿里云倉(cāng)庫(kù)
yum-config-manager \
--add-repo \
https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
查看Docker
版本
yum list docker-ce --showduplicates | sort -r
安裝Docker
報(bào)錯(cuò)
[root@localhost ~]# yum install docker-ce
Repository extras is listed more than once in the configuration
Repository centosplus is listed more than once in the configuration
Repository PowerTools is listed more than once in the configuration
Repository AppStream is listed more than once in the configuration
上次元數(shù)據(jù)過(guò)期檢查:0:00:38 前,執(zhí)行于 2020年01月28日 星期二 17時(shí)02分33秒惕橙。
錯(cuò)誤:
問(wèn)題: package docker-ce-3:19.03.5-3.el7.x86_64 requires containerd.io >= 1.2.2-3, but none of the providers can be installed
- cannot install the best candidate for the job
- package containerd.io-1.2.10-3.2.el7.x86_64 is excluded
- package containerd.io-1.2.2-3.3.el7.x86_64 is excluded
- package containerd.io-1.2.2-3.el7.x86_64 is excluded
- package containerd.io-1.2.4-3.1.el7.x86_64 is excluded
- package containerd.io-1.2.5-3.1.el7.x86_64 is excluded
- package containerd.io-1.2.6-3.3.el7.x86_64 is excluded
(嘗試添加 '--skip-broken' 來(lái)跳過(guò)無(wú)法安裝的軟件包 或 '--nobest' 來(lái)不只使用最佳選擇的軟件包)
這個(gè)時(shí)候需要安裝containerd.io
玉组,我們可以到這個(gè)網(wǎng)站https://download.docker.com/linux/centos/7/x86_64/stable/Packages/,找到最新的去安裝
[root@localhost ~]# dnf install https://download.docker.com/linux/centos/7/x86_64/stable/Packages/containerd.io-1.2.6-3.3.el7.x86_64.rpm
報(bào)錯(cuò):
Timeout was reached for https://download.docker.com/linux/centos/7/x86_64/stable/Packages/containerd.io-1.2.6-3.3.el7.x86_64.rpm [Connection timed out after 30000 milliseconds]
Curl error (28): Timeout was reached for https://download.docker.com/linux/centos/7/x86_64/stable/Packages/containerd.io-1.2.6-3.3.el7.x86_64.rpm [Connection timed out after 30000 milliseconds]
解決方法:換成國(guó)內(nèi)的源
[root@localhost yum.repos.d]# dnf install https://mirrors.aliyun.com/docker-ce/linux/centos/7/x86_64/stable/Packages/containerd.io-1.2.6-3.3.el7.x86_64.rpm
繼續(xù)進(jìn)行安裝
[root@localhost ~]# yum install docker-ce docker-ce-cli
啟動(dòng)Docker
,并設(shè)置為開(kāi)機(jī)自啟
[root@localhost ~]# systemctl start docker
[root@localhost ~]# systemctl enable docker
Created symlink /etc/systemd/system/multi-user.target.wants/docker.service → /usr/lib/systemd/system/docker.service.
啟動(dòng)docker服務(wù)遠(yuǎn)程允許訪問(wèn)
1盖腕、編輯服務(wù)器上的docker.service文件
vi /usr/lib/systemd/system/docker.service
大約 在 14行 原來(lái)的值
ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
修改為
ExecStart=/usr/bin/dockerd -H fd:// -H tcp://0.0.0.0:2375 -H unix://var/run/docker.sock
2妨退、保存修改退出,重啟docker
systemctl daemon-reload
service docker restart
3锭魔、測(cè)試遠(yuǎn)程連接是否正常 輸出下面的內(nèi)容 如果出現(xiàn)以下內(nèi)容則能正常連接:
curl http://localhost:2375/version
{"Platform":{"Name":"Docker Engine - Community"},"Components":[{"Name":"Engine","Version":"19.03.9","Details":{"ApiVersion":"1.40","Arch":"amd64","BuildTime":"2020-05-15T00:24:05.000000000+00:00","Experimental":"false","GitCommit":"9d988398e7","GoVersion":"go1.13.10","KernelVersion":"4.18.0-147.el8.x86_64","MinAPIVersion":"1.12","Os":"linux"}},{"Name":"containerd","Version":"1.2.6","Details":{"GitCommit":"894b81a4b802e4eb2a91d1ce216b8817763c29fb"}},{"Name":"runc","Version":"1.0.0-rc8","Details":{"GitCommit":"425e105d5a03fabd737a126ad93d62a9eeede87f"}},{"Name":"docker-init","Version":"0.18.0","Details":{"GitCommit":"fec3683"}}],"Version":"19.03.9","ApiVersion":"1.40","MinAPIVersion":"1.12","GitCommit":"9d988398e7","GoVersion":"go1.13.10","Os":"linux","Arch":"amd64","KernelVersion":"4.18.0-147.el8.x86_64","BuildTime":"2020-05-15T00:24:05.000000000+00:00"}
4例证、開(kāi)放端口
需要將2375端口進(jìn)行開(kāi)放才能被遠(yuǎn)程連接,如果是阿里云主機(jī)的話迷捧,可以直接登錄阿里云去進(jìn)行開(kāi)放织咧。
如果是虛擬機(jī)的話,可以用以下命令進(jìn)行開(kāi)放:
firewall-cmd --zone=public --add-port=2375/tcp --permanent
如果是虛擬機(jī) 也可以暫時(shí) 關(guān)閉 防火墻
查看防火墻運(yùn)行狀態(tài)
firewall-cmd --state
running
running 表示正在 運(yùn)行
關(guān)閉防火墻命令
systemctl stop firewalld
本機(jī) 瀏覽器上輸入 http://192.168.1.98:2375/version
有返回結(jié)果党涕,則可以正常使用了
在idea中 正常連接了