centos7下安装docker

引言:之前零散学过docker,这次正式操作并记录在centos7,银河麒麟,uos下,如何在线离线安装docker服务。


1.yum在线安装

首先将yum源更换为阿里源,详细见:

CentOS7将yum源更换为阿里源-CSDN博客

# step 1: 安装必要的一些系统工具
sudo yum install -y yum-utils

# Step 2: 添加软件源信息
yum-config-manager --add-repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo

# Step 3: 安装Docker
sudo yum install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

# Step 4: 开启Docker服务
systemctl start docker 

参考:docker-ce镜像_docker-ce下载地址_docker-ce安装教程-阿里巴巴开源镜像站

2.rpm安装

rpm包下载:自行选择最新的就行

docker安装包:https://download.docker.com/linux/centos/7/x86_64/stable/Packages/docker-ce-26.1.4-1.el7.x86_64.rpm

containerd.io:https://download.docker.com/linux/centos/7/x86_64/stable/Packages/containerd.io-1.6.9-3.1.el7.x86_64.rpm

docker-ce-cli:https://download.docker.com/linux/centos/7/x86_64/stable/Packages/docker-ce-cli-26.1.4-1.el7.x86_64.rpm

container-selinux:https://mirrors.aliyun.com/centos/7.9.2009/extras/x86_64/Packages/container-selinux-2.119.2-1.911c772.el7_8.noarch.rpm


安装

rpm -ivh docker-ce-cli-26.1.4-1.el7.x86_64.rpm --nodeps --force
rpm -ivh container-selinux-2.119.2-1.911c772.el7_8.noarch.rpm --nodeps --force
rpm -ivh containerd.io-1.6.9-3.1.el7.x86_64.rpm --nodeps --force
rpm -ivh docker-ce-26.1.4-1.el7.x86_64.rpm --nodeps --force

启动

# 启动
systemctl start docker 
# 查看状态
systemctl status docker 

3.二进制安装(推荐安装)

官方文档:Binaries | Docker Docs

下载最新的安装包:

官方下载:Index of linux/static/stable/x86_64/

阿里云镜像下载:docker-ce-linux-static-stable-x86_64安装包下载_开源镜像站-阿里云

根据系统架构下载不同的版本,我下载的是x86_64下当前最新的docker-28.1.1.tgz版本。

#将下载的安装包,上传至/home目录
cd  /home
 
#解压安装包
tar -xvf docker-28.1.1.tgz
 
#将解压出来的文件复制到/usr/bin/目录下
cp docker/* /usr/bin

#注册自启动服务
vi /etc/systemd/system/docker.service

#docker.service内容
[Unit]
Description=Docker Application Container Engine
Documentation=https://docs.docker.com
After=network-online.target firewalld.service
Wants=network-online.target
[Service]
Type=notify
# the default is not to use systemd for cgroups because the delegate issues still
# exists and systemd currently does not support the cgroup feature set required
# for containers run by docker
ExecStart=/usr/bin/dockerd
ExecReload=/bin/kill -s HUP $MAINPID
# Having non-zero Limit*s causes performance problems due to accounting overhead
# in the kernel. We recommend using cgroups to do container-local accounting.
LimitNOFILE=infinity
LimitNPROC=infinity
LimitCORE=infinity
# Uncomment TasksMax if your systemd version supports it.
# Only systemd 226 and above support this version.
#TasksMax=infinity
TimeoutStartSec=0
# set delegate yes so that systemd does not reset the cgroups of docker containers
Delegate=yes
# kill only the docker process, not all processes in the cgroup
KillMode=process
# restart the docker process if it exits prematurely
Restart=on-failure
StartLimitBurst=3
StartLimitInterval=60s
[Install]
WantedBy=multi-user.target


# 加载服务
systemctl daemon-reload
# 设置开机自启
systemctl enable docker.service
# 启动Docker
systemctl start docker

# 查看Docker状态
systemctl status docker
# 查看Docker版本
docker -v

PS:

//查看系统整体的最后两百行日志
tail -200f /var/log/messages

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值