Reputation: 1
version: "3.7"
services:
tomcat:
image: tomcat:9
container_name: tomcat-change
ports:
- "18080:8080"
volumes:
- "./my.war:/usr/local/tomcat/webapps/my.war"
entrypoint:
- "catalina.sh"
- "run"
networks:
- mywork
networks:
mywork:
name: mywork
driver: bridge
ipam:
driver: default
config:
- subnet: 172.31.0.0/24
gateway: 172.31.0.1
this is my docker-compose.yml
The company's LAN IP address is 172.17.xxx.xxx
My local area network IP address is 172.17.6.xxx
There is an ordinary db server in the LAN 172.17.1.xxx
I run docker compose locally The yml Docker intranet cannot connect to the database of 172.17.1.xxx
com.microsoft.sqlserver.jdbc.SQLServerException: The TCP/IP connection to the host 172.17.1.xxx, port 1433 has failed. Error: "Connect timed out. Verify the connection properties. Make sure that an instance of SQL Ser
ver is running on the host and accepting TCP/IP connections at the port. Make sure that TCP connections to the port are not blocked by a firewall
It is normal to start locally without using Docker
I use the window Docker Desktop
Docker version 20.10.11, build dea9396
Upvotes: 0
Views: 344
Reputation: 10727
ersion: "3.7"
services:
tomcat:
image: tomcat:9
container_name: tomcat-change
ports:
- "18080:8080"
volumes:
- "./my.war:/usr/local/tomcat/webapps/my.war"
entrypoint:
- "catalina.sh"
- "run"
extra_hosts:
- "db:172.17.1.xx"
This is all you need in the docker-compose.yml. Replace 172.17.1.xx
with the ip of your database server. In your application refer to the database host by db
.
Upvotes: 1