Skip to content

Really high memory usage #579

@hnioche

Description

@hnioche

Hi,
I'm using docker for a development environment which has a mysql image.
On my current computer, running arch linux up to date with the default docker setup (community/docker and community/docker-compose).
All the containers I use locally works fine (a ruby container, a nodejs one, a few dotnet core, memcahed).

I only have issues with mysql that uses all the memory available that, each time I start the container, uses immediately all the memory of my computer.
Even the most basic use of the docker image with no database uses 16GB.

I've tried the docker library mysql image, version 8 and 5.7, the oracle version, the percona version, they all have the same issue.
I've tried mariadb and it works as it's supposed, using 100 something MB.
I've tried the same mysql image with podman and had no issue, it uses around 200 MB.

My version of docker is:

Docker version 18.09.8-ce, build 0dd43dd87f

Here's the Dockerfile

FROM mysql:5.7
ENV MYSQL_ROOT_PASSWORD rootpassword
ENV MYSQL_ALLOW_EMPTY_PASSWORD=yes
ENV MYSQL_DATABASE=database

Here's docker stats

CONTAINER ID        NAME                CPU %               MEM USAGE / LIMIT     MEM %               NET I/O             BLOCK I/O           PIDS
d66ccdbd03aa        boring_haibt        0.20%               14.27GiB / 15.51GiB   92.00%              1.34kB / 0B         439MB / 299MB       27

And top inside the container

top - 16:11:06 up  7:32,  0 users,  load average: 0.84, 2.05, 1.42
Tasks:   2 total,   1 running,   1 sleeping,   0 stopped,   0 zombie
%Cpu(s):  5.4 us,  3.0 sy,  0.2 ni, 87.1 id,  3.3 wa,  0.9 hi,  0.2 si,  0.0 st
KiB Mem:  16262332 total, 16100992 used,   161340 free,    10252 buffers
KiB Swap:  8388604 total,  6197880 used,  2190724 free.   443820 cached Mem

  PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND
    1 mysql     20   0 17.005g 0.013t      0 S   0.0 85.0   0:05.59 mysqld
  172 root      20   0   24152   2336   2000 R   0.0  0.0   0:00.15 top

I tried to limit the memory usage of the container using -m and mysqld refuses to start when it is bellow 10g with the error:

ERROR: mysqld failed while attempting to check config
command was: "mysqld --verbose --help"

I found something even weirder.
On the same machine, I run a Windows virtual machine using qemu-kvm.
When this machine is started, the mysql container behave normally. When this machine is not started, it uses all the memory of my computer.

I'm not entirely sure the issue is due to this docker image, but I'm a bit lost and don't know how to troubleshoot this problem further. It seems to be specific to mysql running in a container on docker.

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionUsability question, not directly related to an error with the image

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions