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 ...
随机推荐
- Linux 下面根据端口号 查询 可执行程序的路劲的方法
1. 安装上lsof 的包 2. 使用 lsof 命令查看相关进程 lsof -i: 效果为: 3. 根据/proc 的目录查看可执行目录的文件位置 ll /proc/procid # procid ...
- (2.2)【转】mysql的SQL笔记
一千行 MySQL 详细学习笔记 IT技术思维 4月1日 ↑↑↑点上方蓝字关注并星标⭐「IT技术思维」 一起培养顶尖技术思维 作者:格物 原文链接:https://shockerli.net/post ...
- @OneToMany 一对多 通过表之间的链接
https://blog.csdn.net/qq_38157516/article/details/80146547 一对多 一个人对多张卡,但是一张卡只能对应一个人,典型的一对多关系,下面就用One ...
- Two progressions CodeForces - 125D (暴力)
大意: 给定序列, 求划分为两个非空等差序列. 暴搜, 加个记忆化剪枝. #include <iostream> #include <sstream> #include < ...
- JavaSE基础:泛型
泛型 1.引入 情景模式描述,假设完成一个学生的成绩的情况: 整数: math=80,english=70 小数: math=85.6,englisth=77.8 字符串: math="66 ...
- mac osx sed 命令
$ sed -i "s/devicedemo/device/g" `grep devicedemo -rl ./` sed: 1: ".//.coveragerc&quo ...
- 使用 supervisor 管理 Celery 服务
使用 supervisor 管理 Celery 服务 Celery 后台运行 如果我们想让celery worker运行在后台而不是终端上,在后台以守护进程的方式运行,我们可以使用supervisor ...
- GDAL栅格矢量化
在这里主要提供直接能用的栅格矢量化代码,这个函数中路径输入为QStrng,如果是其他类型的,请直接转成const char *: bool Polygonize(const QString& ...
- Qualcomm_Mobile_OpenCL.pdf 翻译-4-Adreno OpenCL的程序开发
这章将简要讨论一些开发Adreno OpenCL应用程序的基本要求,下面将会介绍如何调试和统计程序性能. 4.1 安卓平台上开发OpenCL程序 目前,Adreno GPU主要是在安卓操作系统和在部 ...
- (转)JAVA socket 进行十六进制报文交互测试
import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io. ...