Rainie999 发表于 2018-5-29 08:34:19

docker 疑难杂症

  一、kernel-4.6 无法创建container
  4.0内核,docker官方推荐的是overlay2 做storage driver,但是,xfs文件系统在4.0上与docker不能兼容,需要更改文件系统为ext4。

  github链接
  https://github.com/docker/docker/issues/23930
  最新github链接,有了解决方法,具体内核版本需要自行测试
  https://github.com/docker/docker/issues/22937#issuecomment-229807934
  

  关于xfs文件系统,官方有了新的说明
  centos 系统使用overlay,所以如果是xfs的文件系统,需要重新格式化
  系统默认格式化xfs是没有这个参数的,所以需要重新格式化添加参数,才能支持
mkfs.xfs -n ftype=1 /dev/sdxxxx  

  如果是kickstart 安装的系统,用如下命令:
logvol / --fstype xfs --mkfsoptions='-n ftype=1'  注意:如果用kickstart,iso/initd.img/vmlinuz 必须是同一版本,
--mkfsoptions  这个命令 从7.2才有,坑爹的是,官方文档说从rhel7就有了,结果我在7.1装了无数遍。。。。。。
  官方release 一定要仔细看。。。。
  https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/7/html/7.2_Release_Notes/index.html
  

  这个网址 是docker 取消的功能
  https://docs.docker.com/engine/deprecated/
  
  
  二、无法初始化docker
  centos6升级到7后,storage driver是overlay的,graph无法初始化,需要把文件系统从ext4换为xfs
  

  三、自定义docker配置(基于centos7)
  之前喜欢把/var/lib/docker软链到特定的目录,会有异常bug,比如plugin无法使用,所以抛弃软链
  自己有个性化的设置,需要改docker.service

  -g 指定docker目录
  -s 指定storage driver
  -H 指定socket,监听ip/端口号
sed -i '\/usr\/bin\/dockerd/aEnvironmentFile=/etc/sysconfig/docker' /usr/lib/systemd/system/docker.service
sed -i s'/dockerd/dockerd $OPTIONS/' /usr/lib/systemd/system/docker.service
echo 'OPTIONS="-g /data/docker -s overlay -H unix:///var/run/docker.sock -H 0.0.0.0:2375"' >/etc/sysconfig/docker

  四、device or resource busy
  有时候创建、删除、停止容器的时候,会报错如下:
$ docker start c39206003c7a
Error: Cannot start container c39206003c7a: Error getting container c39206003c7ae8992a554a9ac2ea130327fc4af1b2c389656c34baf9a56c84b5 from driver devicemapper: Error mounting '/dev/mapper/docker-253:0-267081-c39206003c7ae8992a554a9ac2ea130327fc4af1b2c389656c34baf9a56c84b5' on '/var/lib/docker/devicemapper/mnt/c39206003c7ae8992a554a9ac2ea130327fc4af1b2c389656c34baf9a56c84b5': device or resource busy
Error: failed to start one or more containers
$ docker rm c39206003c7a
Error: Cannot destroy container c39206003c7a: Driver devicemapper failed to remove root filesystem c39206003c7ae8992a554a9ac2ea130327fc4af1b2c389656c34baf9a56c84b5: Error running removeDevice
Error: failed to remove one or more containers  解决方式2种:
  4.1 出现问题一般是storage driver是devicemapper, 更换操作系统用Ubuntu的aufs或者redhat的overlay
  4.2 取消挂载
umount /var/lib/devicemapper/mnt/容器id  再删除/重启 就可以了
  

  五、docker - container里面 su 报错:Resource temporarily unavailable
  这个现象目前只在centos7出现过

docker exec -it 206f56b7da86 /bin/bash
# su - storm
su: /bin/bash: Resource temporarily unavailable  解决方式:
docker exec -it 206f56b7da86 /bin/bash
# cd /etc/pam.d/
# vi su  将里面session 的参数都改为optional
  例子:
#%PAM-1.0
auth            sufficient      pam_rootok.so
# Uncomment the following line to implicitly trust users in the "wheel" group.
#auth         sufficient      pam_wheel.so trust use_uid
# Uncomment the following line to require a user to be in the "wheel" group.
#auth         required      pam_wheel.so use_uid
auth            include         system-auth
account         sufficient      pam_succeed_if.so uid = 0 use_uid quiet
account         include         system-auth
password      include         system-auth
session         optional      system-auth
session         optional      pam_xauth.so
  
页: [1]
查看完整版本: docker 疑难杂症