yum install -y yum-utils device-mapper-persistent-data lvm2yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repoyum install -y docker-ce## 创建 /etc/docker 目录
mkdir /etc/dockercat > /etc/docker/daemon.json <<EOF
{
"exec-opts": ["native.cgroupdriver=systemd"],
"log-driver": "json-file",
"log-opts": {
"max-size": "100m"
}
}
EOF
mkdir -p /etc/systemd/system/docker.service.d
# 重启docker服务
systemctl daemon-reload && systemctl restart docker && systemctl enable docker

踩坑:

报错、File contains no section headers. file: file:///etc/yum.repos.d/docker-ce.repo, line: 1

1、删除仓库:  rm -f /etc/yum.repos.d/*

2、设置阿里云镜像: wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo

3、yum clean all

4、sudo yum install -y yum-utils

5、sudo yum install docker-ce   安装了最新版的docker

6、sudo systemctl enable docker 设置开机启动

CENTOS环境DOCKER的正确安装及疑难杂症

根据官方文档:Install Docker Engine on CentOS | Docker Documentation搭建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.安装相关工具类:

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

这是由于国内访问不到docker官方镜像的缘故 
可以通过aliyun的源来完成:

sudo yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
出现以下内容则表示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

出现以下异常:
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

再执行docker的安装命令即可安装成功。

sudo yum install docker-ce

内容如下:

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

则会出现以下异常:

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'.

此错误也是网络问题:出现这个问题原因为国内网络问题,无法连接到 docker hub。 
配置阿里云的docker镜像库:在阿里云开通容器镜像服务拿到加速地址在执行以下命令:

也可以:

好在国内已经有  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服务:

$ sudo systemctl daemon-reload
$ sudo systemctl restart docker

再次验证docker:

sudo docker run hello-world

出现一下内容表示验证成功:

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/

原文地址:Centos环境docker的正确安装及疑难杂症 - 东邪西毒 - 博客园 (cnblogs.com)

最新版的docker安装相关推荐

  1. 史上最详细Docker安装最新版Minio 带详解 绝对值得收藏!!! 让我们一起学会使用minio搭建属于自己的文件服务器!!走上白嫖之路!解决启动了但是浏览器访问不了的原因

    让我们一起学会使用minio搭建属于自己的文件服务器!!走上白嫖之路! WARNING: Console endpoint is listening on a dynamic port (34451) ...

  2. 全网最细Docker安装Minio,填满最新版大坑(强烈推荐收藏)

    文章目录 前言 一.简介 二.安装步骤 1.查询minio服务版本 2.拉取minio 3.启动 4.docker hub下载其他版本 1.启动测试 三.下载安装旧版本 1.下载旧版本 2.启动 3. ...

  3. ubuntu18.04 安装(指定版本/最新版)docker与docker compose

    安装 Docker sudo apt-get remove docker docker-engine docker.io containerd runc # 卸载旧版本 sudo apt-get up ...

  4. Docker 安装最新版禅道16.5版本 原创

    Docker 安装最新版禅道16.5版本 原创 1下载禅道 2运行镜像 3.查看启动日志,可以看到启动成功: 下载禅道 docker pull idoop/zentao; 2.运行镜像 docker ...

  5. 最新版Arch系Linux中Manjaro Linux 的安装和使用,常用软件以及Docker安装

    Arch系Linux中Manjaro Linux 的安装和使用,常用软件以及Docker安装. 用十几年的Windows系统,一直觉得Linux比较复杂,实施上结果恰恰相反,对开发人员来说,Linux ...

  6. Docker(十):Docker实战 Docker 安装 Nginx

    Docker 安装 Nginx Nginx 是一个高性能的 HTTP 和反向代理 web 服务器,同时也提供了 IMAP/POP3/SMTP 服务 . 1.查看可用的 Nginx 版本 访问 Ngin ...

  7. Docker系列 七. Docker 安装Jenkins

    Docker系列 七. Docker 安装Jenkins Jenkins是一个开源软件项目,是基于Java开发的一种持续集成工具,用于监控持续重复的工作,旨在提供一个开放易用的软件平台,使软件的持续集 ...

  8. Docker系列 六. Docker 安装 Redis

    Docker 安装 Redis Redis 是一个开源的使用 ANSI C 语言编写.支持网络.可基于内存亦可持久化的日志型.Key-Value 的 NoSQL 数据库,并提供多种语言的 API . ...

  9. Docker系列 二. Docker 安装 Nginx

    Docker 安装 Nginx Nginx 是一个高性能的 HTTP 和反向代理 web 服务器,同时也提供了 IMAP/POP3/SMTP 服务 . 1.查看可用的 Nginx 版本 访问 Ngin ...

最新文章

  1. 数据库字符mysql_MySQL数据库之字符函数详解
  2. mysql--多实例启动方法
  3. matlab-片状图
  4. 在linux下tomcat报javax.net.ssl.SSLHandshakeException sun.security.validator.ValidatorException: PKIX
  5. linux基本知识2
  6. 主板螺丝是机箱配还是主板配_要配新电脑,A520主板和B450主板哪一个更加值得购买?...
  7. 感知器算法的基本原理和步骤_很多情况下,深度学习算法和人脑相似
  8. failed to keep to the max pss of 66560
  9. Spark记录-Scala记录(基础程序例子)
  10. 怎么删除已经安装的mysql_怎么样删除已经安装的mysql | wdlinux致力于Linux服务器架构,性能优化.免费CDN加速系统,免费智能DNS解析,负载均衡,集群分流...
  11. 小程序 php wecahtpay,PHP 微信公众号,小程序获取支付参数。微信支付
  12. 红皮书--With语句及布尔型
  13. Android 性能优化——之控件的优化
  14. 微信终端跨平台组件 mars 开源
  15. 【数字信号调制】基于matlab GUI PCM编码调制【含Matlab源码 453期】
  16. Linux上安装gcc
  17. prd文档 范例_PRD文档范例,产品经理值得收藏的写作手册
  18. ecplise和lomboz和tomcat配置
  19. python课设答辩ppt_学生成绩管理系统答辩幻灯片.ppt
  20. 2019游戏 f1_F1 2019

热门文章

  1. RISC-V嵌入式开发准备篇2:嵌入式开发的特点介绍
  2. 新鲜出炉 日常家用电器电磁辐射危险排行榜(iPad3 iMac)
  3. 嵌入式2.4内核上驱动USB无线网卡
  4. 何涛连忙叫请兄弟到 常用软件
  5. Adam学习25之读取sam生成的alignmentRecord含recordGroupDictionary
  6. 李思廉的“穷人逻辑”:给咸鱼卖个好价
  7. PMP学习笔记:采购合同类型
  8. Linux iptables nat 实现不同网络间(内外网)的互联
  9. 华铸DCcae80 铸铝 压铸软件.rar
  10. 汇编学习之nasm编译器下载使用