Measures for permissions when building MySQL with Docker on WSL2

Preface

WSL2 This is for those who are addicted to finding a solution to permission even if they search with MySQL. (Always link with Docker on Windows ... Do you use GPU!)

environment

phenomenon

When I start the container with docker-compose up -d, the MySQL container cannot be started like the following.

root@pc-name: docker-compose logs mysql
mysql_1   | mysqld: Cannot change permissions of the file 'private_key.pem' (OS errno 1 - Operation not permitted)
mysql_1   | 2020-09-10T05:04:53.449233Z 0 [ERROR] [MY-010295] [Server] Could not set file permission for private_key.pem
mysql_1   | 2020-09-10T05:04:53.449629Z 0 [ERROR] [MY-010119] [Server] Aborting

I want to describe the countermeasures for this guy ( permission)

Correspondence

Add mount options to /etc/wsl.conf.

Mount options to add


[automount]
options = "metadata"

I think that the beginning of WSL2 does not exist basically, so follow the procedure below. Create `` `/etc/wsl.conf``` in the WSL2 distribution.

#Login with root
user@pc-name:sudo -i
#Create a new wsl config file on the wsl distribution
root@pc-name: sudo touch /etc/wsl.conf
#Edit the configuration file.
root@pc-name: vi /etc/wsl.conf

Change mount options. Put the vi command in insert mode with i and enter the following.

[automount]
options = "metadata"

After pressing ESC, overwrite and save (: wq) and restart WSL.

#Route logout
root@pc-name:exti
#wsl logout
user@pc-name:exit
#WSL shutdown
wsl --shutdown
#Start WSL + login
wsl

I think that the Permission error has disappeared again due to Docker.

bonus

The following log is because the mount directory of / var / lib / mysql already exists. The solution is to delete that directory.

root@pc-name: docker-compose logs mysql
...
mysql_1   | 2020-09-10T05:00:42.590708Z 0 [ERROR] [MY-010457] [Server] --initialize specified but the data directory has files in it. Aborting.
mysql_1   | 2020-09-10T05:00:42.590714Z 0 [ERROR] [MY-013236] [Server] The designated data directory /var/lib/mysql/ is unusable. You can remove all files that the server added to it.
mysql_1   | 2020-09-10T05:00:42.590777Z 0 [ERROR] [MY-010119] [Server] Aborting

Recommended Posts

Measures for permissions when building MySQL with Docker on WSL2
Building an environment for WordPress, MySQL and phpMyAdmin with Docker Compose on EC2
Procedure for building a Rails application development environment with Docker [Rails, MySQL, Docker]
Image flew when updating Docker with WSL2
Time shift measures with Docker for Windows
Notes on building Rails6 / PostgreSQL with Docker Compose
Operate Docker Desktop for Windows on Linux (WSL)
How to start with Hyper-V instead of WSL2 on Docker Desktop for Windows
Explode Docker with WSL2
[Docker] Connection with MySQL
Docker installation on WSL2
When Kubernetes doesn't start on Docker Desktop for Mac
A memo when building a Rails 5.2 development environment using Docker Desktop + WSL2 on Windows 10 Home
Docker for Windows: MySQL container does not start when migrating from Hyper-v to WSL2
Docker autostart settings with wsl2
Build docker environment with WSL
docker-compose.yml when you want to keep mysql running with docker
Build a SPA for Laravel 6.2 / Vue.js / Nginx / Mysql / Redis with Docker
Install metrics-server with Helm on Kubernetes that comes with Docker for Mac
Building a haskell environment with Docker + VS Code on Windows 10 Home
When building docker image with GitLab CI, wait until docker daemon starts
WSL2 + Docker Desktop for Windows does not launch only MySQL container
Build a development environment for Django + MySQL + nginx with Docker Compose
"Rails 6 x MySQL 8" Docker environment construction procedure for sharing with teams
Rails + MySQL environment construction with Docker
Environment construction with Docker for beginners
Read dump file with Docker MySQL
WordPress with Docker Compose on CentOS 8
[Environment construction with Docker] Rails 6 & MySQL 8
mysql doesn't start up with docker.
Using Docker on Windows10 Home WSL2
Update MySQL from 5.7 to 8.0 with Docker
Build debug environment on container --Build local development environment for Rails tutorial with Docker-
Tutorial 1 for building apps with Rails (First steps to Yay! You're on Rails!)
Clone your own web app on GitLab when building a Docker image
Complete roadmap for building environment up to Docker + rails6 + MySQL + bootstrap, jquery
Windows Docker: Disk pressure on WSL files
Building Rails 6 and PostgreSQL environment with Docker
Create Rails 6 + MySQL environment with Docker compose
Using JupyterLab + Java with WSL on Windows 10
Install Docker Desktop for Mac with Homebrew
Deploy to heroku with Docker (Rails 6, MySQL)
Scraping with puppeteer in Nuxt on Docker.
Getting Started with Docker for Mac (Installation)
Precautions when making Docker for deep learning
Edit Mysql with commands in Docker environment
Create a MySQL environment with Docker from 0-> 1
Instructions for building Apache Derby on Windows
Allow image posting with [Docker + WordPress + MySQL]
Use cljstyle with Spacemacs on Ubuntu on WSL2
GPU recognition with docker using WSL2 (August 2020)
Implement simple CRUD with Go + MySQL + Docker
Try putting Docker in ubuntu on WSL
Build an environment with Docker on AWS
Launched Redmine with Docker on Raspberry Pi 3
Run Ubuntu + ROS with Docker on Mac
[Error resolution] Occurs when trying to build an environment for spring with docker
A memorandum when building an environment with Ruby3.0 x Rails6.1 x Docker x CentOS Stream
Experience CI / CD with katacoda (for beginners) --Part10 (Building Docker Images using Jenkins)