微信扫一扫 分享朋友圈

已有 1026 人浏览分享

开启左侧

docker 服务常见报错问题有哪些?

[复制链接]
1026 0
  1. 问题1: Error response from daemon: toomanyrequests: You have reached your pull rate limit. You may increase the limit by authenticating and upgrading: https://www.docker.com/increase-rate-limit
  2. docker pull 时报错,提示受限: Error response from daemon: toomanyrequests: You have reached your pull rate limit. You may increase the limit by authenticating and upgrading: https://www.docker.com/increase-rate-limit
  3. [root@localhost ~]# docker pull docker.io/eclipse-mosquitto
  4. Using default tag: latest
  5. Trying to pull repository docker.io/library/eclipse-mosquitto ...
  6. toomanyrequests: You have reached your pull rate limit. You may increase the limit by authenticating and upgrading: https://www.docker.com/increase-rate-limit
  7. [root@localhost ~]#
复制代码
原因:
DockerHub 从 2020 年 11 月 2 日,正式开始限制非付费用户的拉取频率:
匿名用户,每 6 小时只允许 pull 100 次
已登录用户,每 6 小时只允许 pull 200 次

解决办法:更换镜像配置、绕过限制
Azure:  https://dockerhub.azk8s.cn
中科大: https://ustc-edu-cn.mirror.aliyuncs.com
网易:   https://hub-mirror.c.163.com

vi /etc/docker/daemon.json
{
  "registry-mirrors": ["https://ustc-edu-cn.mirror.aliyuncs.com"]
}

重启服务
  1. systemctl daemon-reload
  2. systemctl restart docker
复制代码
重新执行 docker pull 成功了:
  1. [root@localhost ~]# docker pull docker.io/eclipse-mosquitto
  2. Using default tag: latest
  3. Trying to pull repository docker.io/library/eclipse-mosquitto ...
  4. latest: Pulling from docker.io/library/eclipse-mosquitto
  5. 97518928ae5f: Pull complete
  6. b491d2bad818: Pull complete
  7. 1c67a7209b6c: Pull complete
  8. Digest: sha256:64b7c1729f7d1fff46b5e884fc389071686b2f7ed116c3fc7e17cbcb50fa147e
  9. Status: Downloaded newer image for docker.io/eclipse-mosquitto:latest
  10. [root@localhost ~]#
复制代码
  1. [root@localhost ~]# docker pull docker.io/eclipse-mosquitto
  2. Using default tag: latest
  3. Trying to pull repository docker.io/library/eclipse-mosquitto ...
  4. latest: Pulling from docker.io/library/eclipse-mosquitto
  5. 97518928ae5f: Pull complete
  6. b491d2bad818: Pull complete
  7. 1c67a7209b6c: Pull complete
  8. Digest: sha256:64b7c1729f7d1fff46b5e884fc389071686b2f7ed116c3fc7e17cbcb50fa147e
  9. Status: Downloaded newer image for docker.io/eclipse-mosquitto:latest
  10. [root@localhost ~]#
