Marinus Klasen

Marinus Klasen

  • Blog
  • Contact

December 31, 2021

Mysql on Docker: exited with code 0, io_setup() failed EAGAIN

Marinus Klasen

I’ve encountered this several times and usually just run the quick fix: Destroy the container and restart with a new one. But, in this case, I really don’t want to go through that trouble, so let’s go ahead and fix this.

What does it mean?

Some quick research reveals that this has to do with – you guessed it – input and output. It somehow fails the setup.

What else do we see?

The logs provide some more information, as seen below:

InnoDB: You can disable Linux Native AIO by setting innodb_use_native_aio = 0 in my.cnf
InnoDB: Cannot initialize AIO sub-system

Well, let’s create some config files and apply the setting above!

My current docker-compose.yml database service looks like this:

  db:
    container_name: ${NAME}-db
    image: mysql:5.7
    environment:
      MYSQL_ROOT_PASSWORD: ${MYSQL_PASSWORD}
      MYSQL_DATABASE: ${DB_NAME}
      MYSQL_USER: ${DB_USER}
      MYSQL_PASSWORD: ${DB_PASSWORD}
    volumes:
      - "./app/data/db:/var/lib/mysql"

In order to define our own config files, we’ll have to add a new volume, like below:

- "./app/conf/my.cnf:/etc/alternatives/my.cnf"

Combined, the service looks like this:

  db:
    container_name: ${NAME}-db
    image: mysql:5.7
    environment:
      MYSQL_ROOT_PASSWORD: ${MYSQL_PASSWORD}
      MYSQL_DATABASE: ${DB_NAME}
      MYSQL_USER: ${DB_USER}
      MYSQL_PASSWORD: ${DB_PASSWORD}
    volumes:
      - "./app/data/db:/var/lib/mysql"
      - "./app/conf/my.cnf:/etc/alternatives/my.cnf"

Create a file called my.cnf in the conf directory and add the following content:

[mysqld]
innodb_use_native_aio = 0

Let’s see if that works by running docker-compose up again.

It did!

After disabling native AIO, the mysql starts successfully. Problem solved!

About Marinus Klasen

Marinus has been working in software/web development for more than a decade. Since 2020 his attention shifted on sharing knowledge and developing products and tools for sharing knowledge.

Marinus Klasen on Twitter

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Ready to take action?

I'm looking forward to discuss your projects and goals!
Feel free to reach out using the contact details below.

Marinus Klasen

[email protected]
twitter.com/marinusklasen
linkedin.com/in/marinusklasen

Have you read?

  • Remove all edit post links in WordPress with a simple filterMay 11, 2022
  • Registering block styles in WordPress with PHPMay 11, 2022
  • Host key verification failed when connecting over SSH?April 20, 2022
  • Run VS Code server (Remote SSH) on AlpineApril 19, 2022
  • Show the errors and notices from WordPress in DockerApril 18, 2022

Copyright © 2022 · Marinus Klasen | Webdesign by Team Rood