CentOS上的安装与卸载Docker
一、 Docker的安装#
https://docs.docker.com/install/linux/docker-ce/centos/
CentOS7 上安装:#
1. 卸载旧版本
较旧的Docker版本称为docker
或docker-engine
。如果已安装这些程序,请卸载它们以及相关的依赖项。
1 2 3 4 5 6 7 8 | $ sudo yum remove docker \ docker-client \ docker-client-latest \ docker-common \ docker-latest \ docker-latest-logrotate \ docker-logrotate \ docker-engine |
2. 安装所需包
1 2 3 | $ sudo yum install -y yum-utils \ device-mapper-persistent-data \ lvm2 |
3. 设定稳定版存储库
1 2 3 | $ sudo yum-config-manager \ --add-repo \ https: //download .docker.com /linux/centos/docker-ce .repo |
4.安装稳定版
yum install docker-ce docker-ce-cli containerd.io
5. 安装指定版本
yum list docker‐ce ‐‐showduplicates | sort ‐r yum install docker-ce-<VERSION_STRING> docker-ce-cli-<VERSION_STRING> containerd.io
6. 检查是否安装成功
docker run hello-world
1 [root@app-01 ~]# docker run hello-world 2 Unable to find image 'hello-world:latest' locally 3 Trying to pull repository docker.io/library/hello-world ... 4 latest: Pulling from docker.io/library/hello-world 5 78445dd45222: Pull complete 6 Digest: sha256:c5515758d4c5e1e838e9cd307f6c6a0d620b5e07e6f927b07d05f6d12a1ac8d7 7 8 Hello from Docker! 9 This message shows that your installation appears to be working correctly. 10 11 To generate this message, Docker took the following steps: 12 1. The Docker client contacted the Docker daemon. 13 2. The Docker daemon pulled the "hello-world" image from the Docker Hub. 14 3. The Docker daemon created a new container from that image which runs the 15 executable that produces the output you are currently reading. 16 4. The Docker daemon streamed that output to the Docker client, which sent it 17 to your terminal. 18 19 To try something more ambitious, you can run an Ubuntu container with: 20 $ docker run -it ubuntu bash 21 22 Share images, automate workflows, and more with a free Docker ID: 23 https://cloud.docker.com/ 24 25 For more examples and ideas, visit: 26 https://docs.docker.com/engine/userguide/
CentOS6x上的安装:#
官方文档要求Linux kernel至少3.8以上,且docker只能运行在64位的系统中。CentOS6x的内核版本为2.6,因此必须要先升级内核。
1. 升级内核(带aufs模块)#
cd /etc/yum.repos.d
wget http://www.hop5.in/yum/el6/hop5.repo
yum install kernel-ml-aufs kernel-ml-aufs-devel
修改grub的主配置文件/etc/grub.conf,设置default=0,表示第一个title下的内容为默认启动的kernel(一般新安装的内核在第一个位置),将1改为0
重启,再查看内核
[root@wls12c ~]$ uname -r
3.10.5-3.el6.x86_64
查看是否支持aufs
[root@wls12c ~]$ grep aufs /proc/filesystems
nodev aufs
2. 首先关闭selinux:
#
setenforce 0
sed -i '/^SELINUX=/c\SELINUX=disabled' /etc/selinux/config
3. 在Fedora EPEL源中已经提供了docker-io包,下载安装epel:#
rpm -ivh http://mirrors.sohu.com/fedora-epel/6/x86_64/epel-release-6-8.noarch.rpm sed -i 's/^mirrorlist=https/mirrorlist=http/' /etc/yum.repos.d/epel.repo
4、安装docker-io:#
yum -y install docker-io
卸载#
1 2 | sudo yum remove docker-ce sudo rm -rf /var/lib/docker |
删除旧的内核
当前内核: uname -a
查看所有内核版本: rpm -qa | grep kernel
删除不需要的内核: yum remove kernel-2.6.32-693.el7.x86_64
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· Manus爆火,是硬核还是营销?
· 终于写完轮子一部分:tcp代理 了,记录一下
· 别再用vector<bool>了!Google高级工程师:这可能是STL最大的设计失误
· 单元测试从入门到精通
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
2015-08-23 64位Oracle 11g 使用PL/SQL