Beto Aveiga
Beto Aveiga

Reputation: 3690

Docker containers, memory consumption and logs

I've been trying Docker for a few days. I'm using a Drupal image (docker4drupal) which basically contains MySQL (MariaDB), PHP (php-fpm) and NGINX.

Almost everytime I do a database import to the database container, on a VPS with 512MB RAM, the container with MariaDB dies... and messages like "MySQL server has gone away" appear... And this does not happen when my VPS has 1GB o 2GB RAM.

So, this seems to be a memory problem, but I need the evidence! I don't know where is the log that tells me that my container died because wasn't enough memory.

I checked MariaDB logs but I can't find anything... it's log only say somethign like "the database was not normally shutdown" and thaen "it's starting" and then "wating for connections"...

So, independently of my MariaDB config (which is not proper for a 512MB VPS)... Where can I find explicitly the reason of why the container with the database server died?

Any help is welcome. Thanks a lot.

PD: I execute mysql cli from the PHP container, that's why despite the database container dies I still can see the output that something wrong happened.

Upvotes: 1

Views: 2629

Answers (3)

Rick James
Rick James

Reputation: 142528

That is probably too much to cram in a minuscule 512MB. Do one of

  • Increase RAM available. ("And this does not happen when my VPS has 1GB")
  • Split applications across multiple tiny Dockers.
  • Tune each app to use less RAM. (Didn't I answer your question recently?)

How many tables do you have? Hopefully not a lot, as in https://dba.stackexchange.com/questions/60888/mysql-runs-out-of-memory-when-importing-innodb-database

Upvotes: 0

agg3l
agg3l

Reputation: 1444

Could be the kernel terminating most memory-consuming process on 'lack-of-memory' event. Some entries may be there in host system log. Lack of such entries doesn't guarantee it wasn't kernel who killed your DB, though.

Exact filename depends on host system configuration (meaning the VPS, in your case). Could be /var/log/{system.log,error.log, ...}.

As long as docker container is not an isolated VM but a wrapper over kernel-driven cgroups, kernel events are handled by host system loggin daemon

Upvotes: 3

Vishnu Ranganathan
Vishnu Ranganathan

Reputation: 1355

Hi Beto we can see the logs in docker checkout the below commands:

The docker logs --follow command will continue streaming the new output from the container’s STDOUT and STDERR.

Upvotes: 1

Related Questions