大家好,又见面了,我是你们的朋友全栈君。
一、基础环境
- Centos 7环境
- 下载docker 包 ,我们演示的是19.3.12
下载地址
- 将下载好的压缩包上传至服务器下
二、开始安装
- 解压docker 包
tar -zxvf docker-19.03.12.tgz
- 将解压后的文件复制到/usr/bin下
cp docker/* /usr/bin
- 将docker注册为service
vi /etc/systemd/system/docker.service
复制下列配置到docker.service并保存(:wq)
[Unit]
Description=Docker Application Container EngineDocumentation=https://docs.docker.comAfter=network-online.target firewalld.serviceWants=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 dockerExecStart=/usr/bin/dockerdExecReload=/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=infinityLimitNPROC=infinityLimitCORE=infinity
# Uncomment TasksMax if your systemd version supports it.
# Only systemd 226 and above support this version.
#TasksMax=infinityTimeoutStartSec=0
# set delegate yes so that systemd does not reset the cgroups of docker containersDelegate=yes
# kill only the docker process, not all processes in the cgroupKillMode=process
# restart the docker process if it exits prematurelyRestart=on-failureStartLimitBurst=3StartLimitInterval=60s
[Install]
WantedBy=multi-user.target
三、启动docker
- 给配置文件添加权限
chmod +x /etc/systemd/system/docker.servi ce
- 重载配置文件
systemctl daemon-reload
- 启动Docker
systemctl start docker
- 设置开机自启
systemctl enable docker.service
Tip:如果报错检查Selinux是否关闭
四、关闭selinux
- 查看selinux是否启用
/usr/sbin/sestatus -v
- 关闭selinux(将状态修改为disabled)
vi /etc/selinux/config
- 重启系统生效
reboot
Tip:enabled 开启状态 disabled 关闭状态
五、docker portainer开启
上传portainer包https://download.csdn.net/download/qq_27884227/85501735
docker load < portainer.tar
docker run -d -p 9000:9000 --restart=always -v /var/run/docker.sock:/var/run/docker.sock --name dockerui portainer:v19.0.3
六、安装docker-compose
将docker-compose文件上传到 /usr/local/bin
修改权限并查看版本
sudo chmod +x /usr/local/bin/docker-compose
docker-compose -v
七、docker 日志添加
vi /etc/docker/daemon.json
加入以下内容
{
"log-driver":"json-file",
"log-opts":{
"max-size" :"100m","max-file":"1"}
}
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/189285.html原文链接:https://javaforall.cn
未经允许不得转载:便宜VPS » Docker离线安装教程「建议收藏」