实践环境

Centos7.8

先决条件

CentOS 7.8。

必须开启 centos-extrasyum仓库源。默认是开启的,如果关闭了,需要重新开启,如下

编辑 /etc/yum.repos.d/CentOS-Base.repo,找到extras配置结点,修改enabled=1后,更新yum源

#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras&infra=$infra
#baseurl=http://mirror.centos.org/centos/$releasever/extras/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

推荐使用 overlay2存储驱动

安装方法

  • 大部分用户使用 Docker 仓库源 并从此源安装 ,为了更方便安装和升级,该方法是最推荐的
  • 有些用户下载RPM安装包,然后 手动安装,手动升级。如果目标机不能上网,这是个不错的选择。
  • 在测试和开发环境,部分用户选择使用安装官方提供给的方便 脚本 安装

使用Docker仓库源安装

第一次安装docker-ce之前,需要设置Docker仓库源。此后,基于该仓库源安装和升级

设置仓库源

安装 yum-utils 包(该软件包提供了yum-config-manager 工具),并且设置稳定版stable仓库源.

$ sudo yum install -y yum-utils
# ...略 $ 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
repo saved to /etc/yum.repos.d/docker-ce.repo

安装docker-ce

  1. 安装最新版本的docker-cecontainerd

    $ sudo yum install docker-ce docker-ce-cli containerd.io

    以上命令执行完成后,默认会创建docker组,但是不会添加任何用户到该组,不同方式安装都会创建该组,不再赘述

  2. 安装指定版本的docker-ce

    a. 按顺序显示repo库源中可获取的版本(例中为按版本从高到低排序):

    $ yum list docker-ce --showduplicates | sort -r
    
    docker-ce.x86_64  3:18.09.1-3.el7                     docker-ce-stable
    docker-ce.x86_64 3:18.09.0-3.el7 docker-ce-stable
    docker-ce.x86_64 18.06.1.ce-3.el7 docker-ce-stable
    docker-ce.x86_64 18.06.0.ce-3.el7 docker-ce-stable

    b. 安装指定版本的docker-ce

    $ sudo yum install docker-ce-<VERSION_STRING> docker-ce-cli-<VERSION_STRING> containerd.io

    例子:安装docker-ce-18.09.1.

    $ sudo yum install docker-ce-18.09.1 docker-ce-cli-18.09.1 containerd.io
  3. 启动 Docker

    安装完docker-ce后,会在/lib/systemd/system目录下生成docker.service

    $ sudo systemctl start docker
    $ sudo systemctl enable docker.service # 设置开机自启动

  4. 确认docker-ce是否正确安装

    可通过运行 sudo docker run hello-world命令测试Docker是否安装成功

    $ sudo docker run hello-world
    Unable to find image 'hello-world:latest' locally
    latest: Pulling from library/hello-world
    b8dfde127a29: Pull complete
    Digest: sha256:89b647c604b2a436fc3aa56ab1ec515c26b085ac0c15b0d105bc475be15738fb
    Status: Downloaded newer image for hello-world:latest Hello 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 the
    executable that produces the output you are currently reading.
    4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal. To try something more ambitious, you can run an Ubuntu container with:
    $ docker run -it ubuntu bash Share images, automate workflows, and more with a free Docker ID:
    https://hub.docker.com/ For more examples and ideas, visit:
    https://docs.docker.com/get-started/

    以上命令,会下载一个测试镜像,并在容器中运行它,当容器运行时,会线打印相关信息,然后退出

更新docker-ce

参考 安装指南

通过安装包安装

  1. 通过下载 .rpm 包,然后手工安装。下载地址:https://download.docker.com/linux/centos/ ,找到 x86_64/stable/Packages/目录下载目标版本的 .rpm

  2. rpm安装

    $ sudo yum install /path/to/package.rpm
  3. 其它剩余步骤同上,略

更新docker-ce

通过rpm -y update命令

通过脚本安装

卸载docker-ce

  1. 卸载docker-ce, CLI, 和 Containerd软件包

    $ sudo yum remove docker-ce docker-ce-cli containerd.io
  2. 手动移除镜像,容器,和数据卷,及其它自定配置文件

    删除所有镜像,容器,和数据卷:

    $ sudo rm -rf /var/lib/docker
    $ sudo rm -rf /var/lib/containerd

