docker 二进制安装

首先所属环境为内网并且服务器拥有的开发环境不确定,需要跑当前服务所需代码,所以优先选择使用docker

docker 文档地址
https://docs.docker.com

在 install 中存在 Install Docker Engine from binaries 二进制安装
https://download.docker.com/linux/static/stable/x86_64/  选择自己所需的docker 版本。
下载下来之后是一个 tar 压缩包。之后可以按照官网指令进行。
![](https://img2020.cnblogs.com/blog/1453789/202110/1453789-20211014210615188-673104747.png)

此时的docker 无法跟随服务器进行自启动,所以需要继续进行配置。

vi /usr/lib/systemd/system/docker.service #复制docker.service 内容

systemctl daemon-reload

systemctl start docker
systemctl status docker
systemctl enable docker

docker.service 内容 此内容为 https://www.runoob.com/docker/centos-docker-install.htmlcurl -sSL https://get.daocloud.io/docker | sh 安装的docker 所拥有的,更改了下 docker 镜像内容

[Unit]
Description=Docker Application Container Engine
Documentation=https://docs.docker.com
After=network-online.target firewalld.service containerd.service
Wants=network-online.target
# 此处需要删除 docker.socket 
# 参考此篇文章 https://www.cnblogs.com/fat-girl-spring/p/14236356.html
Requires=containerd.service

[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

# 服务器存储时最大存储空间为 /home 路径下,所以需要修改docker 镜像的存储位置
# 参考此篇文章修改 docker.service 的镜像存储位置 https://www.modb.pro/db/47890
ExecStart=/usr/bin/dockerd  --graph=/usr/local/docker/dockerd --containerd=/run/containerd/containerd.sock
ExecReload=/bin/kill -s HUP $MAINPID
TimeoutSec=0
RestartSec=2
Restart=always

# Note that StartLimit* options were moved from "Service" to "Unit" in systemd 229.
# Both the old, and new location are accepted by systemd 229 and up, so using the old location
# to make them work for either version of systemd.
StartLimitBurst=3

# Note that StartLimitInterval was renamed to StartLimitIntervalSec in systemd 230.
# Both the old, and new name are accepted by systemd 230 and up, so using the old name to make
# this option work for either version of systemd.
StartLimitInterval=60s

# 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

# Comment TasksMax if your systemd version does not support it.
# Only systemd 226 and above support this option.
TasksMax=infinity

# 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
OOMScoreAdjust=-500

[Install]
WantedBy=multi-user.target

** https://docs.docker.com
** https://www.modb.pro/db/47890
** https://www.runoob.com/docker/centos-docker-install.html
** https://www.cnblogs.com/fat-girl-spring/p/14236356.html

posted on   antor  阅读(507)  评论(0编辑  收藏  举报

编辑推荐:
· AI与.NET技术实操系列:基于图像分类模型对图像进行分类
· go语言实现终端里的倒计时
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
阅读排行:
· 25岁的心里话
· 闲置电脑爆改个人服务器(超详细) #公网映射 #Vmware虚拟网络编辑器
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· 零经验选手,Compose 一天开发一款小游戏!
· 一起来玩mcp_server_sqlite,让AI帮你做增删改查!!
点击右上角即可分享
微信分享提示