日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 运维知识 > centos >内容正文

centos

Centos环境docker的正确安装及疑难杂症

發(fā)布時間:2025/6/17 centos 68 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Centos环境docker的正确安装及疑难杂症 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

根據(jù)官方文檔:https://docs.docker.com/install/linux/docker-ce/centos/搭建docker?
1.卸載docker舊版本:

sudo yum remove docker \docker-client \docker-client-latest \docker-common \docker-latest \docker-latest-logrotate \docker-logrotate \docker-selinux \docker-engine-selinux \docker-engine\

2.安裝相關(guān)工具類:

sudo yum install -y yum-utils \device-mapper-persistent-data \lvm2

3.配置docker倉庫:

sudo yum-config-manager \--add-repo \https://download.docker.com/linux/centos/docker-ce.repo 會報以下錯誤: Loaded plugins: fastestmirror adding repo from: https://download.docker.com/linux/centos/docker-ce.repo grabbing file https://download.docker.com/linux/centos/docker-ce.repo to /etc/yum.repos.d/docker-ce.repo Could not fetch/save url https://download.docker.com/linux/centos/docker-ce.repo to file /etc/yum.repos.d/docker-ce.repo : [Errno 14] curl#35 - "TCP connection reset by peer

這是由于國內(nèi)訪問不到docker官方鏡像的緣故?
可以通過aliyun的源來完成:

sudo yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo 出現(xiàn)以下內(nèi)容則表示docker倉庫配置成功: Loaded plugins: fastestmirror adding repo from: http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo grabbing file http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo to /etc/yum.repos.d/docker-ce.repo repo saved to /etc/yum.repos.d/docker-ce.repo

4.安裝docker

sudo yum install docker-ce 出現(xiàn)以下異常: Loaded plugins: fastestmirror base https://download-stage.docker.com/linux/centos/7/x86_64/stable/repodata/repomd.xml: [Errno 14] curl#35 - "TCP connection reset by peer" Trying other mirror.One of the configured repositories failed (Docker CE Stable - x86_64),and yum doesn't have enough cached data to continue. At this point the onlysafe thing yum can do is fail. There are a few ways to work "fix" this:1. Contact the upstream for the repository and get them to fix the problem.2. Reconfigure the baseurl/etc. for the repository, to point to a workingupstream. This is most often useful if you are using a newerdistribution release than is supported by the repository (and thepackages for the previous distribution release still work).3. Run the command with the repository temporarily disabledyum --disablerepo=docker-ce-stable ...4. Disable the repository permanently, so yum won't use it by default. Yumwill then just ignore the repository until you permanently enable itagain or use --enablerepo for temporary usage:yum-config-manager --disable docker-ce-stableorsubscription-manager repos --disable=docker-ce-stable5. Configure the failing repository to be skipped, if it is unavailable.Note that yum will try to contact the repo. when it runs most commands,so will have to try and fail each time (and thus. yum will be be muchslower). If it is a very temporary problem though, this is often a nicecompromise:yum-config-manager --save --setopt=docker-ce-stable.skip_if_unavailable=truefailure: repodata/repomd.xml from docker-ce-stable: [Errno 256] No more mirrors to try. https://download-stage.docker.com/linux/centos/7/x86_64/stable/repodata/repomd.xml: [Errno 14] curl#35 - "TCP connection reset by peer"

分析原因為:阿里的鏡像庫文件也指向docker官方庫,所以需要修改庫文件

sudo vim /etc/yum.repos.d/docker-ce.repo

通過命令把https://download-stage.docker.com替換為http://mirrors.aliyun.com/docker-ce

命令如下::%s#https://download-stage.docker.com#http://mirrors.aliyun.com/docker-ce#g

再執(zhí)行docker的安裝命令即可安裝成功。

sudo yum install docker-ce

內(nèi)容如下:

