简体   繁体   中英

mysql 5.7 data directory has files in it

Following the tutorial at: https://docs.docker.com/compose/wordpress/

Running docker-compose up I get:

Initializing database
[Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
[ERROR] --initialize specified but the data directory has files in it. Aborting.
[ERROR] Aborting

Have tried adding arguments as suggested here: https://github.com/docker-library/mysql/issues/186 https://github.com/docker-library/mysql/issues/69

But this doesn't seems to work:

services:
  db:
    image: mysql:5.7
    command: ["mysqld", "--ignore-db-dir=lost+found", "--explicit_defaults_for_timestamp"]
    volumes:
      - db_data:/var/lib/mysql
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: somewordpress
      MYSQL_DATABASE: wordpress
      MYSQL_USER: wordpress
      MYSQL_PASSWORD: wordpress

Is there another solution?

I solved it using:

docker volume prune

Remove all unused local volumes. Unused local volumes are those which are not referenced by any containers

https://docs.docker.com/engine/reference/commandline/volume_prune/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM