刚刚用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规则,改变要挂载的目录的安全性文本
# 更改安全性文本的格式如下

  1. chcon [-R] [-t type] [-u user] [-r role] 文件或者目录
  2.  
  3. 选顷不参数:
  4. -R :连同该目录下癿次目录也同时修改;
  5. -t :后面接安全性本文的类型字段!例如 httpd_sys_content_t
  6. -u :后面接身份识别,例如 system_u
  7. -r :后面街觇色,例如 system_r
  8.  
  9. [root@localhost Desktop]# chcon --help
  10. Usage: chcon [OPTION]... CONTEXT FILE...
  11. or: chcon [OPTION]... [-u USER] [-r ROLE] [-l RANGE] [-t TYPE] FILE...
  12. or: chcon [OPTION]... --reference=RFILE FILE...
  13. Change the SELinux security context of each FILE to CONTEXT.
  14. With --reference, change the security context of each FILE to that of RFILE.
  15.  
  16. Mandatory arguments to long options are mandatory for short options too.
  17. --dereference affect the referent of each symbolic link (this is
  18. the default), rather than the symbolic link itself
  19. -h, --no-dereference affect symbolic links instead of any referenced file
  20. -u, --user=USER set user USER in the target security context
  21. -r, --role=ROLE set role ROLE in the target security context
  22. -t, --type=TYPE set type TYPE in the target security context
  23. -l, --range=RANGE set range RANGE in the target security context
  24. --no-preserve-root do not treat '/' specially (the default)
  25. --preserve-root fail to operate recursively on '/'
  26. --reference=RFILE use RFILE's security context rather than specifying
  27. a CONTEXT value
  28. -R, --recursive operate on files and directories recursively
  29. -v, --verbose output a diagnostic for every file processed
  30.  
  31. The following options modify how a hierarchy is traversed when the -R
  32. option is also specified. If more than one is specified, only the final
  33. one takes effect.
  34.  
  35. -H if a command line argument is a symbolic link
  36. to a directory, traverse it
  37. -L traverse every symbolic link to a directory
  38. encountered
  39. -P do not traverse any symbolic links (default)
  40.  
  41. --help display this help and exit
  42. --version output version information and exit
  43.  
  44. GNU coreutils online help: <http://www.gnu.org/software/coreutils/>
  45. For complete documentation, run: info coreutils 'chcon invocation'

在主机中修改/soft目录的安全性文档

  1. [root@localhost Desktop]# chcon -Rt svirt_sandbox_file_t /soft
  2.  
  3. [root@ba471da26d07 soft]# ll
  4. total
  5. -rw-r--r--. root root Aug : hadoop-2.7..tar.gz
  6. -rw-r--r--. root root Aug : jdk-8u102-linux-x64.tar.gz
  7. docker中就可以正常访问该目录下的相关资源了。

原文链接:https://blog.csdn.net/rznice/article/details/52170085

docker-compose进行部署容器的时候,报错权限不足的更多相关文章

  1. Docker Compose 一键部署LNMP

    Docker Compose 一键部署LNMP 目录结构 [root@localhost ~]# tree compose_lnmp/ compose_lnmp/ ├── docker-compose ...

  2. Docker Compose 一键部署Nginx代理Tomcat集群

    Docker Compose 一键部署Nginx代理Tomcat集群 目录结构 [root@localhost ~]# tree compose_nginx_tomcat/ compose_nginx ...

  3. Docker Compose 一键部署多节点爬虫程序

    Docker Compose 一键部署多节点爬虫程序 目录结构 [root@localhost ~]# tree compose_crawler/ compose_crawler/ ├── cento ...

  4. Docker Compose安装部署Jenkins

    流水线可以让项目发布流程更加清晰,docker可以大大减少Jenkins配置. 1.前言 数据卷挂载到 /var 磁盘目录下,因为该磁盘空间较大,后面需要挂载容器数据卷,以防内存吃紧. 为了可以留存启 ...

  5. Docker Compose—简化复杂容器应用的利器

    Compose是用于定义和运行复杂Docker应用的工具.你可以在一个文件中定义一个多容器的应用,然后使用一条命令来启动你的应用,然后所有相关的操作都会被自动完成. 1. 安装Docker和Compo ...

  6. Docker | Compose创建mysql容器

    本文通过Docker Compose来创建mysql容器 在linux服务器上创建文件,用于管理容器 mkdir docker-mysql cd docker-mysql vim docker-com ...

  7. 开源跨境ERP - 小老板 Docker/Docker Compose一键部署

    先上部署成功后的截图,各个菜单点击均无报错 DockerCompose 包含: 1. 三个mysql5.7数据库 2. redis php会话存储+ memcached 3. 小老板php主程序 do ...

  8. 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 开始自动化部署 在部署过程中报错,报错信息如下 ...

  9. 部署Qt应用时候报错0xc000007b

    情况: 在开发环境可以运行,部署到其他电脑无法运行: 排错:百度.谷歌了很多方法不行,后来发现添加了Qt\5.11.0\mingw53_32\bin环境变量,程序执行正常,去掉就报错:猜测估计是dll ...

随机推荐

  1. Maven从入门到精通(一)

    maven是一个项目管理工具,我的后续将会根据这个思维导图给大家由浅到深讲解Maven是如何管理我们的项目,以及我们如何更好的使用Maven maven在开发过程中功能主要有三个方面:   管理依赖 ...

  2. hdoj4507(数位dp)

    题目链接:https://vjudge.net/problem/HDU-4507 题意:定义如果一个整数符合下面3个条件之一,那么我们就说这个整数和7有关—— 1.整数中某一位是7: 2.整数的每一位 ...

  3. 利用pcl数据结构,实现RegionGrowing的复现

    这篇博客是pcl中区域增长的算法进行简介以实现重写,并添加了一些判断条件. 起初原因是在使用pcl封装的regionGrowing时,效果不太好. 于是想自己重新写一下,通过改变其中种子点的生成策略和 ...

  4. redis 小结二

    1.在redis客户端获取redis 配置文件的某个配置信息(需要先打开redis客户端) config get 配置项   , 如果要列出所有的配置项( CONFIG GET *) 2.在redis ...

  5. Django 前端通过json 取出后端数据

    Django 前端通过json 取出后端数据 前端通过json 取出后端数据 步骤1:后台数据通过 JSON 序列化成字符串a 注意:1.json是1个字符串 ​ 2.通过json.dumps('xx ...

  6. 【golang】浅析rune数据类型

    golang中string底层是通过byte数组实现的.中文字符在unicode下占2个字节,在utf-8编码下占3个字节,而golang默认编码正好是utf-8. golang中还有一个byte数据 ...

  7. [转载]Linux软件包及dpkg\apt等方法

    Linux软件安装 来源:https://segmentfault.com/a/1190000011200004?share_user=1030000007255638 一.安装包分类 在Linux平 ...

  8. 089、初探ELK (2019-05-13 周一)

    参考https://www.cnblogs.com/CloudMan6/p/7770916.html   在开源的日志管理方案中,最出名的莫过于ELK了.ELK是三个软件的合称: Elasticsea ...

  9. php邮件防注入以及实现经典代码

    <?php function spamcheck($field) {     // filter_var() 过滤 e-mail     // 使用 FILTER_SANITIZE_EMAIL ...

  10. Flask开发系列之Flask+redis实现IP代理池

    Flask开发系列之Flask+redis实现IP代理池 代理池的要求 多站抓取,异步检测:多站抓取:指的是我们需要从各大免费的ip代理网站,把他们公开的一些免费代理抓取下来:一步检测指的是:把这些代 ...