记录一次docker安装遇到的坑

内网低版本内核linux服务器要安装docker

1.离线安装docker

        这一步没什么难度在网上找个安装包上传到服务器上按步骤安装

        安装地址:Index of linux/static/stable/x86_64/

        解压,然后将docker文件夹的内容复制到/usr/bin文件夹中便于平时启动

        最后注册成系统服务

        添加到service: 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


上述文件取自于:https://blog.csdn.net/qq_24442273/article/details/123786928

2.

        启动docker的时候遇到错误

AUFS was not found in /proc/filesystem,或者Failed to built-in GetDriver graph devicemapper /var/lib/docker

        FS,filesystem是linux所用的文件系统,低内核版本的linux一般使用的是overlay或者vfs和devicemapper。出现这种错误是因为启动docker时你的系统没有你所指定的文件系统类型。

解决方法为,在 /etc/docker/daemon.json里面指定"storage-driver"为你系统支持的fs

 

如果你的系统只有overlay的话可能又会遇到一个巨坑:

the backing xfs filesystem is formatted without d_type support

        

什么是d_type

d_type 是 Linux 内核的一个术语,表示 “目录条目类型”,而目录条目,其实是文件系统上目录信息的一个数据结构。d_type,就是这个数据结构的一个字段,这个字段用来表示文件的类型,是文件,还是管道,还是目录还是套接字等。

d_type 从 Linux 2.6 内核开始就已经支持了,只不过虽然 Linux 内核虽然支持,但有些文件系统实现了 d_type,而有些,没有实现,有些是选择性的实现,也就是需要用户自己用额外的参数来决定是否开启d_type的支持。

检查xfs文件系统是否支持d_type

[root@10-80-119-18 ~]# xfs_info /
meta-data=/dev/vda2              isize=256    agcount=9, agsize=2589248 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=0        finobt=0
data     =                       bsize=4096   blocks=20843184, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=0
log      =internal               bsize=4096   blocks=5057, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0

注意以上输出中的ftype字段,为0则表示不支持。

解决方案

  1. 指定docker的存储驱动类型为devicemapper,devicemapper不需要文件系统支持d_type,但docker官方目前推荐使用overlay2,因此不选择此方案。
  2. 重新格式化docker data-root目录所在的文件系统,xfs格式化时添加参数ftype=1,如下
mkfs.xfs -n ftype=1 /dev/mapper/vg_data-lv_data -f

上述关于d_type内容转自于:docker启动报错the backing xfs filesystem is formatted without d_type support - 安安

改为devicemapper方法我的服务器不支持devicemapper所以不行,因为是上线的服务器

不可能格式化root目录,所以两个方法都行不通。

所幸的是我的服务器还支持vfs,在daemon.json里面指定了"storage-driver"为"vfs"之后启动便不报关于FS的错误了。

3. iptable和filewall的冲突

最后还遇到了Failed to program NAT chain: INVALID_ZONE: docker这个问题,大致应该是因为iptable和filewall冲突导致,如果想解决得修改防火墙。线上环境不好修改,所以得另外的想方法

我这里指定了关闭docker的iptable功能之后成功终于成功启动

关闭方法:在/etc/docker/daemon.json中添加        "iptables":false

  • 2
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值