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在线安装

  1. 首先运行 yum update
  2. 设置yum源
  3. yum install yum-utils -y
  4. yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
  5. 可以查看所有仓库中所有docker版本,并选择特定版本安装
  6. yum list docker-ce --showduplicates | sort -r
  7. 选择自己需要的版本安装,本人当时安装的docker-ce-18.06.1.ce
  8. yum install docker-ce-18.06.1.ce
  9. 查看版本,验证是否安装成功
  10. docker -v
  11. 启动运行
  12. systemctl start docker
  13. 查看运行状态,确实是运行状态
  14. systemctl status docker 
  15. 设置开机自启动
  16. systemctl enable docker

原文:https://cloud.tencent.com/developer/article/1605163

posted @   李世恒01  阅读(25)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 【译】Visual Studio 中新的强大生产力特性
· 2025年我用 Compose 写了一个 Todo App
· 张高兴的大模型开发实战:(一)使用 Selenium 进行网页爬虫
点击右上角即可分享
微信分享提示