如何在Windows版Docker(Windows 10)中挂载网络卷 [英] How to mount network Volume in Docker for Windows (Windows 10)

查看:355
本文介绍了如何在Windows版Docker(Windows 10)中挂载网络卷的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在努力在Docker中创建标准的数据科学映像,以帮助我们的团队维护一致的环境。为了使它对我们有用,我们需要容器对我们公司的网络具有读/写访问权限。如何将网络驱动器安装到Docker容器?

We're working to create a standard "data science" image in Docker in order to help our team maintain a consistent environment. In order for this to be useful for us, we need the containers to have read/write access to our company's network. How can I mount a network drive to a docker container?

以下是我使用Docker Hub中的rocker / rstudio映像进行的尝试:

Here's what I've tried using the rocker/rstudio image from Docker Hub:

这有效:

docker run -d -p 8787:8787 -v // c / users / {插入用户}:/ home / rstudio / foobar rocker / rstudio

这不起作用(其中P是网络驱动器的映射位置):
docker run -d -p 8787:8787 -v // p:/ home / rstudio / foobar rocker / rstudio

This does not work (where P is the mapped location of the network drive): docker run -d -p 8787:8787 -v //p:/home/rstudio/foobar rocker/rstudio

这也不起作用:
docker run -d -p 8787:8787 -v //10.1.11.###/projects:/home/ rstudio / foobar rocker / rstudio

有什么建议吗?

我相对

推荐答案

我知道这是比较老的-但为了他人-这通常对我有用。使用-我们使用Windows文件服务器,因此我们使用cifs-utils来映射驱动器。我假设以下说明也可以应用于nfs或其他任何东西。

I know this is relatively old - but for the sake of others - here is what usually works for me. for use - we use a windows file-server so we use cifs-utils in order to map the drive. I assume that below instructions can be applied to nfs or anything else as well.

首先-需要在特权模式下运行容器,以便可以在其中装载远程文件夹容器(可能不需要-dns 标志)

docker run --dns< company dns ip> -p 8000:80 --privileged -it<容器名称和标签>

first - need to run the container in privileged mode so that you can mount remote folders inside of the container (--dns flag might not be required)
docker run --dns <company dns ip> -p 8000:80 --privileged -it <container name and tag>

现在,(假定centos带有cifs并植根于容器)-跳入容器并运行:

now, (assuming centos with cifs and being root in the container) - hop into the container and run:

如果尚未安装cifs-utils,请安装

yum -y install cifs-utils

创建要映射的本地目录

mkdir / mnt / my- Mounted-folder

使用用户名和凭据

echo username =<用户名可访问共享驱动器> > 〜/ .smbcredentials

echo password =< password> > 〜/ .smbcredentials

映射远程文件夹

安装<远程共享文件夹> <我本地安装的文件夹> -t cifs -o iocharset = utf8,凭据= / root / .smbcredentials,file_mode = 0777,dir_mode = 0777,uid = 1000,gid = 1000,cache = strict

现在您应该可以访问

希望这会有所帮助。

这篇关于如何在Windows版Docker(Windows 10)中挂载网络卷的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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