安装Docker
环境准备
Contos7 xshell远程连接服务器
环境查看 查看自己环境
#系统内核是 3.10以上的
[root@Graht /]# uname -r
3.10.0-957.21.3.el7.x86_64
#系统版本
[root@Graht /]# 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、卸载旧的版本
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 device-mapper-persistent-data lvm2
#4、设置镜像仓库
#默认是国外的
yum-config-manager \
--add-repo \
https://download.docker.com/linux/centos/docker-ce.repo
#国内的
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
#更新yum软件包索引
yum makecache fast
#5、安装docker相关的内容 docker-ce 社区版 ee 企业版
yum install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
#启动docker
systemctl start docker
#6、使用docker version查看是否安装成功
#7、启动测试 hello-world
docker run hello-world
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-uz9AmZ2T-1646900824791)(C:\Users\43070\AppData\Roaming\Typora\typora-user-images\image-20220310154258951.png)]
#8、查看下载的hello-world镜像
[root@Graht ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
hello-world latest feb5d9fea6a5 5 months ago 13.3kB
了解 卸载 docker
#1、卸载依赖
yum remove docker-ce docker-ce-cli containerd.io
#2、删除所有的映像、容器和卷 [docker默认工作路径/var/lib/docker /var/lib/containerd]
rm -rf /var/lib/docker
rm -rf /var/lib/containerd
阿里云镜像加速
配置使用
sudo mkdir -p /etc/docker
sudo tee /etc/docker/daemon.json <<-'EOF'
{
"registry-mirrors": ["https://sve8z8qw.mirror.aliyuncs.com"]
}
EOF
sudo systemctl daemon-reload
sudo systemctl restart docker