CentOS7 安装 Docker CE步骤

准备工作

系统要求  

  Docker CE 支持 64 位版本 CentOS 7,并且要求内核版本不低于 3.10。 CentOS 7 满足最低内核的要求,但由于内核版本比较低,部分功能(如 overlay2 存储层驱动) 无法使用,并且部分功能可能不太稳定。

卸载旧版本
  旧版本的 Docker 称为 docker 或者 docker-engine ,使用以下命令卸载旧版本: 

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

使用 yum 安装依赖包:(鉴于国内网络问题,强烈建议使用国内源)

#配置yum源sudo yum-config-manager --add-repo https://mirrors.ustc.edu.cn/docker-ce/linux/centos/docker-ce.repo
#安装依赖包sudo yum install -y yum-utils device-mapper-persistent-data lvm2

如果需要最新版本的 Docker CE 请使用以下命令:

sudo yum-config-manager --enable docker-ce-edge

如果需要测试版本的 Docker CE 请使用以下命令:

sudo yum-config-manager --enable docker-ce-test

安装 Docker CE

更新 yum 软件源缓存,并安装 docker-ce

sudo yum makecache fast
sudo yum install docker-ce

使用脚本自动安装
  在测试或开发环境中 Docker 官方为了简化安装流程,提供了一套便捷的安装脚本,CentOS
  系统上可以使用这套脚本安装:

curl -fsSL get.docker.com -o get-docker.sh
sudo sh get-docker.sh --mirror Aliyun

执行这个命令后,脚本就会自动的将一切准备工作做好,并且把 Docker CE 的 Edge 版本安
装在系统中。

启动 Docker CE

sudo systemctl enable docker
sudo systemctl start docker

建立 docker 用户组

建立 docker 组:

sudo groupadd docker

将当前用户加入 docker 组:

sudo usermod -aG docker $USER

退出当前终端并重新登录,进行如下测试。
测试 Docker 是否安装正确

docker run hello-worldUnable to find image ‘hello-world:latest‘ locallylatest: Pulling from library/hello-worldca4f61b1923c: Pull completeDigest: sha256:be0cd392e45be79ffeffa6b05338b98ebb16c87b255f48e297ec7f98e123905cStatus: 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://cloud.docker.com/For more examples and ideas, visit:https://docs.docker.com/engine/userguide/

若能正常输出以上信息,则说明安装成功。

镜像加速

  鉴于国内网络问题,后续拉取 Docker 镜像十分缓慢,强烈建议安装 Docker 之后配置 国内镜
  像加速。  

  在 /etc/docker/daemon.json 中写入如下内容(如果文件不存在请新建该文件) 

{
    "registry-mirrors": [
        "https://registry.docker-cn.com"
    ]
}

添加内核参数
  默认配置下,如果在 CentOS 使用 Docker CE 看到下面的这些警告信息:
    WARNING: bridge-nf-call-iptables is disabled
    WARNING: bridge-nf-call-ip6tables is disabled
  请添加内核配置参数以启用这些功能

sudo tee -a /etc/sysctl.conf <<-EOF
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
EOF

然后重新加载 sysctl.conf

sudo sysctl -p 



原文地址:https://www.cnblogs.com/myIvan/p/9534740.html

时间: 2024-08-29 09:59:47

CentOS7 安装 Docker CE步骤的相关文章

Centos7安装Docker CE

原文:Centos7安装Docker CE 每次安装Docker都要去找文档,或者每次安装的都不一样,还是要好好管理自己的这些东西,下次用的时候可以省很多的时间 Docker的早期版本称为docker或docker-engine:现在的Docker CE软件包称为docker-ce ; 环境 Centos7 安装脚本 #!/bin/bash #filename: install_docker.sh #Version: v1.0.0 #Author: LiLe #Date: 20190306 #C

Centos7 安装docker ce

一. 安装docker 1.升级rpm包 yum -y update 2. 通过命令设置Docker CE 资源库: yum install -y yum-utils yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo 3.生成缓存 sudo yum makecache fast 4.查看可下载版本 yum list docker-ce --showduplicates | s

Centos7 安装 Docker CE

安装 先安装 gcc sudo yum -y install gcc 如果有安装过 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 添加镜像仓库(这里

使用Centos7 安装docker的步骤

备份本机软件源 mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup 下载新的CentOS-Base.repo 到/etc/yum.repos.d/ CentOS 5 get -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-5.repo 或者 curl -o /etc/yum.repos.d/C

在Ubuntu14.04下安装Docker CE(1) - repository篇

从2017年3月开始,Docker开始分为社区版本和企业版,也就是Docker CE和Docker EE, 原来Ubuntu14.04下,通过sudo apt-get install docker.io来进行安装的方式已经过时了.在这里,会详细介绍如何在ubuntu14.04 LTS下安装Docker社区版,也就是Docker CE. 在开始之前,请确保你先做好一些前期准备工作,然后开始安装Docker. 前期准备工作 操作系统 安装Docker CE,你需要以下其中一种64位的Ubuntu操作

Centos7安装docker应用容器引擎

Docker 是一个开源的应用容器引擎,基于 Go 语言 并遵从Apache2.0协议开源. Docker 可以让开发者打包他们的应用以及依赖包到一个轻量级.可移植的容器中,然后发布到任何流行的 Linux 机器上,也可以实现虚拟化. 容器是完全使用沙箱机制,相互之间不会有任何接口(类似 iPhone 的 app),更重要的是容器性能开销极低. Docker的应用场景 Web 应用的自动化打包和发布. 自动化测试和持续集成.发布. 在服务型环境中部署和调整数据库或其他的后台应用. 从头编译或者扩

Ubuntu、Debian安装Docker CE

这篇文章介绍如何在Ubuntu和Debian系统上安装Docker CE(Docker 社区版),文章内容主要是从Docker官方文档中摘抄过来的. 官方文档:https://docs.docker.com/ 安装Docker CE之前,先要明确Docker CE只能安装在x64版本的系统上,不适用于x86版本的系统. 其次,Ubuntu系统要满足:Ubuntu >= 16.04 (LTS):Debian系统要满足:Debian >= Stretch 9 (stable). 较低的Linux发

Ubuntu 16.04安装docker详细步骤

因需要安装opendronemap,而这个依赖于docker,所以记录了一下安装docker的步骤,比较简单.通过apt的docker官方源安装最新的Docker CE(Community Edition),即Docker社区版,是开发人员和小型团队的理想选择. 开始安装 由于apt官方库里的docker版本可能比较旧,所以先卸载可能存在的旧版本: $ sudo apt-get remove docker docker-engine docker-ce docker.io 更新apt包索引: $

CentOS 7 安装Docker CE

本节内容: 背景 Moby项目 安装Docker CE 卸载Docker CE 一.背景 在搭建Registry的过程中,发现使用Docker 1.12版本,在push镜像到Registry时会报错误,几经查询解决之道无果后,去github的docker项目上提问,得到的回答是"Also note you appear running an unsupported version of docker which has changes specifically around how regist