【问题标题】:docker, cannot start docker mysql container built from the official docker image mysqldocker, 无法启动从官方 docker 镜像 mysql 构建的 docker mysql 容器
【发布时间】:2018-04-20 22:00:16
【问题描述】:

我正在尝试从此 docker-compose 文件启动 db 容器:

                    db:
                      image: mysql
                      environment:
                        MYSQL_ROOT_PASSWORD: root
                      volumes:
                        - "./testsql:/var/lib/mysql"
                    phpmyadmin:
                      image: phpmyadmin/phpmyadmin
                      container_name: phpmyadmin
                      volumes:
                        - /sessions
                      environment:
                       - PMA_ARBITRARY=1
                      restart: always
                      ports:
                       - "8082:80"
                      depends_on:
                        - db

我在容器日志中发现了这个错误:

 2018-04-20T21:36:42.409677Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
            2018-04-20T21:36:42.420057Z 0 [ERROR] --initialize specified but the data directory has files in it. Aborting.
            2018-04-20T21:36:42.420341Z 0 [ERROR] Aborting
            2018-04-20T21:36:42.420428809Z

谢谢

【问题讨论】:

    标签: mysql docker docker-compose


    【解决方案1】:

    testsql中有子目录吗?

    如果有子目录,则会重现如下所示的错误。

    $ mkdir -p testsql/aaa
    $ docker run -e MYSQL_ROOT_PASSWORD=r00t -v `pwd`/testsql:/var/lib/mysql mysql
    Initializing database
    2018-04-20T23:59:23.465762Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
    2018-04-20T23:59:23.468193Z 0 [ERROR] --initialize specified but the data directory has files in it. Aborting.
    2018-04-20T23:59:23.468245Z 0 [ERROR] Aborting
    
    $ 
    

    如果没有子目录,则不会报错。

    $ rm -rf testsql/
    $ mkdir testsql
    $ docker run -e MYSQL_ROOT_PASSWORD=r00t -v `pwd`/testsql:/var/lib/mysql mysql
    Initializing database
    2018-04-21T00:04:06.012172Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
    2018-04-21T00:04:06.533290Z 0 [Warning] InnoDB: New log files created, LSN=45790
    2018-04-21T00:04:06.629547Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
    2018-04-21T00:04:06.692854Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 823515e3-44f7-11e8-b4cf-0242ac110003.
    ...
    

    【讨论】:

      猜你喜欢
      • 2019-04-24
      • 1970-01-01
      • 1970-01-01
      • 2021-11-09
      • 2017-04-16
      • 1970-01-01
      • 2017-09-15
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多