Marinus Klasen

Marinus Klasen

  • Development
  • Consultancy
  • Developer Resources
  • 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

Looking for a WordPress expert?
Hire top notch developers on Codeable!

Consult an expert

Leave a Reply Cancel reply

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

Get in touch

Contact me using the details below

Marinus Klasen

Wilhelmina van Pruisenweg 35, 2595 AN Den Haag

marinus@mklasen.com
twitter.com/marinusklasen
linkedin.com/in/marinusklasen

  • GitHub
  • LinkedIn
  • Twitter

Have you read?

  • Elementor Widget UsageMarch 27, 2025
  • Programmatically showing popups with ElementorMarch 25, 2025
  • The Elementor sanitize_settings errorSeptember 12, 2024
  • Announcing.. Wooping Shop Health!June 13, 2024
  • Swiper setup when using wp-scriptsMarch 14, 2024

Copyright © 2025 ยท Marinus Klasen | Webdesign by Team Rood