Docker安装

Docker安装



前言

本文介绍了Docker在linux环境下的安装,还有相关镜像的配置。


安装前提条件

目前,CentOS 仅发行版本中的内核支持 Docker。Docker 运行在CentOS 7 (64-bit)上,
要求系统为64位、Linux系统内核版本为 3.8以上,这里选用Centos7.9

查看自己的内核
uname命令用于打印当前系统相关信息(内核版本号、硬件架构、主机名称和操作系统类型等)。
# uname -r
3.10.0-1160.el7.x86_64
# cat /etc/redhat-release
CentOS Linux release 7.9.2009 (Core)

安装步骤

yum安装gcc相关

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

安装需要的软件包

yum install -y yum-utils

设置stable镜像仓库

yum-config-manager  --add-repo 
https://download.docker.com/linux/centos/docker-ce.repo
#默认是从国外的,不推荐
#推荐使用国内的
yum-config-manager --add-repo 
    https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo


更新yum软件包索引

yum makecache fast

安装DOCKER CE

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

启动Docker

# systemctl start docker
查看docker信息
# docker version  
成功启动会显示版本信息

测试

# docker run hello-world
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.

阿里云镜像加速

登录阿里云网站,选择容器镜像服务
在这里插入图片描述
点击管理控制台
在这里插入图片描述
在镜像加速器中可以看到自己的加速器地址
在这里插入图片描述
按照网站提供的操作文档操作即可

mkdir -p /etc/docker
tee /etc/docker/daemon.json <<-'EOF'
{
  "registry-mirrors": ["https://{自已的编码}.mirror.aliyuncs.com"]
}
EOF
# 重启docker
systemctl daemon-reload
systemctl restart docker

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值