无法在Docker容器中调用chown(适用于Windows的Docker) [英] Cannot call chown inside Docker container (Docker for Windows)

查看:584
本文介绍了无法在Docker容器中调用chown(适用于Windows的Docker)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用官方Mongo dockerfile 要启动数据库,我正在使用-v命令将本地目录映射到容器内的/data.

I am attempting to use the official Mongo dockerfile to boot up a database, I am using the -v command to map a local directory to /data inside the container.

作为Dockerfile的一部分,它尝试将该目录授予用户mongodb:

As part of the Dockerfile, it attempts to chown this directory to the user mongodb:

RUN mkdir -p /data/db /data/configdb \
    && chown -R mongodb:mongodb /data/db /data/configdb
VOLUME /data/db /data/configdb

但是,此操作失败,并显示以下命令:

However, this fails with the following command:

chown: changing ownership of '/data/db': Permission denied

我在这里做错了什么?我在这附近找不到任何文档-肯定容器应该对映射目录具有完全权限,因为它是在docker run命令中明确传递的:

What I am doing wrong here? I cannot find any documentation around this - surely the container should have full permissions to the mapped directory, as it was explicitly passed in the docker run command:

docker run -d --name mongocontainer -v R:\mongodata:/data/db -p 3000:27017 mongo:latest

推荐答案

您有类似的问题,说明了 mongo问题68 问题74

You have similar issues illustrating the same error message in mongo issues 68 or issue 74

主机卷目录不能位于/Users(或~)下.试试:

The host machine volume directory cannot be under /Users (or ~). Try:

docker run --name mongo -p 27017:27017 -v /var/lib/boot2docker/my-mongodb-data/:/data/db -d mongo --storageEngine wiredTiger

PR 470 添加:

警告:由于MongoDB使用内存映射文件,因此无法通过vboxsf将其用于您的主机( vbox错误).

WARNING: because MongoDB uses memory mapped files it is not possible to use it through vboxsf to your host (vbox bug).

MongoDB不支持VirtualBox共享文件夹(请参阅 docs.mongodb.org 和相关的 jira.mongodb. org 错误).

VirtualBox shared folders are not supported by MongoDB (see docs.mongodb.org and related jira.mongodb.org bug).

这意味着使用Docker Toolbox的默认设置无法运行将数据目录映射到主机的MongoDB容器.

This means that it is not possible with the default setup using Docker Toolbox to run a MongoDB container with the data directory mapped to the host.

这篇关于无法在Docker容器中调用chown(适用于Windows的Docker)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