Docker 安装
安装Docker
环境准备
1、centos 7
环境查看
[root@Lyle /] #uname -r
3.10.0-1062.12.1.e17.x86_64
#系统版本
[root@Lyle ~]# cat /etc/os-release
NAME="CentOS Linux"
VERSION="7 (Core)"
ID="centos"
ID_LIKE="rhel fedora"
VERSION_ID="7"
PRETTY_NAME="CentOS Linux 7 (Core)"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:centos:centos:7"
HOME_URL="https://www.centos.org/"
BUG_REPORT_URL="https://bugs.centos.org/"
CENTOS_MANTISBT_PROJECT="CentOS-7"
CENTOS_MANTISBT_PROJECT_VERSION="7"
REDHAT_SUPPORT_PRODUCT="centos"
REDHAT_SUPPORT_PRODUCT_VERSION="7"
安装
帮助文档
#1.卸载docker
yum remove docker \
docker-client \
docker-client-latest \
docker-common \
docker-latest \
docker-latest-logrotate \
docker-logrotate \
docker-engine
#2.需要的安装包
yum install -y yum-utils
#3.设置镜像仓库
yum-config-manager \
--add-repo \
https://download.docker.com/linux/centos/docker-ce.repo #默认国外
yum-config-manager \
--add-repo \
http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo #推荐使用阿里云
#更新
[root@Lyle ~]# yum makecache fast
#4.安装docker docker-ce 社区 ee企业版
yum install docker-ce docker-ce-cli containerd.io
#5.启动docker
[root@Lyle ~]# systemctl start docker
#6.使用docker version
#7.docker run hello-world
#8.查看一下下载hello-world镜像
[root@Lyle ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
hello-world latest bf756fb1ae65 8 months ago 13.3kB
了解:卸载docker
#1.删除依赖
yum remove docker-ce docker-ce-cli containerd.io
#2.删除资源
rm -rf /var/lib/docker
#/var/lib/docker docker的默认工作路径
阿里云镜像加速
1.登录阿里云找到容器服务
2.找到镜像加速地址
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-vKMHDOZp-1605839345675)(C:\Users\lenovo\AppData\Roaming\Typora\typora-user-images\image-20200901173510126.png)]
3.配置使用
sudo mkdir -p /etc/docker
sudo tee /etc/docker/daemon.json <<-'EOF'
{
"registry-mirrors": ["https://4fdld3q1.mirror.aliyuncs.com"]
}
EOF
sudo systemctl daemon-reload
sudo systemctl restart docker