Docker中有三个核心概念:镜像、容器和仓库。因此,准确把握这三大概念对于掌握Docker技术尤为重要。 1. 镜像(Image) Docker 镜像(Image),就相当于是一个 root 文件系统。 比如官方镜像 ubuntu:16.04 就包含了完整的一套 Ubuntu16.04 最小系统的 root 文件系统。 2. 容器(Container) 镜像(Image)和容器(Container)的关系,就像是面向对象程序设计中的类和实例一样, 镜像是静态的定义,容器是镜像运行时的实体。容器可以被创建、启动、停止、删除、暂停等。 3. 仓库(Repository) 用来保存镜像的仓库。当我们构建好自己的镜像之后,需要存放在仓库中, 当我们需要启动一个镜像时,可以在仓库中下载下来。二. 安装: 支持centos7+,内核3.0+ 完整安装命令:
# 备份原来YUN源 cp /etc/yum.repos.d/CentOS-base.repo /etc/yum.repos.d/CentOS-base.repo.bak # 更换YUM源 curl -o /etc/yum.repos.d/CentOS-base.repo https://mirrors.aliyun.com/repo/Centos-7.repo # 刷新yum源缓存 yum makecache # 更新系统 yum update -y --exclud=kernel* //排除不必要更新的. # 安装基础软件 yum install -y yum-utils device-mapper-persistent-data lvm2 # 使用阿里源安装 yum-config-manager --add-repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo # 更新并安装docker-ce yum makecache fast yum -y install docker-ce # 安装完成,使用命令查看安装位置 whereis docker # 启动并开机自启动: systemctl enable --now docker # 查看启动状态 docker info说明: 1. 备份yum源,使用阿里源
## 1. uname -a 查看内核是否支持 ## 2. 备份yum源,替换为阿里源 # 备份原来YUN源 cp /etc/yum.repos.d/CentOS-base.repo /etc/yum.repos.d/CentOS-base.repo.bak # 更换YUM源 curl -o /etc/yum.repos.d/CentOS-base.repo https://mirrors.aliyun.com/repo/Centos-7.repo # 刷新yum源缓存 yum makecache2. 更新系统,安装基础软件
# 2.1 更新系统 yum update -y --exclud=kernel* //排除不必要更新的. # 2.2 安装基础软件 yum install -y yum-utils device-mapper-persistent-data lvm23. 安装docker yum/ 更新并安装Docker-CE
ce:社区版,免费使用,中小企业
ee:企业版,花钱,功能较多
# 1. yum-config-manager --add-repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo # 2. 更新并安装docker-ce yum makecache fast yum -y install docker-ce # 3. 安装完成 # whereis docker docker: /usr/bin/docker /usr/libexec/docker /usr/share/man/man1/docker.1.gz4. 启动并设置开机自启动
# 启动 systemctl enable --now docker # 查看运行状态 docker info阿里云镜像加速器:
访问1. 的地址,有详细说明
1. 访问: https://cr.console.aliyun.com/cn-hangzhou/instances/mirrors
2. 配置镜像加速器
sudo mkdir -p /etc/docker
sudo tee /etc/docker/daemon.json <<-'EOF'
{
"registry-mirrors": ["https://lr3e0lji.mirror.aliyuncs.com"]
}
EOF
sudo systemctl daemon-reload
sudo systemctl restart docker



