Linux下安装docker

1、查看系统版本

Docker支持64位版本的CentOS 7和CentOS 8及更高版本,它要求Linux内核版本不低于3.10。查看Linux版本的命令这里推荐两种:lsb_release -a或cat /etc/redhat-release。

显然,当前Linux系统为CentOS7。再查一下内核版本是否不低于3.10。

查看内核版本有三种方式:

  1. cat /proc/version
  2. uname -a
  3. uname -r

2、Docker安装

2.1: 安装必要的一些系统工具

sudo yum install -y yum-utils device-mapper-persistent-data lvm2

2.2: 添加软件源信息

sudo yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo

2.3: 更新yum索引列表并安装Docker引擎

sudo yum makecache fast

2.4:yum索引列表没有更新可以直接使用yum makecache

sudo yum install docker-ce

2.5:开启Docker服务

sudo service docker start

安装过程中会提示确认,输入y以确认

3.测试是否安装成功

4、配置下载docker镜像的仓库

docker的默认仓库Docker Hub下载速度在国内是很慢的,需要我们替换为阿里云的仓库。

打开阿里云的官网,搜索容器,找到容器与镜像服务。

进入容器与镜像服务页面,点击镜像加速器

  • 依据页面的提示,在Terminal中输入以下指令:

  • 这里注意registry-mirrors的地址每个人都是不一样的,要查看页面上显示的地址。

sudo mkdir -p /etc/docker

sudo tee /etc/docker/daemon.json <<-'EOF'

{

"registry-mirrors": ["https://xxxxxx.mirror.aliyuncs.com"]

}

EOF

sudo systemctl daemon-reload

sudo systemctl restart docker

5、测试HelloWorld镜像

在Terminal中输入docker run hello-world。看到 Hello from Docker! 字段说明我们的安装步骤没有问题,Docker已经成功安装~

相关推荐
沐雪轻挽萤几秒前
无人系统:Ubuntu 操作系统全景架构与实战工程指南
linux·运维·ubuntu
白緢8 分钟前
嵌入式 Linux + 内核开发高频问题及排查
java·linux·运维
学编程就要猛9 分钟前
JavaEE初阶:网络编程
运维·服务器·网络
hughnz14 分钟前
钻井自动化案例研究
运维·自动化
ILL11IIL19 分钟前
Docker容器技术
运维·docker·容器
蜡笔小新..20 分钟前
Linux下Matplotlib使用Times New Roman字体的解决方案
linux·运维·matplotlib
飞yu流星23 分钟前
文件压缩、文本内容、文本编辑
运维·服务器
洪流之源30 分钟前
图像格式转换与内存对齐详解
linux
二宝哥30 分钟前
Failed connect to mirrorlist.centos.org:80; Connection refused
linux·运维·centos
humors22142 分钟前
一些安全类网站(不定期更新)
linux·网络·windows·安全·黑客·白帽