Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What to do when the Docker container starts the error WARNING in Centos7

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

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!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report