Installed:docker-ce.x86_64 0:18.03.0.ce-1.el7.centosDependency Installed:audit-libs-python.x86_64 0:2.7.6-3.el7 checkpolicy.x86_64 0:2.5-4.el7 container-selinux.noarch 2:2.42-1.gitad8f0f7.el7 libcgroup.x86_64 0libtool-ltdl.x86_64 0:2.4.2-22.el7_3 pigz.x86_64 0:2.3.3-1.el7.centos policycoreutils-python.x86_64 0:2.5-17.1.el7 python-IPy.noarchComplete!

5.驗證docker安裝成功:

啟動docker:

sudo systemctl start docker

驗證docker:

sudo docker run hello-world

則會出現(xiàn)以下異常:

Unable to find image 'hello-world:latest' locally latest: Pulling from library/hello-world 9bb5a5d4561a: Pulling fs layer docker: error pulling image configuration: Get https://dseasb33srnrn.cloudfront.net/registry-v2/docker/registry/v2/blobs/sha256/e3/e38bc07ac18e See 'docker run --help'.

此錯誤也是網(wǎng)絡(luò)問題:出現(xiàn)這個問題原因為國內(nèi)網(wǎng)絡(luò)問題,無法連接到 docker hub。?
配置阿里云的docker鏡像庫:在阿里云開通容器鏡像服務(wù)拿到加速地址在執(zhí)行以下命令:

也可以:

好在國內(nèi)已經(jīng)有 ?daocloud,docker指定該源即可。

vi /usr/lib/systemd/system/docker.service [Unit] Description=Docker Application Container Engine Documentation=https://docs.docker.com After=network-online.target firewalld.service Wants=network-online.target[Service] Type=notify # the default is not to use systemd for cgroups because the delegate issues still # exists and systemd currently does not support the cgroup feature set required # for containers run by docker ExecStart=/usr/bin/dockerd --registry-mirror=http://f2d6cb40.m.daocloud.io ExecReload=/bin/kill -s HUP $MAINPID # Having non-zero Limit*s causes performance problems due to accounting overhead # in the kernel. We recommend using cgroups to do container-local accounting. LimitNOFILE=infinity LimitNPROC=infinity LimitCORE=infinity # Uncomment TasksMax if your systemd version supports it. # Only systemd 226 and above support this version. #TasksMax=infinity TimeoutStartSec=0 # set delegate yes so that systemd does not reset the cgroups of docker containers Delegate=yes # kill only the docker process, not all processes in the cgroup KillMode=process # restart the docker process if it exits prematurely Restart=on-failure StartLimitBurst=3 StartLimitInterval=60s[Install] WantedBy=multi-user.target

重啟docker服務(wù):

$ sudo systemctl daemon-reload $ sudo systemctl restart docker

?

再次驗證docker:

sudo docker run hello-world

出現(xiàn)一下內(nèi)容表示驗證成功:

Unable to find image 'hello-world:latest' locally latest: Pulling from library/hello-world 9bb5a5d4561a: Pull complete Digest: sha256:f5233545e43561214ca4891fd1157e1c3c563316ed8e237750d59bde73361e77 Status: Downloaded newer image for hello-world:latestHello from Docker! This message shows that your installation appears to be working correctly.To generate this message, Docker took the following steps:1. The Docker client contacted the Docker daemon.2. The Docker daemon pulled the "hello-world" image from the Docker Hub.(amd64)3. The Docker daemon created a new container from that image which runs theexecutable that produces the output you are currently reading.4. The Docker daemon streamed that output to the Docker client, which sent itto your terminal.To try something more ambitious, you can run an Ubuntu container with:$ docker run -it ubuntu bashShare images, automate workflows, and more with a free Docker ID:https://hub.docker.com/ For more examples and ideas, visit:https://docs.docker.com/engine/userguide/

?

轉(zhuǎn)載于:https://www.cnblogs.com/liuyansheng/p/9203134.html

總結(jié)

以上是生活随笔為你收集整理的Centos环境docker的正确安装及疑难杂症的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。