开发者问题收集

Docker mariadb无法启动

2020-05-12
5119

我的 MariaDB 容器无法启动,我不知道为什么。 这是我的 docker-compose.yml:

version:  '3.7'
services:
    mariadb:
        image: ${MARIADB_VERSION}
        restart: on-failure
        environment:
            MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD}
            MYSQL_DATABASE: ${MYSQL_DATABASE}
            MYSQL_USER: ${MYSQL_USER}
            MYSQL_PASSWORD: ${MYSQL_PASSWORD}
        ports:
            - ${PORTS_MARIADB}
        volumes:
            - './db/:/var/lib/mysql'
        user: 1000:1000

之后,我运行了这些命令:

docker-compose build
docker-compose up -d

但我的 MariaDB 容器不想启动。 这是容器的日志:

2020-05-12 20:33:35+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 1:10.4.12+maria~bionic started.
2020-05-12 20:33:35+00:00 [Note] [Entrypoint]: Initializing database files
2020-05-12 20:33:36 0 [ERROR] InnoDB: The Auto-extending innodb_system data file './ibdata1' is of a different size 0 pages than specified in the .cnf file: initial 768 pages, max 0 (relevant if non-zero) pages!
2020-05-12 20:33:36 0 [ERROR] InnoDB: Plugin initialization aborted with error Generic error
2020-05-12 20:33:36 0 [ERROR] Plugin 'InnoDB' init function returned error.
2020-05-12 20:33:36 0 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
2020-05-12 20:33:36 0 [ERROR] Unknown/unsupported storage engine: InnoDB
2020-05-12 20:33:36 0 [ERROR] Aborting

Installation of system tables failed!  Examine the logs in
/var/lib/mysql/ for more information.

The problem could be conflicting information in an external
my.cnf files. You can ignore these by doing:

    shell> /usr/bin/mysql_install_db --defaults-file=~/.my.cnf

You can also try to start the mysqld daemon with:

    shell> /usr/sbin/mysqld --skip-grant-tables --general-log &

and use the command line tool /usr/bin/mysql
to connect to the mysql database and look at the grant tables:

    shell> /usr/bin/mysql -u root mysql
    mysql> show tables;

Try 'mysqld --help' if you have problems with paths.  Using
--general-log gives you a log in /var/lib/mysql/ that may be helpful.

The latest information about mysql_install_db is available at
https://mariadb.com/kb/en/installing-system-tables-mysql_install_db
You can find the latest source at https://downloads.mariadb.org and
the maria-discuss email list at https://launchpad.net/~maria-discuss

Please check all of the above before submitting a bug report
at http://mariadb.org/jira

为什么以及我该怎么做才能解决这个问题?

致以最诚挚的问候 :)

2个回答

我认为您在 Windows 上使用 Docker Desktop?如果是这种情况,这是一个已知问题。 您无法在 Windows 上的 mariadb 上挂载主机卷。有关更多详细信息,您可以查看 github 问题: https://github.com/docker-library/mariadb/issues/152

解决方法是使用由 docker 管理的命名卷:

version:  '3.7'
services:
    mariadb:
        image: ${MARIADB_VERSION}
        restart: on-failure
        environment:
            MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD}
            MYSQL_DATABASE: ${MYSQL_DATABASE}
            MYSQL_USER: ${MYSQL_USER}
            MYSQL_PASSWORD: ${MYSQL_PASSWORD}
        ports:
            - ${PORTS_MARIADB}
        volumes:
            - mariadb-data:/var/lib/mysql
jmaitrehenry
2020-05-12

删除 user:1000:1000 并尝试

version:  '3.7'
services:
    mariadb:
        image: mariadb:${MARIADB_VERSION}
        restart: always
        environment:
            MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD}
            MYSQL_DATABASE: ${MYSQL_DATABASE}
            MYSQL_USER: ${MYSQL_USER}
            MYSQL_PASSWORD: ${MYSQL_PASSWORD}
        ports:
            - ${PORTS_MARIADB}
        volumes:
            - './db/:/var/lib/mysql'
ikenas
2020-05-12