当前位置: 首页 > news >正文

TencentOS Server 4.4 下创建mysql容器无法正常运行的问题

环境

腾讯的 TencentOS Server 4.4 服务器系统

Linux app 6.6.92-34.1.tl4.x86_64 #1 SMP PREEMPT_DYNAMIC Wed Jun 25 14:33:47 CST 2025 x86_64 x86_64 x86_64 GNU/Linux

docker使用的是yum安装的版本

[root@app ~]# docker version
Client:Version:           28.0.1-20241223130549-3b49debAPI version:       1.48Go version:        go1.24.4Git commit:        3b49debBuilt:             Mon Aug 11 09:03:23 2025OS/Arch:           linux/amd64Context:           defaultServer:Engine:Version:          28.0.1API version:      1.48 (minimum version 1.24)Go version:       go1.24.2Git commit:       %{_gitcommit_engine}Built:            Thu Jun 12 10:00:10 2025OS/Arch:          linux/amd64Experimental:     falsecontainerd:Version:          1.7.27GitCommit:        runc:Version:          1.1.14GitCommit:        docker-init:Version:          0.19.0GitCommit:        de40ad0

问题现象

docker创建的mysql 5.7.44容器(官方镜像)无法正常启动,隔几秒就重启

docker logs mysql 打印:

2025-08-27 15:45:46+08:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 5.7.44-1.el7 started.
2025-08-27 15:46:01+08:00 [ERROR] [Entrypoint]: mysqld failed while attempting to check configcommand was: mysqld --verbose --help --log-bin-index=/tmp/tmp.RBl3Hbmt6u2025-08-27 15:46:15+08:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 5.7.44-1.el7 started.
2025-08-27 15:46:26+08:00 [ERROR] [Entrypoint]: mysqld failed while attempting to check configcommand was: mysqld --verbose --help --log-bin-index=/tmp/tmp.hZa5kwNZnP2025-08-27 15:46:28+08:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 5.7.44-1.el7 started.
2025-08-27 15:46:37+08:00 [ERROR] [Entrypoint]: mysqld failed while attempting to check configcommand was: mysqld --verbose --help --log-bin-index=/tmp/tmp.6eeHXfFfzH2025-08-27 15:46:39+08:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 5.7.44-1.el7 started.
2025-08-27 15:46:48+08:00 [ERROR] [Entrypoint]: mysqld failed while attempting to check configcommand was: mysqld --verbose --help --log-bin-index=/tmp/tmp.lvQBb4Rtwb

进入到容器手动运行mysqld命令也没有有用的信息,会在光标卡一段时间后提示killed。

查找资料

很幸运谷歌到了一个issues:官方docker github里的issuse

里面的回复:

Hello,I know this post is old, nevertheless, for those who come across it in the future like me, this solution allows resolving the issue without intervening in the host system configuration:---
version: '3.6'
services:mysql:image: mysql:5.7ulimits:nofile: # Fix memory leak issue on some systems when LimitCORE=infinity (containerd)soft: 1048576hard: 1048576
This is a configuration for Compose (Docker plugin). However, you can use the equivalent, such as docker run mysql:5.7 --ulimit nofile=1048576:1048576.For your information, I encountered a similar issue with the library/elasticsearch:2.4-alpine image.I use Fedora Workstation Silverblue 39

我原来运行的命令:

docker run -d --name mysql \
-v /app/mysql/binlogs:/ava_app/mysql/binlogs \
-v /app/mysql/conf:/etc/mysql \
-v /app/mysql/logs:/var/log/mysql \
-v /data/upload:/ava_data/upload \
-v /etc/localtime:/etc/localtime:ro \
-v /app/timezone:/etc/timezone:ro \
-e "MYSQL_ROOT_PASSWORD=xxxxxxxxxxxx" \
--restart always --network=host mysql:5.7.44

根据上面方法改进的命令:

# 加入 --ulimit nofile=1048576:1048576 
docker run -d --ulimit nofile=1048576:1048576 --name mysql \
-v /app/mysql/binlogs:/ava_app/mysql/binlogs \
-v /app/mysql/conf:/etc/mysql \
-v /app/mysql/logs:/var/log/mysql \
-v /data/upload:/ava_data/upload \
-v /etc/localtime:/etc/localtime:ro \
-v /app/timezone:/etc/timezone:ro \
-e "MYSQL_ROOT_PASSWORD=xxxxxxxxxxxx" \
--restart always --network=host mysql:5.7.44

解决

后续根据“ docker mysql ulimit ”关键词查到的几个文章

https://cloud.tencent.com/developer/article/2448486

https://blog.chenwx.top/p/docker-mysql-event1.html

https://www.cnblogs.com/littlezt/p/16252678.html

http://www.dtcms.com/a/354199.html

相关文章:

  • wireshark解析FLV插件分享
  • 嵌入式Linux(Exynos 4412)笔记
  • 3459. 最长 V 形对角线段的长度
  • 设计模式理解
  • Nishang PowerShell工具:原理详解+使用方法+渗透实战
  • Go+Gdal 完成高性能GIS数据空间分析
  • 深度学习:常用的损失函数的使用
  • “java简单吗?”Java的“简单”与PHP的挑战:编程语言哲学-优雅草卓伊凡
  • 白话FNN、RNN、Attention和self-attention等
  • 《从有限元到深度学习:我的金属疲劳研究进阶之路》
  • 反内卷加速全产业链价值重塑 通威股份等行业龙头或率先受益
  • 基于 C# OpenCVSharp 的模板匹配检测技术方案
  • 计算机日常答疑,一起寻找问题的最优解
  • select
  • SM4加密算法
  • Karatsuba
  • 前端工程化与AI融合:构建智能化开发体系
  • 4-4.Python 数据容器 - 字典 dict(字典 dict 概述、字典的定义与调用、字典的遍历、字典的常用方法)
  • CPU 虚拟化之Cpu Models
  • 代码随想录刷题Day43
  • 时间轮定时器HashedWheelTimer
  • WSL设置静态IP
  • window程序打包
  • Libvio网站与客户端访问故障排查指南(专业版)
  • 什么是低空经济?
  • JMeter 5.3 性能测试:文件下载脚本编写与导出文件接收完整指南
  • QT鼠标事件中的QMouseEvent :e
  • 深度学习---卷积神经网络CNN
  • PLC_博图系列☞基本指令”S_ODT:分配接通延时定时器参数并启动“
  • HTML5超详细学习内容