5
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

【Rancher Desktop】chownでPermission deniedになる(@Mac)

Last updated at Posted at 2023-11-29

はじめに

  • 備忘録です
  • Macユーザー向けの説明です

以下のようなvolumeを利用するdocker-composeファイルを用意して、

docker-compose.yaml
version: "3"
services:
  mysql:
    build: ./
    volumes:
      - ./db:/var/lib/mysql #ここにデータ永続化するためのファイルが入る。
    image: mysqlapp
    container_name: "mysql"
    platform: linux/x86_64    # M1 Mac用の設定
    environment:
      - MYSQL_ROOT_PASSWORD=password
    ports:
      - "127.0.0.1:3306:3306"

docker-compose upコマンドを実行すると、コンテナ起動中にPermission deninedエラーが起きてコンテナの起動に失敗する。

$ docker-compose up
:
(省略)
:
mysql  | 2023-11-29 04:39:28+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.30-1debian11 started.
mysql  | chown: changing ownership of '/var/lib/mysql/': Permission denied
mysql  | chown: changing ownership of '/var/lib/mysql/binlog.000034': Permission denied
mysql  | chown: changing ownership of '/var/lib/mysql/binlog.000033': Permission denied
mysql  | chown: changing ownership of '/var/lib/mysql/private_key.pem': Permission denied
mysql  | chown: changing ownership of '/var/lib/mysql/database': Permission denied
:
(省略)
:

対処法

Rancher DesktopのGithubのIssueにあるように、以下の設定を
~/Library/Application\ Support/rancher-desktop/lima/_config/override.yamlに記載すれば良い。
(Rancher Desktopインストール直後、override.yamlは存在しないので、作成する必要がある)

override.yaml
mountType: 9p
mounts:
  - location: "~"
    9p:
      securityModel: mapped-xattr
      cache: "mmap"

注意(2024/7/23追記)
override.yamlを更新後はRancher Desktopを再起動すること!!
再起動しないと記載内容反映されないみたいです。(最近Rancher DesktopをFactory Resetして同じ問題に引っかかり、この対処をしたけど問題解決しなくて5分くらい悩んだ)

5
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?