【问题标题】:File permission issue with mongo docker imagemongo docker镜像的文件权限问题
【发布时间】:2020-03-08 14:28:06
【问题描述】:

我正在尝试使用以下命令实例化一个 mongodb docker 映像:

docker run -e MONGO_INITDB_ROOT_USERNAME=root -e MONGO_INITDB_ROOT_PASSWORD=password mongo

由于权限被拒绝,命令立即失败:

2019-11-12T20:16:29.503+0000 I  CONTROL  [main] ERROR: Cannot write pid file to /tmp/docker-entrypoint-temp-mongod.pid: Permission denied

奇怪的是,相同的命令在其他一些具有相同用户、组的机器上运行良好……唯一不同的是 docker 版本。

我不明白为什么 mongo 实例没有运行,因为我没有在命令行上指定任何卷或用户。

这是我的码头工人信息

Client:
 Debug Mode: false
Server:
 Containers: 29
  Running: 1
  Paused: 0
  Stopped: 28
 Images: 87
 Server Version: 19.03.4
 Storage Driver: overlay2
  Backing Filesystem: extfs
  Supports d_type: true
  Native Overlay Diff: true
 Logging Driver: json-file
 Cgroup Driver: cgroupfs
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
 Swarm: inactive
 Runtimes: runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: b34a5c8af56e510852c35414db4c1f4fa6172339
 runc version: 3e425f80a8c931f88e6d94a8c831b9d5aa481657
 init version: fec3683
 Security Options:
  seccomp
   Profile: default
 Kernel Version: 4.9.0-11-amd64
 Operating System: Debian GNU/Linux 9 (stretch)
 OSType: linux
 Architecture: x86_64
 CPUs: 4
 Total Memory: 25.52GiB
 Name: jenkins-vm
 ID: YIGQ:YOVJ:2Y7F:LM77:VHK6:ICMY:QDGA:5EFD:ZYDD:EQM5:DR77:DANT
 Docker Root Dir: /data/var/lib/docker
 Debug Mode: false
 Registry: https://index.docker.io/v1/
 Labels:
 Experimental: false
 Insecure Registries:
  127.0.0.0/8
 Live Restore Enabled: false
WARNING: No swap limit support

正如@jan-garaj 所建议的,这是docker run -e MONGO_INITDB_ROOT_USERNAME=root -e MONGO_INITDB_ROOT_PASSWORD=password mongo id 的结果: uid=0(root) gid=0(root) groups=0(root)

这次失败的原因可能是什么?

【问题讨论】:

    标签: mongodb docker jenkins permissions


    【解决方案1】:

    您的某些安全配置可能存在问题。检查并比较 docker info 输出。您可能启用了用户命名空间 (userns-remap)、一些特殊的 seccomp、selinux 策略、奇怪的存储驱动程序、完整的磁盘空间……

    【讨论】:

    • docker信息相同
    • @benjamin.d 请将docker info 输出附加到+ docker run -e MONGO_INITDB_ROOT_USERNAME=root -e MONGO_INITDB_ROOT_PASSWORD=password mongo id
    【解决方案2】:

    可能是因为 selinux 政策:

    在 /etc/selinux/config 编辑配置文件:

    SELINUX:disabled
    

    重启你的系统,然后尝试运行镜像。

    【讨论】:

    • 我试过了,但是没有用。我得到完全相同的结果
    猜你喜欢
    • 1970-01-01
    • 2021-12-29
    • 2021-01-14
    • 2021-08-03
    • 1970-01-01
    • 2018-10-13
    • 2017-08-08
    • 2016-04-29
    • 2018-04-28
    相关资源
    最近更新 更多