其他分享
首页 > 其他分享> > Docker部署问题

Docker部署问题

作者:互联网

之前学习了下怎么部署Docker,想自己实操下,就装了个CentOS7搞实操,这东西,不实操真的会不知道会面临多少的坑...

安装完系统之后……CentOS连net-tools和vim都没有,还得上网重新装...

#更新yum包

yum update

#安装需要的软件包, yum-utils 提供yum-config-manager功能,另外两个是devicemapper驱动依赖的

yum install -y yum-utils device-mapper-persistent-data lvm2

安装到上面的命令就出现了问题,查了一下原因是yum update之后没有安装yum-utils...

# 3、 设置yum源

yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo

# 4、 安装docker,出现输入的界面都按 y

yum install -y docker-ce

# 5、 查看docker版本,验证是否验证成功

docker -v

到这里没有问题

然后去阿里云找镜像加速器。

sudo mkdir -p /etc/docker
sudo tee /etc/docker/daemon.json <<-'EOF'
{
"registry-mirrors": ["https://WCNMDOCKER.mirror.aliyuncs.com"]
}
EOF
sudo systemctl daemon-reload
sudo systemctl restart docker

运行最后一条语句的时候出现了问题

[root@bogon docker]# systemctl daemon-reload
[root@bogon docker]# systemctl restart docker
Job for docker.service failed because the control process exited with error code. See "systemctl status docker.service" and "journalctl -xe" for details.
[root@bogon docker]# systemctl status docker.service
● docker.service - Docker Application Container Engine
   Loaded: loaded (/usr/lib/systemd/system/docker.service; disabled; vendor preset: disabled)
   Active: failed (Result: start-limit) since Sun 2022-03-20 23:51:51 EDT; 656ms ago
     Docs: https://docs.docker.com
  Process: 3832 ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock (code=exited, status=1/FAILURE)
 Main PID: 3832 (code=exited, status=1/FAILURE)

Mar 20 23:51:49 bogon systemd[1]: docker.service: main process exited, code=exited, status=1/FAILURE
Mar 20 23:51:49 bogon systemd[1]: Failed to start Docker Application Container Engine.
Mar 20 23:51:49 bogon systemd[1]: Unit docker.service entered failed state.
Mar 20 23:51:49 bogon systemd[1]: docker.service failed.
Mar 20 23:51:51 bogon systemd[1]: docker.service holdoff time over, scheduling restart.
Mar 20 23:51:51 bogon systemd[1]: Stopped Docker Application Container Engine.
Mar 20 23:51:51 bogon systemd[1]: start request repeated too quickly for docker.service
Mar 20 23:51:51 bogon systemd[1]: Failed to start Docker Application Container Engine.
Mar 20 23:51:51 bogon systemd[1]: Unit docker.service entered failed state.
Mar 20 23:51:51 bogon systemd[1]: docker.service failed.

然后就是一顿瞎JB弄

照着网上教程改了daemon.json文件内容,失败

照着网上教程把daemon.json文件改成daemon.conf,失败

照着网上教程该docker.service文件,还是失败

卸载,重装docker,失败中的失败

就差去研究docker配置文件了....

最后把“3138 ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/contai”这条放进百度里查,终于找到了问题原因

NMB内核过低!

13307 ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock (code=exited,_让代码飞~的博客-CSDN博客

学着更新内核改版本

当前CentOS内核版本

[root@bogon docker]# uname -r
3.10.0-123.el7.x86_64
[root@bogon docker]# uname -a
Linux bogon 3.10.0-123.el7.x86_64 #1 SMP Mon Jun 30 12:09:22 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux
[root@bogon docker]# cat /etc/redhat-release 
CentOS Linux release 7.9.2009 (Core)

随便找了一个blog学学升级内核...

Centos7升级内核 - 愤怒的小白~ - 博客园 

比如这个

摘两条命令放进去

#启用elrepo仓库

rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org

rpm -Uvh http://www.elrepo.org/elrepo-release-7.0-3.el7.elrepo.noarch.rpm

#安装最新版本内核

$ yum --enablerepo=elrepo-kernel install kernel-ml

#查看系统上的所有可用内核:

$ awk -F\' '$1=="menuentry " {print i++ " : " $2}' /etc/grub2.cfg

#通过 grub2-set-default 0 命令设置

#其中 0 是上面查询出来的可用内核

grub2-set-default 0

设置完成之后重启CentOS,当前内核版本

[root@bogon ~]# uname -r 
5.17.0-1.el7.elrepo.x86_64
[root@bogon ~]# uname -a
Linux bogon 5.17.0-1.el7.elrepo.x86_64 #1 SMP PREEMPT Sun Mar 20 16:57:12 EDT 2022 x86_64 x86_64 x86_64 GNU/Linux
[root@bogon ~]# cat /etc/redhat-release 
CentOS Linux release 7.9.2009 (Core)

 重启Docker

[root@bogon ~]# sudo systemctl restart docker
[root@bogon ~]# systemctl status docker.service
● docker.service - Docker Application Container Engine
   Loaded: loaded (/usr/lib/systemd/system/docker.service; disabled; vendor preset: disabled)
   Active: active (running) since Mon 2022-03-21 00:11:24 EDT; 19s ago
     Docs: https://docs.docker.com
 Main PID: 13029 (dockerd)
    Tasks: 10
   Memory: 129.7M
   CGroup: /system.slice/docker.service
           └─13029 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock

Mar 21 00:11:22 bogon dockerd[13029]: time="2022-03-21T00:11:22.280803828-04:00" level=warning msg="[graphdriver] WARNING: the devicemapper storag... release"
Mar 21 00:11:22 bogon dockerd[13029]: time="2022-03-21T00:11:22.318340270-04:00" level=warning msg="Your kernel does not support cgroup blkio weight"
Mar 21 00:11:22 bogon dockerd[13029]: time="2022-03-21T00:11:22.319277964-04:00" level=warning msg="Your kernel does not support cgroup blkio weight_device"
Mar 21 00:11:22 bogon dockerd[13029]: time="2022-03-21T00:11:22.321021727-04:00" level=info msg="Loading containers: start."
Mar 21 00:11:23 bogon dockerd[13029]: time="2022-03-21T00:11:23.239647477-04:00" level=info msg="Default bridge (docker0) is assigned with an IP a... address"
Mar 21 00:11:23 bogon dockerd[13029]: time="2022-03-21T00:11:23.714244359-04:00" level=info msg="Loading containers: done."
Mar 21 00:11:24 bogon dockerd[13029]: time="2022-03-21T00:11:24.233372871-04:00" level=info msg="Docker daemon" commit=7141c199a2 graphdriver(s)=d...n=19.03.7
Mar 21 00:11:24 bogon dockerd[13029]: time="2022-03-21T00:11:24.234022941-04:00" level=info msg="Daemon has completed initialization"
Mar 21 00:11:24 bogon dockerd[13029]: time="2022-03-21T00:11:24.314533439-04:00" level=info msg="API listen on /var/run/docker.sock"
Mar 21 00:11:24 bogon systemd[1]: Started Docker Application Container Engine.
Hint: Some lines were ellipsized, use -l to show in full.

目测成功了...

一个上午就搞了个这...

cao..

标签:11,bogon,00,Mar,部署,51,问题,Docker,docker
来源: https://blog.csdn.net/emmos/article/details/123632421