目录

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

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-3b49deb
 API version:       1.48
 Go version:        go1.24.4
 Git commit:        3b49deb
 Built:             Mon Aug 11 09:03:23 2025
 OS/Arch:           linux/amd64
 Context:           default

Server:
 Engine:
  Version:          28.0.1
  API version:      1.48 (minimum version 1.24)
  Go version:       go1.24.2
  Git commit:       %{_gitcommit_engine}
  Built:            Thu Jun 12 10:00:10 2025
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.7.27
  GitCommit:        
 runc:
  Version:          1.1.14
  GitCommit:        
 docker-init:
  Version:          0.19.0
  GitCommit:        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 config
        command was: mysqld --verbose --help --log-bin-index=/tmp/tmp.RBl3Hbmt6u

2025-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 config
        command was: mysqld --verbose --help --log-bin-index=/tmp/tmp.hZa5kwNZnP

2025-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 config
        command was: mysqld --verbose --help --log-bin-index=/tmp/tmp.6eeHXfFfzH

2025-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 config
        command was: mysqld --verbose --help --log-bin-index=/tmp/tmp.lvQBb4Rtwb

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

查找资料

很幸运谷歌到了一个issues:

里面的回复:

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.7
    ulimits:
      nofile: # Fix memory leak issue on some systems when LimitCORE=infinity (containerd)
        soft: 1048576
        hard: 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 ”关键词查到的几个文章