如何在web和数据库(windows base)docker容器之间建立连接(在aws远程windows服务器上运行的docker(2016)

k4aesqcs  于 2021-10-10  发布在  Java
关注(0)|答案(0)|浏览(226)

docker引擎正在aws远程windows server 2016上运行
这是我的docker撰写文件:-

version: '3'
services:

     controllerdb:
            hostname: controllerdb
            container_name: controllerdb
            image: <windows base mysql image>
            restart: always                           
            networks:
                test:
                    ipv4_address: 172.28.1.3
     controller:
            hostname: controller
            container_name: controller
            depends_on: 
                - controllerdb
            image: <windows base tomcat image>
            restart: always
            ports:
                - 8080:8080           
            networks:
                test:
                    ipv4_address: 172.28.1.4
networks:
  test:
    ipam:
        driver: default
        config:
            - subnet: 172.28.0.0/16

之后,尝试通过提供特定的url在controller(web映像)和controllerdb(数据库映像)中建立连接。
url=jdbc:mysql://172.28.1.3:3306/database_name"
但在运行compose文件时,我发现连接错误:

com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure

   The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.

   Caused by: java.net.ConnectException: Connection timed out: connect
           at java.base/java.net.PlainSocketImpl.connect0(Native Method)
           at java.base/java.net.PlainSocketImpl.socketConnect(PlainSocketImpl.java:101)

我的主要想法是,我能够以同样的方式在本地机器的docker桌面上建立连接,但在远程windows server 2016的docker引擎上,它显示出错误。
Docker 信息:-

Client:
 Context:    default
 Debug Mode: false
 Plugins:
  app: Docker Application (Docker Inc., v0.8.0)
  cluster: Manage Mirantis Container Cloud clusters (Mirantis Inc., v1.9.0)
  registry: Manage Docker registries (Docker Inc., 0.1.0)

Server:
 Containers: 0
  Running: 0
  Paused: 0
  Stopped: 5
 Images: 5
 Server Version: 20.10.6
 Storage Driver: windowsfilter
  Windows:
 Logging Driver: json-file
 Plugins:
  Volume: local
  Network: ics internal l2bridge l2tunnel nat null overlay private transparent
  Log: awslogs etwlogs fluentd gcplogs gelf json-file local logentries splunk syslog
 Swarm: inactive
 Default Isolation: process
 Kernel Version: 10.0 14393 (14393.4467.amd64fre.rs1_release.210604-1844)
 Operating System: Windows Server 2016 Datacenter Version 1607 (OS Build 14393.4467)
 OSType: windows
 Architecture: x86_64
 CPUs: 4
 Total Memory: 16GiB
 Name: EC2AMAZ-6S0KVR1
 ID: XVNL:JTWW:N4QI:HINO:Q3MO:DYSH:N3HC:Q3Q7:PMED:OSF2:L2NQ:RPBD
 Docker Root Dir: E:\DockerData
 Debug Mode: false
 Username: 
 Registry: https://index.docker.io/v1/
 Labels:
 Experimental: false
 Insecure Registries:
  127.0.0.0/8
 Live Restore Enabled: false

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题