复制代码
  1. 问题2: 启动docker服务失败: container-storage-setup: ERROR: Can not setup storage driver overlay2 as system does not support it. Specify a different driver.
  2. [root@localhost ~]# service docker start
  3. Redirecting to /bin/systemctl start docker.service
  4. Job for docker.service failed because the control process exited with error code. See "systemctl status docker.service" and "journalctl -xe" for details.
  5. [root@localhost ~]#
  6. [root@localhost ~]# service  docker status
  7. Redirecting to /bin/systemctl status docker.service
  8. ● docker.service - Docker Application Container Engine
  9.    Loaded: loaded (/usr/lib/systemd/system/docker.service; disabled; vendor preset: disabled)
  10.    Active: failed (Result: exit-code) since Fri 2022-04-01 16:09:29 CST; 6s ago
  11.      Docs: http://docs.docker.com
  12.   Process: 2300 ExecStart=/usr/bin/dockerd-current --add-runtime docker-runc=/usr/libexec/docker/docker-runc-current --default-runtime=docker-runc --exec-opt native.cgroupdriver=systemd --userland-proxy-path=/usr/libexec/docker/docker-proxy-current --init-path=/usr/libexec/docker/docker-init-current --seccomp-profile=/etc/docker/seccomp.json $OPTIONS $DOCKER_STORAGE_OPTIONS $DOCKER_NETWORK_OPTIONS $ADD_REGISTRY $BLOCK_REGISTRY $INSECURE_REGISTRY $REGISTRIES (code=exited, status=1/FAILURE)
  13. Main PID: 2300 (code=exited, status=1/FAILURE)

  14. Apr 01 16:09:29 localhost.localdomain systemd[1]: Starting Docker Application Container Engine...
  15. Apr 01 16:09:29 localhost.localdomain dockerd-current[2300]: unable to configure the Docker daemon with file /etc/docker/daemon.json: invalid character '}' look...y string
  16. Apr 01 16:09:29 localhost.localdomain systemd[1]: docker.service: main process exited, code=exited, status=1/FAILURE
  17. Apr 01 16:09:29 localhost.localdomain systemd[1]: Failed to start Docker Application Container Engine.
  18. Apr 01 16:09:29 localhost.localdomain systemd[1]: Unit docker.service entered failed state.
  19. Apr 01 16:09:29 localhost.localdomain systemd[1]: docker.service failed.
  20. Hint: Some lines were ellipsized, use -l to show in full.
  21. [root@localhost ~]#
  22. [root@localhost ~]# tail -20f /var/log/messages
  23. Apr  1 16:02:35 localhost NetworkManager[644]: <info>  (eno16777984): Activation: Stage 4 of 5 (IPv6 Configure Timeout) started...
  24. Apr  1 16:02:35 localhost NetworkManager[644]: <info>  (eno16777984): Activation: Stage 4 of 5 (IPv6 Configure Timeout) complete.
  25. Apr  1 16:09:29 localhost systemd: Starting Docker Storage Setup...
  26. Apr  1 16:09:29 localhost container-storage-setup: mount: wrong fs type, bad option, bad superblock on none,
  27. Apr  1 16:09:29 localhost container-storage-setup: missing codepage or helper program, or other error
  28. Apr  1 16:09:29 localhost container-storage-setup: In some cases useful info is found in syslog - try
  29. Apr  1 16:09:29 localhost container-storage-setup: dmesg | tail or so.
  30. Apr  1 16:09:29 localhost kernel: overlayfs: failed to resolve '/run/container-storage-setup//lower1:/run/container-storage-setup//lower2': -2
  31. Apr  1 16:09:29 localhost container-storage-setup: ERROR: Failed to run unshare -m mount -t overlay -o lowerdir=/run/container-storage-setup//lower1:/run/container-storage-setup//lower2,upperdir=/run/container-storage-setup//upper,workdir=/run/container-storage-setup//work none /run/container-storage-setup//merged
  32. Apr  1 16:09:29 localhost container-storage-setup: ERROR: Can not setup storage driver overlay2 as system does not support it. Specify a different driver.
  33. Apr  1 16:09:29 localhost systemd: docker-storage-setup.service: main process exited, code=exited, status=1/FAILURE
  34. Apr  1 16:09:29 localhost systemd: Failed to start Docker Storage Setup.
  35. Apr  1 16:09:29 localhost systemd: Unit docker-storage-setup.service entered failed state.
  36. Apr  1 16:09:29 localhost systemd: docker-storage-setup.service failed.
  37. Apr  1 16:09:29 localhost systemd: Starting Docker Application Container Engine...
  38. Apr  1 16:09:29 localhost dockerd-current: unable to configure the Docker daemon with file /etc/docker/daemon.json: invalid character '}' looking for beginning of object key string
  39. Apr  1 16:09:29 localhost systemd: docker.service: main process exited, code=exited, status=1/FAILURE
  40. Apr  1 16:09:29 localhost systemd: Failed to start Docker Application Container Engine.
  41. Apr  1 16:09:29 localhost systemd: Unit docker.service entered failed state.
  42. Apr  1 16:09:29 localhost systemd: docker.service failed.


  43. 查找资料:
  44. Docker storage drivers:
  45. Ideally, very little data is written to a container’s writable layer, and you use Docker volumes to write data. However, some workloads require you to be able to write to the container’s writable layer. This is where storage drivers come in.

  46. Docker supports several storage drivers, using a pluggable architecture. The storage driver controls how images and containers are stored and managed on your Docker host. After you have read the storage driver overview, the next step is to choose the best storage driver for your workloads. Use the storage driver with the best overall performance and stability in the most usual scenarios.
  47. The Docker Engine provides the following storage drivers on Linux:

  48. Driver:          Description
  49. overlay2:        overlay2 is the preferred storage driver for all currently supported Linux distributions, and requires no extra configuration.
  50. fuse-overlayfs:  fuse-overlayfsis preferred only for running Rootless Docker on a host that does not provide support for rootless overlay2. On Ubuntu and Debian 10, the fuse-overlayfs driver does not need to be used, and overlay2 works even in rootless mode. Refer to the rootless mode documentation for details.
  51. btrfs and zfs:   The btrfs and zfs storage drivers allow for advanced options, such as creating “snapshots”, but require more maintenance and setup. Each of these relies on the backing filesystem being configured correctly.
  52. vfs:             The vfs storage driver is intended for testing purposes, and for situations where no copy-on-write filesystem can be used. Performance of this storage driver is poor, and is not generally recommended for production use.
  53. aufs:            The aufs storage driver Was the preferred storage driver for Docker 18.06 and older, when running on Ubuntu 14.04 on kernel 3.13 which had no support for overlay2. However, current versions of Ubuntu and Debian now have support for overlay2, which is now the recommended driver.
  54. devicemapper:    The devicemapper storage driver requires direct-lvm for production environments, because loopback-lvm, while zero-configuration, has very poor performance. devicemapper was the recommended storage driver for CentOS and RHEL, as their kernel version did not support overlay2. However, current versions of CentOS and RHEL now have support for overlay2, which is now the recommended driver.
  55. overlay:         The legacy overlay driver was used for kernels that did not support the “multiple-lowerdir” feature required for overlay2 All currently supported Linux distributions now provide support for this, and it is therefore deprecated.

  56. The Docker Engine has a prioritized list of which storage driver to use if no storage driver is explicitly configured, assuming that the storage driver meets the prerequisites, and automatically selects a compatible storage driver. You can see the order in the source code for Docker Engine 20.10.

  57. Some storage drivers require you to use a specific format for the backing filesystem. If you have external requirements to use a specific backing filesystem, this may limit your choices. See Supported backing filesystems.

  58. 另外找到docker支持文件系统类型:
  59. Supported backing filesystems:

  60. With regard to Docker, the backing filesystem is the filesystem where /var/lib/docker/ is located. Some storage drivers only work with specific backing filesystems.

  61. Storage driver:    Supported backing filesystems
  62. overlay2, overlay:    xfs with ftype=1, ext4
  63. fuse-overlayfs:        any filesystem
  64. aufs:                  xfs, ext4
  65. devicemapper:          direct-lvm
  66. btrfs:                btrfs
  67. zfs:                  zfs
  68. vfs:                   any filesystem


  69. 问题原因:
  70. ERROR: Can not setup storage driver overlay2 as system does not support it. Specify a different driver.
  71. devicemapper was the recommended storage driver for CentOS and RHEL, as their kernel version did not support overlay2. However, current versions of CentOS and RHEL now have support for overlay2, which is now the recommended driver.
  72. RHEL或CentOS 使用新的 docker 存储驱动(overlay or overlay2),需要升级系统内核版本到3.10.0-514以上版本,否则不支持 overlay or overlay2 存储驱动。


  73. 我的docker配置的默认的存储驱动为 overlay2:
  74. cat /etc/sysconfig/docker-storage-setup
  75. STORAGE_DRIVER=overlay2

  76. cat /etc/sysconfig/docker-storage
  77. DOCKER_STORAGE_OPTIONS=


  78. 我的Centos7内核版本为:3.10.0-229,版本太低
  79. [root@localhost ~]# uname -a
  80. Linux localhost.localdomain 3.10.0-229.el7.x86_64 #1 SMP Fri Mar 6 11:36:42 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux

  81. 确认我的系统内核是否加载/支持 overlay2 模块/驱动:
  82. [root@localhost ~]# lsmod | grep overlay2
  83. [root@localhost ~]#
  84. [root@localhost ~]# lsmod | grep overlay
  85. overlay                37831  0

  86. 我的系统不支持 overlay2,仅支持 overlay

  87. 解决方案:
  88. 方案1)修改 docker 配置

  89. 修改docker启动文件,设置使用overlay 存储,添加选项 --storage-driver=overlay
  90. vi /etc/sysconfig/docker
  91. OPTIONS='--storage-driver=overlay --selinux-enabled --log-driver=journald --signature-verification=false'

  92. systemctl daemon-reload
  93. systemctl restart docker


  94. 方案2)不修改存储类型,升级内核版本,使用 overlay2
  95. Centos7 升级内核版本 for 支持  docker overlay2 存储驱动

  96. 升级软件和内核
  97. yum -y update
  98. 注意:升级所有软件,也会升级内核版本。注意:yum -y upgrade 和 yum -y update的区别,upgrade 只升级所有包,不升级软件和系统内核,update 升级所有包同时也升级软件和系统内核

  99. 内核升级完毕后,问题解决,docker 服务正常启动了

  100. [root@localhost ~]# systemctl  status docker
  101. ● docker.service - Docker Application Container Engine
  102.    Loaded: loaded (/usr/lib/systemd/system/docker.service; disabled; vendor preset: disabled)
  103.    Active: active (running) since Fri 2022-04-01 18:00:11 CST; 10min ago
  104.      Docs: http://docs.docker.com
  105. Main PID: 2604 (dockerd-current)
  106.    CGroup: /system.slice/docker.service
  107.            ├─2604 /usr/bin/dockerd-current --add-runtime docker-runc=/usr/libexec/docker/docker-runc-current --default-runtime=docker-runc --exec-opt native.cgroupdrive...
  108.            └─2612 /usr/bin/docker-containerd-current -l unix:///var/run/docker/libcontainerd/docker-containerd.sock --metrics-interval=0 --start-timeout 2m --state-dir ...

  109. Apr 01 18:00:11 localhost.localdomain dockerd-current[2604]: time="2022-04-01T18:00:11.135550079+08:00" level=info msg="Loading containers: start."
  110. Apr 01 18:00:11 localhost.localdomain dockerd-current[2604]: time="2022-04-01T18:00:11.169777432+08:00" level=warning msg="Running modprobe bridge br_netfilter failed w...
  111. Apr 01 18:00:11 localhost.localdomain dockerd-current[2604]: time="2022-04-01T18:00:11.201924213+08:00" level=info msg="Firewalld running: false"
  112. Apr 01 18:00:11 localhost.localdomain dockerd-current[2604]: time="2022-04-01T18:00:11.385050677+08:00" level=info msg="Default bridge (docker0) is assigned wit...address"
  113. Apr 01 18:00:11 localhost.localdomain dockerd-current[2604]: time="2022-04-01T18:00:11.415252165+08:00" level=info msg="Loading containers: done."
  114. Apr 01 18:00:11 localhost.localdomain dockerd-current[2604]: time="2022-04-01T18:00:11.416744386+08:00" level=warning msg="Not using native diff for overlay2, t...rgument"
  115. Apr 01 18:00:11 localhost.localdomain dockerd-current[2604]: time="2022-04-01T18:00:11.488179968+08:00" level=info msg="Daemon has completed initialization"
  116. Apr 01 18:00:11 localhost.localdomain dockerd-current[2604]: time="2022-04-01T18:00:11.488227398+08:00" level=info msg="Docker daemon" commit="7d71120/1.13.1" g...n=1.13.1
  117. Apr 01 18:00:11 localhost.localdomain dockerd-current[2604]: time="2022-04-01T18:00:11.496220774+08:00" level=info msg="API listen on /var/run/docker.sock"
  118. Apr 01 18:00:11 localhost.localdomain systemd[1]: Started Docker Application Container Engine.
  119. Hint: Some lines were ellipsized, use -l to show in full.
  120. [root@localhost ~]#

  121. 另外:如果有条件的话,建议另外准备一块独立磁盘或者独立分区,加参数 -n ftype=1 格式化为 xfs 格式,然后将 /var/lib/docker 挂载上去
  122. 格式化:
  123. mkfs.xfs -f -n ftype=1 /dev/sdb2

  124. 查看磁盘信息
  125. lsblk -a -f

  126. 配置开启自动加载磁盘
  127. vi /etc/fstab
  128. UUID=c8c91281-1dc2-4da0-af06-c2f182c0ce03   /var/lib/docker                 xfs     defaults        0 0

  129. 手动挂载
  130. mount -a

  131. 修改docker启动文件,设置使用overlay 存储,添加选项 --storage-driver=overlay
  132. vi /etc/sysconfig/docker
  133. OPTIONS='--storage-driver=overlay --selinux-enabled --log-driver=journald --signature-verification=false'

  134. systemctl daemon-reload
  135. systemctl restart docker
  136. systemctl enable docker  #如果没有设置开启自启动docker,设置自启动服务

  137. uname -a
  138. docker version
  139. docker info
复制代码


免责声明:
1,海欣资源网所发布的资源由网友上传和分享,不保证信息的正确性和完整性,且不对因信息的不正确或遗漏导致的任何损失或损害承担责任。
2,海欣资源网的资源来源于网友分享,仅限用于学习交流和测试研究目的,不得将上述内容用于商业或者非法用途,否则,一切后果请用户自负。
3,海欣资源网所发布的资源由网友上传和分享,版权争议与本站无关,您必须在下载后的24个小时之内,从您的电脑中彻底删除上述内容。
4,如果您喜欢,请支持正版,购买正版,得到更好的正版服务,如有侵权,请联系我们删除并予以真诚的道歉,联系方式邮箱 haixinst@qq.com
海欣资源-企业信息化分享平台。
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

0

关注

0

粉丝

28

主题
热度排行
回复排行
最新贴子

Archiver|手机版|海欣资源 ( 湘ICP备2021008090号-1 )|网站地图

GMT+8, 2024-4-25 08:20 , Gzip On, MemCached On.

免责声明:本站所发布的资源和文章均来自网络,仅限用于学习交流和测试研究目的,不得将上述内容用于商业或者非法用途,否则,一切后果请用户自负。 本站信息来自网络,版权争议与本站无关,您必须在下载后的24个小时之内,从您的电脑中彻底删除上述内容。 如果您喜欢,请支持正版,购买正版,得到更好的正版服务,如有侵权,请联系我们删除并予以真诚的道歉。