我有一个带有持久卷的WordPress和MySQL容器。我一直在努力学习docker,并在学习过程中错误地删除了老docker撰写。yml和mysql卷之外的所有卷。我现在已经尽我所能将其重新创建到compose文件中,但每当我启动机器时,它都无法连接到MySQL服务器。有谁能指出我哪里做错了。
我怀疑我对两者之间的联系有问题,但我不确定。
docker-compose.yml:
version: '2'
services:
wp.spm:
restart: always
image: wordpress:latest
ports:
- "8080:80"
environment:
WORDPRESS_DB_HOST: localhost:3306
WORDPRESS_DB_USER: spm
WORDPRESS_DB_PASSWORD: Ivietoo2Phah8xay
WORDPRESS_DB_NAME: spm
links:
- mysql.5.7
working_dir: /var/www/html
volumes:
- ./wp-content:/var/www/html/wp-content
mysql.5.7:
restart: always
image: mysql:5.7
ports:
- 3306:3306
environment:
MYSQL_ROOT_PASSWORD: root # TODO: Change this
MYSQL_USER: spm
MYSQL_PASS: Ivietoo2Phah8xay
MYSQL_DATABASE: spm
volumes:
- db_data:/var/lib/mysql
volumes:
db_data:
日志:
$ docker-compose up
Pulling mysql.5.7 (mysql:5.7)...
5.7: Pulling from library/mysql
75a822cd7888: Pull complete
b8d5846e536a: Pull complete
b75e9152a170: Pull complete
832e6b030496: Pull complete
fe4a6c835905: Pull complete
c3f247e29ab1: Pull complete
21be3e562071: Pull complete
c7399d6bf033: Pull complete
ccdaeae6c735: Pull complete
713c7d65b0d3: Pull complete
86c18539deb2: Pull complete
Digest: sha256:9ef4478a3aa597f59b2266d5702f55f29acc468b5bf3518c3c90cbca4e243823
Status: Downloaded newer image for mysql:5.7
Pulling wp.spm (wordpress:latest)...
latest: Pulling from library/wordpress
75a822cd7888: Already exists
e4d8a4e038be: Pull complete
81d4d961577a: Pull complete
f0a3d7c702e3: Pull complete
a4b7d2c4c9cc: Pull complete
de3fbbff60a9: Pull complete
336c38203cc2: Pull complete
628c443fd26f: Pull complete
6b43451e2e60: Pull complete
a4dc6da381e6: Pull complete
771a9ee2bb6a: Pull complete
3862c25af8ee: Pull complete
a3bf90f1df74: Pull complete
4564f4870a3e: Pull complete
ec9c03f98075: Pull complete
5f4dfa2bfbb4: Pull complete
69feb6fb40db: Pull complete
5f129a65fac7: Pull complete
Digest: sha256:0bb659eafa22cdb9f14bc05d17be97132842eb122eb8ff346ecafe7553f48f22
Status: Downloaded newer image for wordpress:latest
Creating googleserver_mysql.5.7_1
Creating googleserver_wp.spm_1
Attaching to googleserver_mysql.5.7_1, googleserver_wp.spm_1
mysql.5.7_1 | 2017-01-09T11:07:44.271254Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
mysql.5.7_1 | 2017-01-09T11:07:44.278843Z 0 [Note] mysqld (mysqld 5.7.17) starting as process 1 ...
wp.spm_1 | WordPress not found in /var/www/html - copying now...
mysql.5.7_1 | 2017-01-09T11:07:44.347784Z 0 [Note] InnoDB: PUNCH HOLE support available
mysql.5.7_1 | 2017-01-09T11:07:44.347937Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
mysql.5.7_1 | 2017-01-09T11:07:44.347956Z 0 [Note] InnoDB: Uses event mutexes
mysql.5.7_1 | 2017-01-09T11:07:44.348024Z 0 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier
mysql.5.7_1 | 2017-01-09T11:07:44.348048Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.3
mysql.5.7_1 | 2017-01-09T11:07:44.348060Z 0 [Note] InnoDB: Using Linux native AIO
mysql.5.7_1 | 2017-01-09T11:07:44.356631Z 0 [Note] InnoDB: Number of pools: 1
mysql.5.7_1 | 2017-01-09T11:07:44.367564Z 0 [Note] InnoDB: Using CPU crc32 instructions
mysql.5.7_1 | 2017-01-09T11:07:44.370949Z 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M
mysql.5.7_1 | 2017-01-09T11:07:44.419506Z 0 [Note] InnoDB: Completed initialization of buffer pool
mysql.5.7_1 | 2017-01-09T11:07:44.476953Z 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority().
mysql.5.7_1 | 2017-01-09T11:07:44.501029Z 0 [Note] InnoDB: Highest supported file format is Barracuda.
wp.spm_1 | WARNING: /var/www/html is not empty - press Ctrl+C now if this is an error!
wp.spm_1 | + ls -A
wp.spm_1 | wp-content
wp.spm_1 | + sleep 10
mysql.5.7_1 | 2017-01-09T11:07:44.614777Z 0 [Note] InnoDB: Creating shared tablespace for temporary tables
mysql.5.7_1 | 2017-01-09T11:07:44.615567Z 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
mysql.5.7_1 | 2017-01-09T11:07:45.135167Z 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
mysql.5.7_1 | 2017-01-09T11:07:45.137285Z 0 [Note] InnoDB: 96 redo rollback segment(s) found. 96 redo rollback segment(s) are active.
mysql.5.7_1 | 2017-01-09T11:07:45.137414Z 0 [Note] InnoDB: 32 non-redo rollback segment(s) are active.
mysql.5.7_1 | 2017-01-09T11:07:45.138586Z 0 [Note] InnoDB: Waiting for purge to start
mysql.5.7_1 | 2017-01-09T11:07:45.189557Z 0 [Note] InnoDB: 5.7.17 started; log sequence number 12168868
mysql.5.7_1 | 2017-01-09T11:07:45.194278Z 0 [Note] Plugin 'FEDERATED' is disabled.
mysql.5.7_1 | 2017-01-09T11:07:45.195063Z 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool
mysql.5.7_1 | 2017-01-09T11:07:45.223753Z 0 [Note] InnoDB: Buffer pool(s) load completed at 170109 11:07:45
mysql.5.7_1 | 2017-01-09T11:07:45.235736Z 0 [Warning] Failed to set up SSL because of the following SSL library error: SSL context is not usable without certificate and private key
mysql.5.7_1 | 2017-01-09T11:07:45.237375Z 0 [Note] Server hostname (bind-address): '*'; port: 3306
mysql.5.7_1 | 2017-01-09T11:07:45.237759Z 0 [Note] IPv6 is available.
mysql.5.7_1 | 2017-01-09T11:07:45.237877Z 0 [Note] - '::' resolves to '::';
mysql.5.7_1 | 2017-01-09T11:07:45.237961Z 0 [Note] Server socket created on IP: '::'.
mysql.5.7_1 | 2017-01-09T11:07:45.295529Z 0 [Warning] 'db' entry 'sys mysql.sys@localhost' ignored in --skip-name-resolve mode.
mysql.5.7_1 | 2017-01-09T11:07:45.296334Z 0 [Warning] 'proxies_priv' entry '@ root@localhost' ignored in --skip-name-resolve mode.
mysql.5.7_1 | 2017-01-09T11:07:45.304463Z 0 [Warning] 'tables_priv' entry 'sys_config mysql.sys@localhost' ignored in --skip-name-resolve mode.
mysql.5.7_1 | 2017-01-09T11:07:45.325375Z 0 [Note] Event Scheduler: Loaded 0 events
mysql.5.7_1 | 2017-01-09T11:07:45.326559Z 0 [Note] Executing 'SELECT * FROM INFORMATION_SCHEMA.TABLES;' to get a list of tables using the deprecated partition engine. You may use the startup option '--disable-partition-engine-check' to skip this check.
mysql.5.7_1 | 2017-01-09T11:07:45.326653Z 0 [Note] Beginning of list of non-natively partitioned tables
mysql.5.7_1 | 2017-01-09T11:07:45.377612Z 0 [Note] End of list of non-natively partitioned tables
mysql.5.7_1 | 2017-01-09T11:07:45.378560Z 0 [Note] mysqld: ready for connections.
mysql.5.7_1 | Version: '5.7.17' socket: '/var/run/mysqld/mysqld.sock' port: 3306 MySQL Community Server (GPL)
wp.spm_1 | Complete! WordPress has been successfully copied to /var/www/html
wp.spm_1 |
wp.spm_1 | Warning: mysqli::mysqli(): (HY000/2002): No such file or directory in - on line 19
wp.spm_1 |
wp.spm_1 | MySQL Connection Error: (2002) No such file or directory
wp.spm_1 |
wp.spm_1 | Warning: mysqli::mysqli(): (HY000/2002): No such file or directory in - on line 19
wp.spm_1 |
wp.spm_1 | MySQL Connection Error: (2002) No such file or directory
我想说的是,问题是您正在将wp实例与在本地主机中设置的数据库链接,但事实并非如此,因为您的数据库位于服务器mysql中。5.7. 我会尝试下一个yaml文件:
version: '2'
services:
wp.spm:
restart: always
image: wordpress:latest
ports:
- "8080:80"
environment:
WORDPRESS_DB_HOST: mysql.5.7:3306
WORDPRESS_DB_USER: spm
WORDPRESS_DB_PASSWORD: Ivietoo2Phah8xay
WORDPRESS_DB_NAME: spm
depends_on:
- mysql.5.7
working_dir: /var/www/html
volumes:
- ./wp-content:/var/www/html/wp-content
mysql.5.7:
restart: always
image: mysql:5.7
ports:
- 3306:3306
environment:
MYSQL_ROOT_PASSWORD: root # TODO: Change this
MYSQL_USER: spm
MYSQL_PASS: Ivietoo2Phah8xay
MYSQL_DATABASE: spm
volumes:
- db_data:/var/lib/mysql
volumes:
db_data:
我面临一个问题,如果更改MySQL连接器Jar版本,我会遇到某些错误。我的代码在JBoss4.0.4.ga版上运行良好。然后我用连接器jar版本mysql-connector-java-5.1.36-bin将JBoss升级到Wildfly,并且没有对运行良好的代码做任何更改。现在,每当我添加一些新行,我就会得到一个错误,说生成的密钥没有被请求。 之前我认为这可能是因为服务器(JBoss)升级的问题
系统:win11专业版 wsl2:ubuntu20.04.6 LTS 问题: 第一次安装docker后,创建镜像,创建容器都挺正常,端口映射也正常。 今天就出问题,创建容器时,配置端口映射,正常,但是宿主机访问映射端口没有响应. 假设端口映射18080:8080,我还在容器内部使用 curl http://localhost:8080有响应,使用在内部是正常,但是宿主机浏览器访问http://lo
Spark 组件之间的网络连接问题会导致各式各样的警告/错误: SparkContext <-> Spark Standalone Master: 如果 SparkContext 不能连接到 Spark standalone master,会显示下面的错误 ERROR AppClient$ClientActor: All masters are unresponsive! Giving up. E
默认情况下 docker swarm 服务中暴露的端口在有外部请求时会通过 router mesh 进行负载均衡。查看文档时提到了两个绕过默认负载均衡的方式,。一种是在暴露端口时设置 --publish 参数的 mode 为 host,一种是设置 --endpoint-mode 为 dnsrr。这两种方式具体有什么区别?
我有一个 docker 容器,我想给它 --network=host AND -。我需要连接到主机网络才能将主机数据狗服务器 (UDP) 和 网络用于其数据库。 尝试添加这两个网络会导致。 知道正确的处理方法吗?
当我运行此命令时 uvicorn应用程序。主:应用程序--主机0.0.0.0--端口8000--重新加载 我得到这个错误 SQL炼金术。exc.OperationalError:(pymysql.err.OperationalError)(2003,“无法连接到“0.0.0.0”上的MySQL服务器([WinError 10049]请求的地址在其上下文中无效)”)(此错误的背景信息位于:http: