概要

docker-composeを使って、wordpressとmysqlの公式イメージを使用した環境を構築するとmysqlへの接続エラーが起きます。
wordpress自体はlocalhost:8080で立ち上げており、ブラウザでアクセスするとトップページ自体は問題なく表示されますが、管理画面にログインしようとするとID、PWが合っている場合でも再度ログイン画面にリダイレクトされるという現象が起きています。

docker-compose.yml

version: '3'
services:
  wordpress:
    image: wordpress:latest
    volumes:
      - ./wp:/var/www/html/:cached
    depends_on:
      - db
    ports:
      - "8080:80"
    environment:
      WORDPRESS_DB_HOST: db:3306
      WORDPRESS_DB_PASSWORD: wordpress
  db:
    image: mysql:latest
    volumes:
      - ./_db:/var/lib/mysql:cached
    environment:
      MYSQL_ROOT_PASSWORD: wordpress
      MYSQL_DATABASE: wordpress
      MYSQL_USER: wordpress
      MYSQL_PASSWORD: wordpress

再現している現象について

docker-composeでコンテナを立ち上げた時のログ

Creating network "nikakeru_corp_default" with the default driver
Creating nikakeru_corp_db_1 ... done
Creating nikakeru_corp_wordpress_1 ... done
Attaching to nikakeru_corp_db_1, nikakeru_corp_wordpress_1
db_1         | 2018-06-16T02:38:38.909458Z 0 [Warning] [MY-011070] [Server] 'Disabling symbolic links using --skip-symbolic-links (or equivalent) is the default. Consider not using this option as it' is deprecated and will be removed in a future release.
db_1         | 2018-06-16T02:38:38.909586Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.11) starting as process 1
db_1         | mbind: Operation not permitted
db_1         | mbind: Operation not permitted
wordpress_1  |
wordpress_1  | Warning: mysqli::__construct(): (HY000/2002): Connection refused in Standard input code on line 22
wordpress_1  |
wordpress_1  | MySQL Connection Error: (2002) Connection refused
db_1         | 2018-06-16T02:38:39.625922Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.
db_1         | 2018-06-16T02:38:39.633143Z 0 [Warning] [MY-011810] [Server] Insecure configuration for --pid-file: Location '/var/run/mysqld' in the path is accessible to all OS users. Consider choosing a different directory.
db_1         | 2018-06-16T02:38:39.636986Z 0 [ERROR] [MY-013129] [Server] A message intended for a client cannot be sent there as no client-session is attached. Therefore, we're sending the information to the error-log instead: MY-001146 - Table 'mysql.component' doesn't exist
db_1         | 2018-06-16T02:38:39.637629Z 0 [Warning] [MY-013129] [Server] A message intended for a client cannot be sent there as no client-session is attached. Therefore, we're sending the information to the error-log instead: MY-003543 - The mysql.component table is missing or has an incorrect definition.
db_1         | 2018-06-16T02:38:39.647507Z 0 [Warning] [MY-010929] [Server] Storage engine 'MyISAM' does not support system tables. [mysql.user].
db_1         | 2018-06-16T02:38:39.647547Z 0 [Warning] [MY-010929] [Server] Storage engine 'MyISAM' does not support system tables. [mysql.db].
db_1         | 2018-06-16T02:38:39.647557Z 0 [Warning] [MY-010929] [Server] Storage engine 'MyISAM' does not support system tables. [mysql.tables_priv].
db_1         | 2018-06-16T02:38:39.647561Z 0 [Warning] [MY-010929] [Server] Storage engine 'MyISAM' does not support system tables. [mysql.columns_priv].
db_1         | 2018-06-16T02:38:39.647565Z 0 [Warning] [MY-010929] [Server] Storage engine 'MyISAM' does not support system tables. [mysql.procs_priv].
db_1         | 2018-06-16T02:38:39.647570Z 0 [Warning] [MY-010929] [Server] Storage engine 'MyISAM' does not support system tables. [mysql.proxies_priv].
db_1         | 2018-06-16T02:38:39.648261Z 0 [ERROR] [MY-013143] [Server] Column count of mysql.user is wrong. Expected 49, found 45. The table is probably corrupted
db_1         | 2018-06-16T02:38:39.648311Z 0 [Warning] [MY-010966] [Server] ACL table mysql.role_edges missing. Some operations may fail.
db_1         | 2018-06-16T02:38:39.648318Z 0 [Warning] [MY-010966] [Server] ACL table mysql.default_roles missing. Some operations may fail.
db_1         | 2018-06-16T02:38:39.648322Z 0 [Warning] [MY-010966] [Server] ACL table mysql.global_grants missing. Some operations may fail.
db_1         | 2018-06-16T02:38:39.648329Z 0 [Warning] [MY-010966] [Server] ACL table mysql.password_history missing. Some operations may fail.
db_1         | 2018-06-16T02:38:39.649112Z 0 [Warning] [MY-010315] [Server] 'user' entry 'root@localhost' ignored in --skip-name-resolve mode.
db_1         | 2018-06-16T02:38:39.649167Z 0 [Warning] [MY-010315] [Server] 'user' entry 'mysql.sys@localhost' ignored in --skip-name-resolve mode.
db_1         | 2018-06-16T02:38:39.649701Z 0 [Warning] [MY-010323] [Server] 'db' entry 'performance_schema mysql.session@localhost' ignored in --skip-name-resolve mode.
db_1         | 2018-06-16T02:38:39.649753Z 0 [Warning] [MY-010323] [Server] 'db' entry 'sys mysql.sys@localhost' ignored in --skip-name-resolve mode.
db_1         | 2018-06-16T02:38:39.650267Z 0 [Warning] [MY-010311] [Server] 'proxies_priv' entry '@ root@localhost' ignored in --skip-name-resolve mode.
db_1         | 2018-06-16T02:38:39.650313Z 0 [ERROR] [MY-010965] [Server] Missing system table mysql.global_grants; please run mysql_upgrade to create it.
db_1         | 2018-06-16T02:38:39.661876Z 0 [Warning] [MY-010330] [Server] 'tables_priv' entry 'user mysql.session@localhost' ignored in --skip-name-resolve mode.
db_1         | 2018-06-16T02:38:39.661910Z 0 [Warning] [MY-010330] [Server] 'tables_priv' entry 'sys_config mysql.sys@localhost' ignored in --skip-name-resolve mode.
db_1         | 2018-06-16T02:38:39.664529Z 0 [Warning] [MY-010727] [Server] System table 'func' is expected to be transactional.
db_1         | 2018-06-16T02:38:39.668294Z 0 [Warning] [MY-010405] [Repl] Info table is not ready to be used. Table 'mysql.slave_master_info' cannot be opened.
db_1         | 2018-06-16T02:38:39.668335Z 0 [ERROR] [MY-010422] [Repl] Error in checking mysql.slave_master_info repository info type of TABLE.
db_1         | 2018-06-16T02:38:39.668343Z 0 [ERROR] [MY-010415] [Repl] Error creating master info: Error checking repositories.
db_1         | 2018-06-16T02:38:39.668348Z 0 [ERROR] [MY-010426] [Repl] Slave: Failed to initialize the master info structure for channel ''; its record may still be present in 'mysql.slave_master_info' table, consider deleting it.
db_1         | 2018-06-16T02:38:39.668353Z 0 [ERROR] [MY-010529] [Repl] Failed to create or recover replication info repositories.
db_1         | 2018-06-16T02:38:39.669841Z 0 [System] [MY-010931] [Server] /usr/sbin/mysqld: ready for connections. Version: '8.0.11'  socket: '/var/run/mysqld/mysqld.sock'  port: 3306  MySQL Community Server - GPL.
db_1         | 2018-06-16T02:38:39.785465Z 0 [ERROR] [MY-011294] [Server] Plugin mysqlx reported: 'Unable to use user mysql.session account when connecting the server for internal plugin requests.'
db_1         | 2018-06-16T02:38:39.785595Z 0 [ERROR] [MY-011301] [Server] Plugin mysqlx reported: 'Unable to switch context to user mysql.session'

立ち上げたwordpressの管理画面にログインしようとした時のリダイレクト後のURL

ログイン時
http://localhost:8080/wp-login.php

リダイレクト後ログイン画面
http://localhost:8080/wp-login.php?redirect_to=http%3A%2F%2Flocalhost%3A8080%2Fwp-admin%2F&reauth=1

備考

  • この現象が起き始めたのがPCの移行を行ってからです。以前まで使用していたPCでは同じdocker-compose.ymlファイルで問題なく起動出来ています。

  • Docker公式ドキュメントを参考に( http://docs.docker.jp/compose/startup-order.html )などの対応を試しましたがwordpressコンテナ自体が立ち上がらなくなってしまいうまく解決しませんでした。