[LINUX] How to deal with the error that Docker's MySQL container fails to start on Docker Toolbox

Overview

Event

When I tried to launch a Docker container running MySQL with docker-compose, the container repeatedly restarted forever. Make a note of the solution to this problem here.

By the way, I had this problem when using Docker Toolbox on Windows, but it seems unlikely (probably) in other environments.

docker-compose.yml settings

The settings of the part of docker-compose.yml where this problem occurs are as follows.

  db:
    image: mysql:5.7
    volumes: 
      - "/tmp/db/data:/var/lib/mysql"
      - "./db:/usr/src/db"
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: $MYSQL_ROOT_PASSWORD
      MYSQL_DATABASE: $MYSQL_DATABASE
      MYSQL_USER: $MYSQL_USER
      MYSQL_PASSWORD: $MYSQL_PASSWORD
    ports:
      - 3306:3306

No special settings are made, just the minimum required settings based on the image of mysql: 5.7.

approach

Execute --innodb-use-native-aio = 0 in the launched container. So docker-compose.yml looks like this:

  db:
    image: mysql:5.7
    volumes: 
      - "/tmp/db/data:/var/lib/mysql"
      - "./db:/usr/src/db"
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: $MYSQL_ROOT_PASSWORD
      MYSQL_DATABASE: $MYSQL_DATABASE
      MYSQL_USER: $MYSQL_USER
      MYSQL_PASSWORD: $MYSQL_PASSWORD
    ports:
      - 3306:3306
     command: --innodb-use-native-aio=0 # <-this!

Why this solves

The MySQL Official Documentation has the following description.

InnoDB uses the asynchronous I/O subsystem (native AIO) on Linux to perform read-ahead and write requests for data file pages. This behavior is controlled by the innodb_use_native_aio configuration option, which applies to Linux systems only and is enabled by default.

InnoDB (the database engine for MySQL) is set to use Linux asynchronous I / O (native AIO) by default, but this behavior can be changed with the ʻinnodb_use_native_aio` option.

This time I was running the container on Windows using Docker Toolbox, but in that case this asynchronous I / O is not available, so it seems that an error occurred and the restart was repeated. Therefore, as stated in the quoted part above the official documentation, you need to set the ʻinnodb_use_native_aio` option to not use asynchronous I / O to avoid this problem.

About restarting the container

The container restarts because I wrote restart: always in docker-compose.yml. Otherwise, the container will fall normally.

Recommended Posts

How to deal with the error that Docker's MySQL container fails to start on Docker Toolbox
How to deal with the problem that pandas 1.1.0 or later build fails on Alpine Linux
How to deal with the phenomenon that Python (Jupyter notebook) executed on WSL becomes Aborted
How to deal with the error "Failed to load module" canberra-gtk-module "that appears when you run OpenCV
How to deal with the problem that build fails when CI / CD of Python Function with AWS Amplify
[Python] How to deal with pandas read_html read error
[systemd] How to deal with the problem that fancontrol does not work after suspending
[AWS] How to deal with "Invalid codepoint" error in CloudSearch
A story about how to deal with the CORS problem
How to start the program
[VLC] How to deal with the problem that it is not in the foreground during playback
How to solve the problem that APL does not start after transferring to the actual device on Kivy-iOS
How to deal with the problem that the current directory moves when Python is executed from Atom
When WSL Distro fails to start (error: "WslRegisterDistribution failed with error: 0x800706be.")
How to deal with imbalanced data
How to deal with imbalanced data
How to deal with DistributionNotFound errors
Use Docker Desktop for Windows to start the latest odo with 2 commands
How to deal with OAuth2 error when using Google APIs from Python
How to deal with SSL error when connecting to S3 with boto of Python
[AWS] How to deal with WordPress "An error occurred when cropping an image."
Connect to Docker's MySQL container from Flask
Connect to MySQL with Python within Docker
How to deal with enum compatibility errors
How to deal with the problem that Japanese characters are garbled when outputting logs using JSON log formatter
[Python] How to deal with the is instance error "is instance () arg 2 must be a type or tuple of types"
How to deal with "^ [[A ^ [[B ^ [[C ^ [[D"] when you press the arrow keys when executing python on mac
[Python] How to deal with module errors
How to install python3 with docker centos
How to publish a blog on Amazon S3 with the static Blog engine'Pelican'for Pythonista
How to get the key on Amazon S3 with Boto 3, implementation example, notes
How to deal with "No module named'〇〇'" error in Jupyter Notebook | Install with! Pip!
How to run a Django application on a Docker container (development and production environment)
Checklist on how to avoid turning the elements of numpy's array with for
[AWS] Wordpress How to deal with "The response is not a correct JSON response"
Resolve the error that appears without setting the user after DLing mysql on MAC
How to deal with memory leaks in matplotlib.pyplot
How to deal with errors when hitting pip ②
How to specify the NIC to scan with amazon-dash
How to delete log with Docker, not to collect log
Strategy on how to monetize with Python Java
can't pickle annoy. How to deal with Annoy objects
How to deal with run-time errors in subprocess.call
How to deal with module'tensorflow' has no attribute'〇〇'
How to deal with SessionNotCreatedException when using Selenium
How to install OpenGM on OSX with macports
Introduction to Python with Atom (on the way)
How to Learn Kaldi with the JUST Corpus
Connect to MySQL with Python on Raspberry Pi
How to filter foreign keys that can be selected on the Django admin screen
How to deal with "Type Error: No matching signature found" error when using pandas fillna
mong --I tried porting the code that randomly generates Docker container names to Python -
A memo on how to overcome the difficult problem of capturing FX with AI