Docker在线安装之Centos

本文详细介绍了在CentOS 6.8和CentOS 7环境下安装及配置Docker的过程,包括安装必要的软件包、配置仓库、启动Docker服务、验证版本以及配置镜像源等关键步骤。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

一、系统环境,CentOS6.8 x64

#Docker使用EPEL发布,RHEL系的OS首先要确保已经持有EPEL仓库,否则先检查OS版本,安装相应的EPEL库
# 1、安装库
yum install -y epel-release

# 2、安装Docker
yum install -y docker-io

# 3、修改配置文件
vi /etc/sysconfig/docker

# 4、启动Docker
service docker start

# 5、版本验证
docker version


# 6、配置文件
/etc/sysconfig/docker
# 7、查看当前使用的源
ps -ef|grep docker

二、系统环境,CentOS 7 x64

# 1、安装必要的容器包yum-utils,device-mapper-persistent-data,lvm2
yum install -y yum-utils device-mapper-persistent-data lvm2
# 2、下载官网的仓库配置到本地
# 官方解释:Use the following command to set up the stable repository.
# 不配置的话,第三点是找不到软件包安装的
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
# 有时国外地址会timeout端口,换阿里云的地址
# 阿里网址说明:https://yq.aliyun.com/articles/110806?spm=5176.8351553.0.0.4ef81991qSmbPA
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
#配置完毕之后,可以cat查看配置文件
cat /etc/yum.repos.d/docker-ce.repo
# 更新yum索引,可选
yum makecache fast
# 3、安装最新版的docker
yum install docker-ce docker-ce-cli containerd.io
# 4、启动docker
systemctl start docker
# 5、验证版本
docker -v

# 6、配置阿里镜像源(网易云同理)
vi /etc/docker/daemon.json
#把地址拷贝进去,可以在阿里云的容器镜像服务-镜像加速器获得
# 7、配置立即生效
systemctl daemon-reload
systemctl restart docker
# 8、查看是否生效
docker info
# 末尾有一行信息如下
# Registry Mirrors:
# https://pciypvna.mirror.aliyuncs.com/



############### 扩展 ######################
#列出当前可用版本
yum list docker-ce --showduplicates | sort -r
#下载特定版本
yum install docker-ce-<VERSION_STRING> docker-ce-cli-<VERSION_STRING> containerd.io

三、运行helloworld

#初次安装时没有这个镜像的,会从官方仓库下载最新的hello-world镜像
docker run hello-world
#以下为执行返回结果信息
[root@localhost ~]# docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
1b930d010525: Pull complete 
Digest: sha256:4fe721ccc2e8dc7362278a29dc660d833570ec2682f4e4194f4ee23e415e1064
Status: Downloaded newer image for hello-world:latest

Hello from Docker!
...

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值