Docker Engine在Centos下的安装的更多相关文章

  1. Install Docker Engine on CentOS 在CentOS 7 上安装Docker

    Install Docker Engine on CentOS OS Requirements 系统要求 To install Docker Engine,you need a maintained ...

  2. Elasticsearch 在docker和centos下的安装教程

    前言 新版本的Elasticsearch不能以root用户来运行.因此,MAC下建议使用Docker来安装. 国内各版本镜像:点击这 Centos7.4 64位 第一步 下载.tar.gz的安装包 不 ...

  3. Docker在CentOS下的安装

    工欲善其事,必先利其器. 在我们以后的Docker学习中,都推荐使用CentOS6.5作为学习平台,毕竟Docker的内核也是基于Linux的.本文主要分享笔者在CentOS下的安装Docker的过程 ...

  4. Docker在linux系统下的安装

    系统要求 本安装教程仅限于CentOS7,其他系统不适用.centos-extras仓库必须是启用状态,这个仓库默认状态是启用,如果不是启用状态,请修改. 卸载旧版本的Docker Docker的旧版 ...

  5. centos 下yum 安装nginx

    centos 下yum 安装nginx 1. 直接yum install nginx不行,要先处理下源: rpm -ivh http://nginx.org/packages/centos/6/noa ...

  6. centos下编译安装lnmp

    centos下编译安装lnmp 本文以centos为背景在其中编译安装nginx搭建lnmp环境. 编译安装nginx时,需要事先安装 开发包组"Development Tools" ...

  7. CentOS下一键安装Openstack

    CentOS下一键安装Openstack 系统环境:Oracle VirtualBox 4.38CentOS-6.5-x86_64-bin-DVD1.iso 安装前需要修改 /etc/hosts文件, ...

  8. mac和centos下git安装

    mac下面的git安装,这篇文章写的很详细了http://www.cnblogs.com/ccdev/archive/2012/09/12/2682098.html 谈谈centos下的安装.我用的是 ...

  9. centOS下yum安装配置samba

     centOS下yum安装配置samba 2010-03-29 15:46:00 标签:samba yum centOS 安装 休闲 注意:本文的原则是只将文件共享应用于内网服务器,并让将要被共享的目 ...

  10. centos下apache安装后无法访问

    2013.11.28遇到的问题: -------------------------------------- 一.centos下apache安装后无法访问 得查一下防火墙的问题 iptables添加 ...

随机推荐

  1. OpenQA.Selenium.WebDriverException The HTTP request to the remote WebDriver server for URL timed out

    OpenQA.Selenium.WebDriverException:"The HTTP request to the remote WebDriver server for URL htt ...

  2. centos6 chkconfig的原理 和添加开机自启动的办法

    当我们使用 chkconfig --list的时候 都会又 123456 这样的级别. 当某个级别是 on 他就会开机启动,当他是off 的时候他就不会开机自启动. 那么这是什么原因呢?他的 原理是什 ...

  3. UILable在Autolayout模式下面自动调节字体大小

    一.需求 固定UILabel的宽度大小在一定范围,内容能够自动伸缩 二.实施 首先加好约束: 约束加好之后,需要设置好Autoshrink属性,包括Line break.BaseLine.以及缩小字体 ...

  4. sort awk 文本处理命令

    sort: 1.将文件的每一行作为一个单位,相互比较 2.默认升序 3.以字符来进行对比,从首字符开始往后,依次按ASCII码值排序 sort 显示文件内容 (类似cat) 选项: -u 去掉重复行 ...

  5. C# yyyyMMddHHmmss 格式的日期转换

    C# yyyyMMddHHmmss 格式的日期转换 DateTime dtTimeEnd = DateTime.Now; if (!string.IsNullOrWhiteSpace(rspA.fin ...

  6. mysql8 windows 数据库名 表名 大小写

    由于Apollo的SQL 脚本是大小写的.mysql8 默认又是纯小写的. 解决方法: 方法1.卸载MYSQL,重新安装MYSQL时,高级选项中指定区分大写小.这种会清空所有库和数据.不建议. 方法2 ...

  7. ObjectMapper Json字符串的转换处理

    package com.example.demo; import com.example.pojo.User; import com.fasterxml.jackson.annotation.Json ...

  8. Docker镜像下载慢/失败?Linux代理使用不便?想在无Docker环境下载镜像?试试我这款开源项目吧

    我要在这里放一段代码块 // 这是一段防爬代码块,我不介意被文章被爬取,但请注明出处 console.log("作者官网:https://www.hanzhe.site"); co ...

  9. Flutter 借助SearchDelegate实现搜索页面,实现搜索建议、搜索结果,解决IOS拼音问题

    搜索界面使用Flutter自带的SearchDelegate组件实现,通过魔改实现如下效果: 搜素建议 搜索结果,支持刷新和加载更多 IOS中文输入拼音问题 界面预览 拷贝源码 将SearchDele ...

  10. springboot+security自定义登录-1-基础-自定义用户和登录界面

    为何学习spring security? 理由如下: 1)虽然可以不用,但难免部分客户又要求 2)某种程度上,security还是不错的,譬如csrf,oauth等等,省了一些功夫. 3)虽然spri ...