Docker----CentOS7系统上Docker的安装与卸载

简介: Docker----CentOS7系统上Docker的安装与卸载

【原文链接】

一、环境准备

(1)系统内核需要3.10以上的

[root@localhost ~]# uname -r
3.10.0-1127.el7.x86_64

(2)查看一下当前系统,比如这里

[root@localhost ~]# 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"

(3)安装基础依赖

yum -y install gcc
yum -y install gcc-c++

二、安装

(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 \
    http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo

(4)安装docker

yum install -y docker-ce docker-ce-cli containerd.io

(5)启动docker

systemctl start docker

(6)验证docker安装完成

docker run hello-world

有如下打印,表示docker已经安装OK

[root@iZbp1flzt6x7pxmxfhmxeeZ ~]# docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
2db29710123e: Pull complete
Digest: sha256:2498fce14358aa50ead0cc6c19990fc6ff866ce72aeb5546e1d59caac3d0d60f
Status: Downloaded newer image for hello-world:latest

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/

[root@iZbp1flzt6x7pxmxfhmxeeZ ~]#

(7)查看docker安装版本

docker version

如下:

[root@iZbp1flzt6x7pxmxfhmxeeZ ~]# docker version
Client: Docker Engine - Community
 Version:           20.10.14
 API version:       1.41
 Go version:        go1.16.15
 Git commit:        a224086
 Built:             Thu Mar 24 01:49:57 2022
 OS/Arch:           linux/amd64
 Context:           default
 Experimental:      true

Server: Docker Engine - Community
 Engine:
  Version:          20.10.14
  API version:      1.41 (minimum version 1.12)
  Go version:       go1.16.15
  Git commit:       87a90dc
  Built:            Thu Mar 24 01:48:24 2022
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.5.11
  GitCommit:        3df54a852345ae127d1fa3092b95168e4a88e2f8
 runc:
  Version:          1.0.3
  GitCommit:        v1.0.3-0-gf46b6ba
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0
[root@iZbp1flzt6x7pxmxfhmxeeZ ~]#

三、卸载docker

(1)卸载docker

yum remove docker-ce docker-ce-cli containerd.io

(2)删除对应的文件

rm -rf /var/lib/docker
rm -rf /var/lib/containerd
目录
相关文章
|
1天前
|
安全 关系型数据库 MySQL
解决centos7.0安装mysql后出现access defind for user@'localhost'的错误
在使用yum 安装完mariadb, mariadb-server, mariadb-devel后
7 0
|
2天前
|
Linux 网络安全 数据安全/隐私保护
centos7安装gitlab-ce社区版全过程,详细到爆炸,这些面试官常问的开发面试题你都掌握好了吗
centos7安装gitlab-ce社区版全过程,详细到爆炸,这些面试官常问的开发面试题你都掌握好了吗
|
2天前
|
存储 Linux Docker
CentOS7修改Docker容器和镜像默认存储位置
CentOS7修改Docker容器和镜像默认存储位置
|
3天前
|
Ubuntu Linux Docker
window10下安装ubuntu系统以及docker使用
window10下安装ubuntu系统以及docker使用
|
4天前
|
NoSQL Linux Redis
在CentOS上安装和配置Redis
在CentOS上安装和配置Redis
46 0
|
4天前
|
安全 Linux 测试技术
在CentOS上安装Elasticsearch和Kibana
在CentOS上安装Elasticsearch和Kibana
11 0
|
4天前
|
Cloud Native 安全 Linux
【云原生之Docker实战】使用Docker部署mBlog微博系统
【5月更文挑战第10天】使用Docker部署mBlog微博系统
14 2
|
4天前
|
运维 Kubernetes 监控
本地CentOS安装轻量级容器PaaS平台KubeSphere并实现无公网IP远程访问
本地CentOS安装轻量级容器PaaS平台KubeSphere并实现无公网IP远程访问
6 0
|
4天前
|
JavaScript 前端开发 测试技术
Docker环境下部署Ghost开源内容管理系统
【5月更文挑战第9天】Docker环境下部署Ghost开源内容管理系统
13 0
|
4天前
|
Kubernetes Docker 容器
Docker 安装 Portainer
Portainer Community Edition是一个针对容器化应用程序的轻量级服务交付平台,可用于管理 Docker、Swarm、Kubernetes 和 ACI 环境。它的设计理念是部署和使用都简单,该应用程序允许您通过“智能”GUI 和/或广泛的 API 管理所有编排器资源。
42 3