高木のブログ

Docker + MySQL 8 で mbind: Operation not permitted が出る時の対応

2022/06/02

問題

Docker で MySQL 8 を使っていたらログに mbind: Operation not permitted がたくさん出た

docker-compose.yml
db:
  image: mysql:8.0.29
  environment:
    MYSQL_ROOT_PASSWORD: password
  ports:
    - "3306:3306"
  command: --default-authentication-plugin=mysql_native_password
  volumes:
    - mysql_vol:/var/lib/mysql
habitra-db-1   | 2022-05-27T05:48:22.844580Z 0 [Warning] [MY-011810] [Server] Insecure configuration for --pid-file: Location '/var/run/mysqld' in the path is accessible to all OS users. Consider choosing a different directory.
habitra-db-1   | 2022-05-27T05:48:22.871235Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Bind-address: '::' port: 33060, socket: /var/run/mysqld/mysqlx.sock
habitra-db-1   | 2022-05-27T05:48:22.871392Z 0 [System] [MY-010931] [Server] /usr/sbin/mysqld: ready for connections. Version: '8.0.29'  socket: '/var/run/mysqld/mysqld.sock'  port: 3306  MySQL Community Server - GPL.
habitra-web-1  | Puma starting in single mode...
habitra-web-1  | * Puma version: 5.6.4 (ruby 3.1.2-p20) ("Birdie's Version")
habitra-web-1  | *  Min threads: 0
habitra-web-1  | *  Max threads: 5
habitra-web-1  | *  Environment: development
habitra-web-1  | *          PID: 1
habitra-web-1  | * Listening on http://0.0.0.0:4567
habitra-web-1  | Use Ctrl-C to stop
habitra-db-1   | mbind: Operation not permitted
habitra-db-1   | mbind: Operation not permitted
habitra-db-1   | mbind: Operation not permitted
habitra-db-1   | mbind: Operation not permitted
habitra-db-1   | mbind: Operation not permitted

解決方法

CAP_SYS_NICE を有効にすると解決する

docker-compose.yml
 db:
   image: mysql:8.0.29
   environment:
     MYSQL_ROOT_PASSWORD: password
   ports:
     - "3306:3306"
   command: --default-authentication-plugin=mysql_native_password
   volumes:
     - mysql_vol:/var/lib/mysql
+  cap_add:
+    - SYS_NICE

MySQL 8 の新機能を有効にするために必要らしい
その新機能が何かは調べきれなかった

参考


SNS でシェアする


ytkg

Written by ytkg, Twitter, GitHub