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

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.xdnf.cn/news/18870.html

相关文章:

  • 微服务-docker compose
  • mfc中操作excel
  • APP与WEB测试的区别?
  • Windows MCP 踩坑经验 -- 今日股票行情助手
  • 金仓数据库文档系统全面升级:用户体验焕然一新
  • SqlHelper类的方法详细解读和使用示例
  • 人工智能和机器学习如何改善机器人技术
  • 应变片与分布式光纤传感:核心差异与选型指南
  • 深入解析 Chromium Mojo IPC:跨进程通信原理与源码实战
  • 【开发配置】GitLab CR(Code Review)规则配置清单
  • 钉钉 AI 硬件:DingTalk A1
  • Java文件的组织方式
  • 用户体验设计 | 从UX到AX:人工智能如何重构交互范式?
  • 趣味学习Rust基础篇(用Rust做一个猜数字游戏)
  • 化学分析原理与算法、数据库。
  • 本地搭建 Redis/MySQL 并配置国内镜像加速(Docker/原生安装 | macOS/Linux/Windows)
  • 【Git】多人协作
  • k8sday18 HELM
  • AI编写测试用例
  • 【微服务】SpringBoot 整合 Easy-Es 实战操作详解
  • 深入探索Vue:前端开发的强大框架
  • 字母异位词分组,leetCode热题100,C++实现
  • 嵌入式学习day38
  • 搭建域服务器
  • spring-ai-alibaba使用
  • 第18章|变量:把数据装进“盒子”的正确方式
  • 机器学习 TF-IDF方法
  • 【docker apoc 部署的neo4j安装apoc插件】
  • MySQL 面试题系列(五)
  • 【Kafka】重点概念和架构总结