Docker Community Forums

Share and learn in the Docker community.

MariaDB in Docker keeps Restarting

I’m running into issues with my MariaDB databases restarting constantly.

Error logs below:

The website encountered an unexpected error. Please try again later.
PDOException: SQLSTATE[HY000] [2002] Connection timed out in Drupal\Component\DependencyInjection\PhpArrayContainer->createService() (line 79 of /app/web/core/lib/Drupal/Component/DependencyInjection/PhpArrayContainer.php).
Drupal\Component\DependencyInjection\PhpArrayContainer->createService(Array, 'database') (Line: 173)
Drupal\Component\DependencyInjection\Container->get('database', 1) (Line: 212)
Drupal\Component\DependencyInjection\PhpArrayContainer->resolveServicesAndParameters(Array) (Line: 62)
Drupal\Component\DependencyInjection\PhpArrayContainer->createService(Array, 'cache.container') (Line: 173)
Drupal\Component\DependencyInjection\Container->get('cache.container') (Line: 544)
Drupal\Core\DrupalKernel->getCachedContainerDefinition() (Line: 910)
Drupal\Core\DrupalKernel->initializeContainer() (Line: 477)
Drupal\Core\DrupalKernel->boot() (Line: 707)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

docker-compose.yml

version: "3"
services:
  db:
    image: mariadb:10.2
    environment:
      MYSQL_DATABASE: drupal
      MYSQL_ROOT_PASSWORD: xxxx
    volumes:
      - db_data:/var/lib/mysql
    restart: always
    container_name: drupal_database
  drupal:
    depends_on:
      - db
    build: .
    ports:
      - "8370:80"
    volumes:
      - ./app:/app
    restart: always
volumes:
  db_data:

Error logs from docker-compose up:

drupal_database | 2021-01-27 14:51:02 140214719071552 [Note] mysqld (mysqld 10.2.23-MariaDB-1:10.2.23+maria~bionic) starting as process 1 ...
drupal_database | 2021-01-27 14:51:02 140214719071552 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
drupal_database | 2021-01-27 14:51:02 140214719071552 [Note] InnoDB: Uses event mutexes
drupal_database | 2021-01-27 14:51:02 140214719071552 [Note] InnoDB: Compressed tables use zlib 1.2.11
drupal_database | 2021-01-27 14:51:02 140214719071552 [Note] InnoDB: Using Linux native AIO
drupal_database | 2021-01-27 14:51:02 140214719071552 [Note] InnoDB: Number of pools: 1
drupal_database | 2021-01-27 14:51:02 140214719071552 [Note] InnoDB: Using SSE2 crc32 instructions
drupal_database | 2021-01-27 14:51:02 140214719071552 [Note] InnoDB: Initializing buffer pool, total size = 256M, instances = 1, chunk size = 128M
drupal_database | 2021-01-27 14:51:02 140214719071552 [Note] InnoDB: Completed initialization of buffer pool
drupal_database | 2021-01-27 14:51:02 140213997057792 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority().
drupal_database | 2021-01-27 14:51:02 140214719071552 [Note] InnoDB: Highest supported file format is Barracuda.
drupal_database | 2021-01-27 14:51:02 140214719071552 [Note] InnoDB: 128 out of 128 rollback segments are active.
drupal_database | 2021-01-27 14:51:02 140214719071552 [Note] InnoDB: Creating shared tablespace for temporary tables
drupal_database | 2021-01-27 14:51:02 140214719071552 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
drupal_database | 2021-01-27 14:51:02 140214719071552 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
drupal_database | 2021-01-27 14:51:02 140214719071552 [Note] InnoDB: Waiting for purge to start
drupal_database | 2021-01-27 14:51:02 140214719071552 [Note] InnoDB: 5.7.25 started; log sequence number 1552585420
drupal_database | 2021-01-27 14:51:02 140213619775232 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool
drupal_database | 2021-01-27 14:51:02 140213619775232 [Note] InnoDB: Buffer pool(s) load completed at 210127 14:51:02
drupal_database | 2021-01-27 14:51:02 140214719071552 [Note] Plugin 'FEEDBACK' is disabled.
drupal_database | 2021-01-27 14:51:02 140214719071552 [Note] Recovering after a crash using tc.log
drupal_database | 2021-01-27 14:51:02 140214719071552 [ERROR] Can't init tc log
drupal_database | 2021-01-27 14:51:02 140214719071552 [ERROR] Aborting

I’ve seen topics elsewhere recommending that I delete tc log but its not where I expect it to be in /var/ on my mac.

I’ve been wrestling with this for ages so any help would be most appreciated. Any further info you need I can provide!