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

This site runs on Cloudways.
It's fast isn't it?
Cloudways offers high-quality, fast and affordable hosting.

Learn more

Need a hand? Post your project and hire me and other top notch developers on Codeable.

Hire me on Codeable

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

  • GitHub
  • LinkedIn
  • Twitter

Have you read?

  • Storing private data with SSH on WPEngine sitesDecember 15, 2022
  • Get the HTML content of a block edit page or post in WordPressNovember 30, 2022
  • Rename Coupon code text to Discount code in WoocommerceNovember 3, 2022
  • Background-size cover in mPDFOctober 22, 2022
  • WordPress.com SSH & duplicating a WordPress.com website locallyOctober 11, 2022

Copyright © 2023 · Marinus Klasen | Webdesign by Team Rood