简体   繁体   English

卷映射时的Docker权限问题

[英]Docker permission problems when doing volume mapping

I want to start a Jupyter notebook in a container. 我想在容器中启动Jupyter笔记本。 The requirement is that the notebooks that are created in the container should be also available on the host machine. 要求是在容器中创建的笔记本也应在主机上可用。 For this I do volume mapping: 为此,我进行体积映射:

docker run -it --rm -p 8888:8888 -v $(shell pwd):/home/jovyan/work --name=notebook jupyter/base-notebook

When I run the above command, I receive the following error: 当我运行上述命令时,出现以下错误:

docker: Error response from daemon: oci runtime error: container_linux.go:247: starting container process caused "chdir to cwd (\"/home/jovyan/work\") set in config.json failed: permission denied". ERRO[0000] error getting events from daemon: context canceled 

To solve this problem temporarily, I changed the permissions of the current working directory on the host: 为了暂时解决此问题,我更改了主机上当前工作目录的权限:

chmod a+rwx [current directory]

I thinks changing the permissions of the folders is not a good solution and there should be another problem. 我认为更改文件夹的权限不是一个好的解决方案,应该还有另一个问题。

Also I have to mention that I work in a company where I do not have sudo rights and we used a shared home directory. 我还要提到的是,我在一家没有sudo权限的公司中工作,我们使用了共享的主目录。

Actually I have this problem with all images. 其实我所有图像都有这个问题。 For example: 例如:

docker run -it -v /net/home/abc/Desktop/:/etc ubuntu:16.04

returns the following error: 返回以下错误:

docker: Error response from daemon: oci runtime error: container_linux.go:247: starting container process caused "process_linux.go:359: container init caused \"rootfs_linux.go:54: mounting \\\"/var/lib/docker/containers/7e62c50efab7141468a00ddefb59d55715449e05f1c516662ac1f73fabab2722/resolv.conf\\\" to rootfs \\\"/var/lib/docker/aufs/mnt/e71d751ce8d253eafcd0dc5f41379cc4dd73da89302cfe8171becd228fba960e\\\" at \\\"/etc/resolv.conf\\\" caused \\\"lstat /var/lib/docker/aufs/mnt/e71d751ce8d253eafcd0dc5f41379cc4dd73da89302cfe8171becd228fba960e/etc/resolv.conf: permission denied\\\"\"".

Also, make sure your docker user has access to the path you are trying to mount in your container. 此外,请确保您的Docker用户有权访问您尝试在容器中挂载的路径。

In my case, my home directory had 700 permissions, so the docker user didn't have access to traverse the directory path. 在我的情况下,我的主目录具有700个权限,因此docker用户无权遍历目录路径。 Giving read and execute permission allows the docker user to go through and mount correctly. 授予读取和执行许可权可使docker用户通过并正确安装。

Take a look at https://github.com/jupyter/docker-stacks/tree/master/base-notebook and notice the Docker Options. 看看https://github.com/jupyter/docker-stacks/tree/master/base-notebook并注意Docker选项。 Per default this image has an unprivilieged user jovyan, with no permissions to your $pwd directory. 默认情况下,该映像具有未特权用户jovyan,对您的$ pwd目录没有权限。 Via ENV you might fix this. 通过ENV,您可以解决此问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM