docker and mysql: Got an error reading communication packets docker and mysql: Got an error reading communication packets docker docker

docker and mysql: Got an error reading communication packets


Check the below:

  • max_allowed_packets
  • wait_timeout
  • net_read_timeout

Also monitor MySQL process list during the issue to identify timeouts.


Can you try some wait, it could be possible that application try to connect to mysql server before its ready to accept connection. To test this, add some wait on startup or run mysql followed by application as different deployments.


The fix is to add --wait-timeout=28800 (or higher number) into MySQL arguments:

Args: [  "mysqld",  "--max-connections=1000",  "--sql-mode=ALLOW_INVALID_DATES,ANSI_QUOTES,ERROR_FOR_DIVISION_BY_ZERO,HIGH_NOT_PRECEDENCE,IGNORE_SPACE,NO_AUTO_CREATE_USER,NO_AUTO_VALUE_ON_ZERO,NO_BACKSLASH_ESCAPES,NO_DIR_IN_CREATE,NO_ENGINE_SUBSTITUTION,NO_FIELD_OPTIONS,NO_KEY_OPTIONS,NO_TABLE_OPTIONS,NO_UNSIGNED_SUBTRACTION,NO_ZERO_DATE,NO_ZERO_IN_DATE,ONLY_FULL_GROUP_BY,PIPES_AS_CONCAT,REAL_AS_FLOAT,STRICT_ALL_TABLES,STRICT_TRANS_TABLES,ANSI,DB2,MAXDB,MSSQL,MYSQL323,MYSQL40,ORACLE,POSTGRESQL,TRADITIONAL",  "--wait-timeout=28800" // 28800 sec = 8 hours],

Reference: https://dev.mysql.com/doc/refman/5.7/en/server-system-variables.html#sysvar_wait_timeout

But maybe it's wiser to find out what is the root cause for idle connections.