mysql容器启动报错-chown: cannot read directory '/var/lib/mysql/': Permission denied

  |   0 评论   |   0 浏览

  

  容器中没有执行权限

  挂载外部数据卷时,无法启动容器

  报 chown: cannot read directory '/var/lib/mysql/': Permission denied

  查看 docker 日志

1docker logs mysql

  该原因为 CentOS7 默认开启 selinux

  需要临时关闭该安全模块

1setenforce 0

  查看

1getenforce

  永久修改 selinux

1vi /etc/selinux/config
2
3enabled 改成 disabled

  或者添加 selinux 规则,将要挂载的目录添加到白名单: 示例:

1chcon -Rt svirt_sandbox_file_t   /data/mysql/databases/
---------------------------------------------------------------
>> 博客地址:https://blog.mufengs.com
>> 邮箱地址:[email protected]
>> 微信帐号:Do8080
>> Github : https://github.com/mufengcoding
---------------------------------------------------------------