我正在尝试在docker容器上运行wordpress,但是它不起作用,当我通过端口8080到达主机上的网页时,我得到的网页是Error establishing a database connection
。
bash命令在Mac上运行:
docker-machine create -d virtualbox Char
eval $(docker-machine env Char)
docker run -d --restart on-failure --mount type=volume,source=hatchery,destination=/etc/mysql --env MYSQL_DATABASE="zerglings" --env MYSQL_ROOT_PASSWORD=Kerrigan --name spawning-pool mysql
docker exec spawning-pool env
docker run -d -p 8080:80 --link spawning-pool:mysql --name lair wordpress
我尝试过的事情:
-使用docker container logs spawning-pool
检查Docker日志:
2019-12-19 23:24:18+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.18-1debian9 started.
2019-12-19 23:24:18+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
2019-12-19 23:24:18+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.18-1debian9 started.
2019-12-19 23:24:18+00:00 [Note] [Entrypoint]: Initializing database files
2019-12-19T23:24:18.501189Z 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.
2019-12-19T23:24:18.501349Z 0 [System] [MY-013169] [Server] /usr/sbin/mysqld (mysqld 8.0.18) initializing of server in progress as process 43
2019-12-19T23:24:21.952062Z 5 [Warning] [MY-010453] [Server] root@localhost is created with an empty password ! Please consider switching off the --initialize-insecure option.
2019-12-19 23:24:25+00:00 [Note] [Entrypoint]: Database files initialized
2019-12-19 23:24:25+00:00 [Note] [Entrypoint]: Starting temporary server
2019-12-19T23:24:26.433659Z 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.
2019-12-19T23:24:26.439768Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.18) starting as process 92
2019-12-19T23:24:27.282952Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.
2019-12-19T23:24:27.288640Z 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.
2019-12-19T23:24:27.314388Z 0 [System] [MY-010931] [Server] /usr/sbin/mysqld: ready for connections. Version: '8.0.18' socket: '/var/run/mysqld/mysqld.sock' port: 0 MySQL Community Server - GPL.
2019-12-19T23:24:27.343477Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Socket: '/var/run/mysqld/mysqlx.sock'
2019-12-19 23:24:27+00:00 [Note] [Entrypoint]: Temporary server started.
Warning: Unable to load '/usr/share/zoneinfo/iso3166.tab' as time zone. Skipping it.
Warning: Unable to load '/usr/share/zoneinfo/leap-seconds.list' as time zone. Skipping it.
Warning: Unable to load '/usr/share/zoneinfo/zone.tab' as time zone. Skipping it.
Warning: Unable to load '/usr/share/zoneinfo/zone1970.tab' as time zone. Skipping it.
2019-12-19 23:24:35+00:00 [Note] [Entrypoint]: Creating database zerglings
2019-12-19 23:24:35+00:00 [Note] [Entrypoint]: Stopping temporary server
2019-12-19T23:24:35.937444Z 11 [System] [MY-013172] [Server] Received SHUTDOWN from user root. Shutting down mysqld (Version: 8.0.18).
2019-12-19T23:24:37.609958Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.18) MySQL Community Server - GPL.
2019-12-19 23:24:37+00:00 [Note] [Entrypoint]: Temporary server stopped
2019-12-19 23:24:37+00:00 [Note] [Entrypoint]: MySQL init process done. Ready for start up.
2019-12-19T23:24:38.334146Z 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.
2019-12-19T23:24:38.334258Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.18) starting as process 1
2019-12-19T23:24:39.075334Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.
2019-12-19T23:24:39.080164Z 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.
2019-12-19T23:24:39.128740Z 0 [System] [MY-010931] [Server] /usr/sbin/mysqld: ready for connections. Version: '8.0.18' socket: '/var/run/mysqld/mysqld.sock' port: 3306 MySQL Community Server - GPL.
2019-12-19T23:24:39.206909Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Socket: '/var/run/mysqld/mysqlx.sock' bind-address: '::' port: 33060
2019-12-19T23:28:32.552935Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.18) MySQL Community Server - GPL.
2019-12-19 23:28:38+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.18-1debian9 started.
2019-12-19 23:28:38+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
2019-12-19 23:28:38+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.18-1debian9 started.
2019-12-19T23:28:38.702488Z 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.
2019-12-19T23:28:38.702596Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.18) starting as process 1
2019-12-19T23:28:39.198280Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.
2019-12-19T23:28:39.202694Z 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.
2019-12-19T23:28:39.220756Z 0 [System] [MY-010931] [Server] /usr/sbin/mysqld: ready for connections. Version: '8.0.18' socket: '/var/run/mysqld/mysqld.sock' port: 3306 MySQL Community Server - GPL.
2019-12-19T23:28:39.374209Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Socket: '/var/run/mysqld/mysqlx.sock' bind-address: '::' port: 33060
尝试查看mysql是否在生成池上运行,但不是,mysql是否需要在其上运行?
docker container top spawning-pool
UID PID PPID C STIME TTY TIME CMD
999 26365 26344 7 23:28 ? 00:00:00 mysqld
尝试添加wordpress环境变量,但仍然出现相同的错误
docker run -d -p 8080:80 --link spawning-pool:mysql --env WORDPRESS_DB_USER=root --env WORDPRESS_DB_PASSWORD=Kerrigan --env WORDPRESS_DB_NAME=zerglings --name lair wordpress