简体   繁体   English

运行Tomcat尝试连接到Docker容器时出错

[英]Error running Tomcat trying to connect to a Docker container

Previously I kept getting the access denied error but at least it was trying to set a connection. 以前,我一直收到拒绝访问错误,但至少它试图建立连接。 Now this is all I get: Caused by: java.sql.SQLException: Could not connect to address=(host=localhost)(port=3306)(type=master). 现在这就是我得到的全部:原因:java.sql.SQLException:无法连接到address =(host = localhost)(port = 3306)(type = master)。 I would appreciate your help. 多谢您的协助。

By default, Docker containers run on a bridge network. 默认情况下,Docker容器在网桥网络上运行。 Thus the Docker container's localhost does not point to the localhost of the Docker host inside which the container runs. 因此,多克尔容器的localhost 指向其内部的容器中运行的泊坞窗主机的本地主机。

Find out the IP address of your Docker host: 找出您的Docker主机的IP地址:

ifconfig \
| grep -E "([0-9]{1,3}\.){3}[0-9]{1,3}" \
| grep -v 127.0.0.1 \
| awk '{ print $2 }' \
| cut -f2 -d: \
| head -n1

Or if you're on macOS, you can use docker.for.mac.localhost (or docker.for.win.localhost on Windows). 或者,如果您使用的是macOS,则可以使用docker.for.mac.localhost (或Windows上的docker.for.win.localhost )。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Docker 容器中的 mongodb 正在运行,但拒绝连接? - The mongodb in Docker container is running ,but refuse to connect? 从 docker 容器内运行的应用程序连接到本地运行的数据库 - Connect to database running in local from application running inside docker container 尝试从Docker容器内部连接到数据库时,“连接被拒绝” - “Connection refused”, when trying to connect to DB from inside the Docker container 尝试使用 Docker 进行快速集群部署:无法连接到 unix:///var/run/docker.sock 上的 Docker 守护进程。 docker 守护进程是否正在运行? - Trying a quick cluster deployment with Docker:Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running? Quarkus docker 容器无法运行/连接到数据库 - Quarkus docker container failed to run / connect to the DB 在 docker 容器中使用创建的用户连接到创建的数据库 - Connect to created database with created user in a docker container 如何将Docker容器连接到远程数据库? - how to connect docker container to a remote database? DBeaver / PostgresSQL 无法连接到远程 docker 容器 - DBeaver / PostgresSQL fails to connect to remote docker container 访问在Docker容器中运行的数据库? - Accessing database that is running inside a docker container? 在docker容器中运行数据库的性能问题 - Performance issues running a database in a docker container
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM