Docker 环境的部署
前言
本环境是基于 Centos 7.8 系统构建Docker-19.03.13环境
一、环境准备
环境要求
Centos 7.8 系统 cup:2*2 内存:4G 硬盘:20G
[root@node01 ~]# cat /etc/redhat-release
CentOS Linux release 7.8.2003 (Core)
[root@node01 ~]# uname -r
3.10.0-1127.el7.x86_64
[root@node01 ~]# free -m
total used free shared buff/cache available
Mem: 3770 287 3255 11 228 3255
Swap: 2047 0 2047
[root@node01 ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 20G 0 disk
├─sda1 8:1 0 1G 0 part /boot
└─sda2 8:2 0 19G 0 part
├─centos-root 253:0 0 17G 0 lvm /
└─centos-swap 253:1 0 2G 0 lvm [SWAP]
sr0 11:0 1 4.5G 0 rom /mnt
关闭防火墙、禁用selinux
[root@node02 ~]# systemctl stop firewalld.service
[root@node02 ~]# setenforce 0
[root@node02 ~]# vim /etc/selinux/config
SELINUX=disabled
配置阿里云docker镜像源
具体配置详情参考:
阿里云docker镜像源
#安装必要的一些系统工具
[root@node02 ~]# yum install -y yum-utils device-mapper-persistent-data lvm2
#配置docker 软件安装源
[root@node02 ~]# yum-config-manager --add-repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
#生成yum源缓存
[root@node02 ~]# yum makecache fast
#查找Docker-CE的版本
[root@node02 ~]# yum list docker-ce.x86_64 --showduplicates | sort -r
二、部署 docker
#安装Docker-CE(最新版本)
[root@node02 ~]# yum -y install docker-ce
# 安装指定版本的Docker-CE: (VERSION例如上面的17.03.0.ce.1-1.el7.centos)
# yum -y install docker-ce-[VERSION]
启动服务,并设置开机自启
[root@node01 ~]# systemctl enable --now docker
查看docker版本
[root@node01 ~]# docker version
Client: Docker Engine - Community
Version: 19.03.13
API version: 1.40
Go version: go1.13.15
Git commit: 4484c46d9d
Built: Wed Sep 16 17:03:45 2020
OS/Arch: linux/amd64
Experimental: false
Server: Docker Engine - Community
Engine:
Version: 19.03.13
API version: 1.40 (minimum version 1.12)
Go version: go1.13.15
Git commit: 4484c46d9d
Built: Wed Sep 16 17:02:21 2020
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: 1.3.7
GitCommit: 8fba4e9a7d01810a393d5d25a3621dc101981175
runc:
Version: 1.0.0-rc10
GitCommit: dc9208a3303feef5b3839f4323d9beb36df0a9dd
docker-init:
Version: 0.18.0
GitCommit: fec3683
三、配置docker镜像加速器
参考文档
配置镜像加速器
[root@node01 ~]# vim /etc/docker/daemon.json
{
"registry-mirrors": ["https://docker.mirrors.ustc.edu.cn/"]
}
[root@node01 ~]# systemctl daemon-reload
[root@node01 ~]# systemctl restart docker