dockerdocker-composeubuntu-server

MySQL in docker-compose error: [ERROR] [Entrypoint]: Unable to start server. mydb exited with code 0


I'm trying to run a MySQL container with this docker-compose.yml file:

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

It runs perfectly on my own computer (Ubuntu 22.04 Desktop), but when I try to running the exact same compose on server (Ubuntu 22.04 Server) I get this error:

/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

Do you have any idea whats going wrong here? Thanks in advance.


Solution

  • Looks like a memory problem. This is most often the case when the container is killed without any other error message.