docker-compose进行部署容器的时候,报错权限不足
刚刚用docker-compose部署elk的时候,没有起来,查看日志的时候,发现在数据卷挂载的时候,报错权限不足。
由于日志不在了,这里就直接贴出解决办法。
问题原因及解决办法
原因是CentOS7中的安全模块selinux把权限禁掉了,至少有以下三种方式解决挂载的目录没有权限的问题:
1.在运行容器的时候,给容器加特权,及加上 --privileged=true 参数:
docker run -i -t -v /soft:/soft --privileged=true 686672a1d0cc /bin/bash
注:这种适合docker run
2.临时关闭selinux:
setenforce 0
用这种解决了问题。
3.添加selinux规则,改变要挂载的目录的安全性文本
# 更改安全性文本的格式如下
chcon [-R] [-t type] [-u user] [-r role] 文件或者目录 选顷不参数:
-R :连同该目录下癿次目录也同时修改;
-t :后面接安全性本文的类型字段!例如 httpd_sys_content_t ;
-u :后面接身份识别,例如 system_u;
-r :后面街觇色,例如 system_r [root@localhost Desktop]# chcon --help
Usage: chcon [OPTION]... CONTEXT FILE...
or: chcon [OPTION]... [-u USER] [-r ROLE] [-l RANGE] [-t TYPE] FILE...
or: chcon [OPTION]... --reference=RFILE FILE...
Change the SELinux security context of each FILE to CONTEXT.
With --reference, change the security context of each FILE to that of RFILE. Mandatory arguments to long options are mandatory for short options too.
--dereference affect the referent of each symbolic link (this is
the default), rather than the symbolic link itself
-h, --no-dereference affect symbolic links instead of any referenced file
-u, --user=USER set user USER in the target security context
-r, --role=ROLE set role ROLE in the target security context
-t, --type=TYPE set type TYPE in the target security context
-l, --range=RANGE set range RANGE in the target security context
--no-preserve-root do not treat '/' specially (the default)
--preserve-root fail to operate recursively on '/'
--reference=RFILE use RFILE's security context rather than specifying
a CONTEXT value
-R, --recursive operate on files and directories recursively
-v, --verbose output a diagnostic for every file processed The following options modify how a hierarchy is traversed when the -R
option is also specified. If more than one is specified, only the final
one takes effect. -H if a command line argument is a symbolic link
to a directory, traverse it
-L traverse every symbolic link to a directory
encountered
-P do not traverse any symbolic links (default) --help display this help and exit
--version output version information and exit GNU coreutils online help: <http://www.gnu.org/software/coreutils/>
For complete documentation, run: info coreutils 'chcon invocation'
在主机中修改/soft目录的安全性文档
[root@localhost Desktop]# chcon -Rt svirt_sandbox_file_t /soft [root@ba471da26d07 soft]# ll
total
-rw-r--r--. root root Aug : hadoop-2.7..tar.gz
-rw-r--r--. root root Aug : jdk-8u102-linux-x64.tar.gz
在docker中就可以正常访问该目录下的相关资源了。
原文链接:https://blog.csdn.net/rznice/article/details/52170085
docker-compose进行部署容器的时候,报错权限不足的更多相关文章
- Docker Compose 一键部署LNMP
Docker Compose 一键部署LNMP 目录结构 [root@localhost ~]# tree compose_lnmp/ compose_lnmp/ ├── docker-compose ...
- Docker Compose 一键部署Nginx代理Tomcat集群
Docker Compose 一键部署Nginx代理Tomcat集群 目录结构 [root@localhost ~]# tree compose_nginx_tomcat/ compose_nginx ...
- Docker Compose 一键部署多节点爬虫程序
Docker Compose 一键部署多节点爬虫程序 目录结构 [root@localhost ~]# tree compose_crawler/ compose_crawler/ ├── cento ...
- Docker Compose安装部署Jenkins
流水线可以让项目发布流程更加清晰,docker可以大大减少Jenkins配置. 1.前言 数据卷挂载到 /var 磁盘目录下,因为该磁盘空间较大,后面需要挂载容器数据卷,以防内存吃紧. 为了可以留存启 ...
- Docker Compose—简化复杂容器应用的利器
Compose是用于定义和运行复杂Docker应用的工具.你可以在一个文件中定义一个多容器的应用,然后使用一条命令来启动你的应用,然后所有相关的操作都会被自动完成. 1. 安装Docker和Compo ...
- Docker | Compose创建mysql容器
本文通过Docker Compose来创建mysql容器 在linux服务器上创建文件,用于管理容器 mkdir docker-mysql cd docker-mysql vim docker-com ...
- 开源跨境ERP - 小老板 Docker/Docker Compose一键部署
先上部署成功后的截图,各个菜单点击均无报错 DockerCompose 包含: 1. 三个mysql5.7数据库 2. redis php会话存储+ memcached 3. 小老板php主程序 do ...
- kolla部署openstack allinone,报错APIError: 500 Server Error: Internal Server Error (\"oci runtime error: container_linux.go:235: starting container process caused \"container init exited prematurely
使用 kolla-ansible 部署 opnenstack:stein 执行 kolla-ansible -i ./all-in-one deploy 开始自动化部署 在部署过程中报错,报错信息如下 ...
- 部署Qt应用时候报错0xc000007b
情况: 在开发环境可以运行,部署到其他电脑无法运行: 排错:百度.谷歌了很多方法不行,后来发现添加了Qt\5.11.0\mingw53_32\bin环境变量,程序执行正常,去掉就报错:猜测估计是dll ...
随机推荐
- 六、Kubernetes_V1.10集群部署-node-部署节点组件
一.配置kubelet 1.配置启动文件 # cat > /usr/lib/systemd/system/kubelet.service <<EOF [Unit] Descripti ...
- Linux下路由配置梳理(转)
转自:https://www.cnblogs.com/kevingrace/p/6490627.html 在日常运维作业中,经常会碰到路由表的操作.下面就linux运维中的路由操作做一梳理:----- ...
- sqlserver with(nolock)而mysql 不需nolock
nolock 是 SQL Server 特有的功能. 例如:对于一个表 A,更新了一行,还没有commit,这时再select * from A 就会死锁.用select * from A(noloc ...
- 打印输出opencv的版本信息
本文链接: https://mangoroom.cn/opencv/print-opencv-version-info.html 序 查看自己安装的opencv的版本信息的方法有两种. 方法一-查看l ...
- python 安装 colorama 控制台输出彩色文字
pip install colorama from colorama import Back,Fore,Style # 字体颜色print(Fore.LIGHTBLUE_EX,'HelloWorLd' ...
- python 链接mysql 事务
import mysql.connector try: con = mysql.connector.connect( host="localhost", port="33 ...
- 吴恩达机器学习101:SVM优化目标
1.为了描述SVM,需要从logistic回归开始进行学习,通过改变一些小的动作来进行支持向量机操作.在logistic回归中我们熟悉了这个假设函数以及右边的sigmoid函数,下式中z表示θ的转置乘 ...
- 关于echarts 重绘/图表切换/数据清空
容器id 为main var myChart=document.getElementById("main") myChart.removeAttribute("_echa ...
- Delphi上机步骤
- laravel-admin利用ModelTree实现对分类信息的管理
根据laravel的基本操作步骤依次完成如下操作:主要是参考laravel-admin内置的Menu菜单管理的功能,利用ModelTree实现业务中的Tree数据管理. 1. 创建模型 php art ...