CentOS7安装docker

CentOS7安装docker

一、检查系统版本

bash 复制代码
cat /etc/redhat-release
bash 复制代码
CentOS Linux release 7.9.2009 (Core)

二、检查是否有旧docker

旧版本的 Docker 名称为dockerdocker-engine。在尝试安装新版本之前卸载任何此类旧版本以及相关的依赖项:

bash 复制代码
sudo yum remove docker \
                  docker-client \
                  docker-client-latest \
                  docker-common \
                  docker-latest \
                  docker-latest-logrotate \
                  docker-logrotate \
                  docker-engine

yum如果报告没有安装这些软件包,那也没关系。

bash 复制代码
已加载插件:fastestmirror, langpacks
参数 docker 没有匹配
参数 docker-client 没有匹配
参数 docker-client-latest 没有匹配
参数 docker-common 没有匹配
参数 docker-latest 没有匹配
参数 docker-latest-logrotate 没有匹配
参数 docker-logrotate 没有匹配
参数 docker-engine 没有匹配
不删除任何软件包

当您卸载 Docker 时,存储在其中的图像、容器、卷和网络/var/lib/docker/不会自动删除,需要手动删除。

三、安装docker

3.1、安装环境

bash 复制代码
# 更新yum软件包索引
yum makecache fast

yum -y install gcc
yum -y install gcc-c++
sudo yum install -y yum-utils

3.2、设置docker的安装源

bash 复制代码
# 国外源
yum-config-manager --add-repo http://download.docker.com/linux/centos/docker-ce.repo
# 阿里源
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo

3.3、安装docker

bash 复制代码
sudo yum install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

有y选y

四、设置docker服务

bash 复制代码
sudo systemctl start docker
ps -ef|grep docker

五、测试

bash 复制代码
sudo docker run hello-world

5.1、失败页面

可能会出现,这是因为还没有hello-world这个镜像。(不出现最好)

bash 复制代码
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
c1ec31eb5944: Pull complete 
Digest: sha256:ac69084025c660510933cca701f615283cdbb3aa0963188770b54c31c8962493
Status: Downloaded newer image for hello-world:latest

5.2、成功页面

bash 复制代码
Hello 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 the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:
 https://hub.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/get-started/

六、卸载docker

bash 复制代码
sudo yum remove docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin docker-ce-rootless-extras

主机上的图像、容器、卷或自定义配置文件不会自动删除。删除所有镜像、容器和卷:

bash 复制代码
sudo rm -rf /var/lib/docker
sudo rm -rf /var/lib/containerd
相关推荐
向日葵xyz3 分钟前
Qt5与现代OpenGL学习(十一)OpenGL Widget鼠标控制直线旋转
开发语言·qt·学习
快乐肚皮5 分钟前
深入解析Docker:核心架构与最佳实践
java·运维·docker·容器
Waitccy8 分钟前
Linux 系统安全基线检查:入侵防范测试标准与漏洞修复方法
linux·运维·网络·安全·系统安全·等保
鸿蒙布道师1 小时前
宇树科技安全漏洞揭示智能机器人行业隐忧
运维·网络·科技·安全·机器学习·计算机视觉·机器人
带鱼吃猫1 小时前
Linux系统:文件系统前言,详解CHS&LBA地址
linux·运维·服务器
aminghhhh1 小时前
多模态融合【十九】——MRFS: Mutually Reinforcing Image Fusion and Segmentation
人工智能·深度学习·学习·计算机视觉·多模态
默默提升实验室1 小时前
Linux 系统如何挂载U盘
linux·运维·服务器
Lw老王要学习2 小时前
Linux架构篇、第五章git2.49.0部署与使用
linux·运维·git·云计算·it
努力毕业的小土博^_^2 小时前
【深度学习|学习笔记】 Generalized additive model广义可加模型(GAM)详解,附代码
人工智能·笔记·深度学习·神经网络·学习
showmethetime2 小时前
搭建高可用及负载均衡的Redis
运维·redis·负载均衡