Linux CentOS7.X 安装Docker
个人编写整合仅供参考!
有在线安装跟离线安装
docker离线安装
1.从官方下载Docker安装包并上传 (此次安装版本为:docker-18.06.3-ce.tgz)
https://download.docker.com/linux/static/stable/x86_64/
2.解压安装包
tar -xvf docker-18.06.3-ce.tgz
3.将解压出来的docker文件内容移动到 /usr/bin/ 目录下
cp docker/* /usr/bin/
将docker注册为service服务
-bash: vim: 未找到命令
yum install vim
vim /etc/systemd/system/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
启动docker
chmod +x /etc/systemd/system/docker.service
systemctl daemon-reload
systemctl start docker #启动Docker
systemctl enable docker.service #设置开机自启
验证
systemctl status docker #查看Docker状态
docker -v #查看Docker版本
docker在线安装
- 首先运行 yum update
- 设置yum源
- yum install yum-utils -y
- yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
- 可以查看所有仓库中所有docker版本,并选择特定版本安装
- yum list docker-ce --showduplicates | sort -r
- 选择自己需要的版本安装,本人当时安装的docker-ce-18.06.1.ce
- yum install docker-ce-18.06.1.ce
- 查看版本,验证是否安装成功
- docker -v
- 启动运行
- systemctl start docker
- 查看运行状态,确实是运行状态
- systemctl status docker
- 设置开机自启动
- systemctl enable docker
原文:https://cloud.tencent.com/developer/article/1605163
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 【译】Visual Studio 中新的强大生产力特性
· 2025年我用 Compose 写了一个 Todo App
· 张高兴的大模型开发实战:(一)使用 Selenium 进行网页爬虫