docker-compose 中的 MySQL 错误:[错误] [入口点]:无法启动服务器。 mydb 退出,代码为 0

问题描述 投票:0回答:1

我正在尝试使用此

docker-compose.yml
文件运行 MySQL 容器:

version: '3.3'

services:
  mydb:
    container_name: mydb
    image: mysql:8.4.0 # I also tried lts and latest here
    restart: unless-stopped
    environment:
      MYSQL_DATABASE: somedb
      MYSQL_USER: myuser
      MYSQL_PASSWORD: mysomepass
      MYSQL_ROOT_PASSWORD: somepass
    networks:
      - my_network 
    volumes:
      - ./data:/var/lib/mysql
    ports:
      - "3306:3306"
# I've created the network and it seems fine
networks:
  my_network:
    external: true
    driver: bridge

它在我自己的计算机(Ubuntu 22.04 桌面)上完美运行,但是当我尝试在服务器(Ubuntu 22.04 服务器)上运行完全相同的撰写时,我收到此错误:

/root/src/mysql# docker compose up --build 
WARN[0000] /root/src/mysql/docker-compose.yml: `version` is obsolete 
[+] Running 1/1
 ✔ mydb Pulled                                                                                                                                                                           0.2s 
[+] Running 1/1
 ✔ Container mydb  Recreated                                                                                                                                                             0.1s 
Attaching to mydb
mydb  | 2024-05-22 22:46:10+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.4.0-1.el9 started.
mydb  | 2024-05-22 22:46:11+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
mydb  | 2024-05-22 22:46:11+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.4.0-1.el9 started.
mydb  | 2024-05-22 22:46:11+00:00 [Note] [Entrypoint]: Initializing database files
mydb  | 2024-05-22T22:46:11.892732Z 0 [System] [MY-015017] [Server] MySQL Server Initialization - start.
mydb  | 2024-05-22T22:46:11.894695Z 0 [System] [MY-013169] [Server] /usr/sbin/mysqld (mysqld 8.4.0) initializing of server in progress as process 79
mydb  | 2024-05-22T22:46:11.916024Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
mydb  | 2024-05-22T22:46:12.798026Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
mydb  | 2024-05-22T22:46:15.569954Z 6 [Warning] [MY-010453] [Server] root@localhost is created with an empty password ! Please consider switching off the --initialize-insecure option.
mydb  | 2024-05-22T22:46:18.883638Z 0 [System] [MY-015018] [Server] MySQL Server Initialization - end.
mydb  | 2024-05-22 22:46:18+00:00 [Note] [Entrypoint]: Database files initialized
mydb  | 2024-05-22 22:46:18+00:00 [Note] [Entrypoint]: Starting temporary server
mydb  | /usr/local/bin/docker-entrypoint.sh: line 122:   116 Killed                  "$@" --daemonize --skip-networking --default-time-zone=SYSTEM --socket="${SOCKET}"
mydb  | 2024-05-22 22:46:19+00:00 [ERROR] [Entrypoint]: Unable to start server.
mydb exited with code 0

你知道这里出了什么问题吗?预先感谢。

docker docker-compose ubuntu-server
1个回答
0
投票

看起来像是内存问题。当容器被杀死而没有任何其他错误消息时,最常见的情况是。

© www.soinside.com 2019 - 2024. All rights reserved.