What to do when the Docker container starts the error WARNING in Centos7
This article mainly introduces the Centos7 Docker container start error WARNING how to do, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor with you to understand.
problem
Recently, when you deployed the Jar package using the Docker container, the database was disconnected:
2021-01-08 02 ERROR [eate-1123226989] com.alibaba.druid.pool.DruidDataSource 2507-create connection SQLException, url: jdbc:mysql://***/***?autoReconnect=true&useUnicode=true&allowMultiQueries=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&serverTimezone=CTT&useAffectedRows=true, errorCode 0, state 08001com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Could not create connection to database server. Attempted reconnect 3 times. Giving up. …… Com.alibaba.druid.pool.DruidAbstractDataSource.createPhysicalConnection (DruidAbstractDataSource.java:1572)... Caused by: java.net.ConnectException: Connection timed out (Connection timed out).
This problem has been plagued for a long time, and the direction of solving the problem has always been the mirror image of the container.
Until today, with the help of the boss, I found that there was an inconspicuous prompt when starting the container:
WARNING: IPv4 forwarding is disabled. Networking will not work
Combined with the previous:
Java.net.ConnectException: Connection timed out (Connection timed out)
Gan!
The problem is on the Internet!
IPv4 forwarding is disabled. The network will not work.
Solve the problem of adding IPv4 forwarding configuration
Vi / etc/sysctl.conf or vi / usr/lib/sysctl.d/00-system.conf
Add a line to configure net.ipv4.ip_forward=1
Restart the network service using systemctl restart network
Use sysctl net.ipv4.ip_forward to check whether the modification is successful. If net.ipv4.ip_forward = 1 is returned, the modification is successful.
Restart the Docker container, problem resolved
Specify IP when starting the container
You can also use the-p parameter to specify IP (IP is the IPv4 address) when starting the container, for example: docker-p 192.168.216.1 docker 8080
Thank you for reading this article carefully. I hope the article "how to start error WARNING in Docker Container in Centos7" shared by the editor will be helpful to everyone. At the same time, I also hope you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!