如何在Mac上从容器映射共享文件夹? [英] How can I map a shared folder from my container on Mac?

查看:1087
本文介绍了如何在Mac上从容器映射共享文件夹?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在通过Samba共享的Docker容器内部有一个文件夹.我可以在Windows上映射此文件夹,而不会像运行以下命令那样出现问题:

I have a folder insider a Docker container that is shared through Samba. I can map this folder on Windows without problem running something like:

net use z: \\vm_ip\folder

在上述情况下,z:是我使用共享文件夹中的内容创建的驱动器.

In the case above, z: is the drive that I created with the content from the shared folder.

如何在Mac上映射相同的文件夹?

How could I map that same folder on Mac?

推荐答案

步骤1-使用Samba共享文件夹

要做的第一件事是让包含要共享的文件(项目,源代码,设置等)的文件夹对于MacOS可见.

The first thing that you need to do is let the folder that contains the files (project, source codes, settings, etc) that you want to share, visible for MacOS.

为此,您需要使用Samba共享Docker Container上的文件夹.我不会在这里描述如何执行此操作,因为Internet上有很多资源.

To do that, you'll need to share the folder on Docker Container using Samba. I won't describe how to do this here because there are a lot of resources on Internet.

第2步-重定向Kitematic上的Samba端口

Kitematic是一个平台,可帮助您在Docker上配置容器和其他设置.可以在这里下载: https://www.docker.com/products/docker-toolbox .您不需要Kitematic来创建重定向Samba端口的规则,但是,您不会花2分钟的时间(而是尝试在CLI中发现如何进行操作).

Kitematic is a platform that helps you to configure the container and other settings on Docker. It can be downloaded here: https://www.docker.com/products/docker-toolbox. You DON'T need Kitematic to create the rules to redirect the Samba ports, however, you won't spend 2 minutes for that (instead trying to discover how to do that in the CLI).

在MacOS上安装了Kitematic:

Having Kitematic installed on MacOS:

开始Kitematic; 选择包含您使用Samba共享的文件夹的容器(标题为容器"的左侧面板); Docker上的Panel图像

Start Kitematic; Select the container (panel on left with the title Container) that contains the folder that you shared using Samba; Image of Panel on Docker

单击设置"选项卡,然后选择下面的名为主机名/端口"的选项卡 Docker上的设置"面板的图像

Click on the Settings tab and then the select the tab below called Hostname/Ports Image of Settings panel on Docker

现在,我们添加端口137、138、139和445,并将其重定向到本地主机上的同一端口.

Now, we add the ports 137, 138, 139 and 445 and redirects it to the same port on localhost.

第3步-在MacOS上安装Samba共享文件夹

在MacOS上编辑文件所需的最后一件事就是在MacOS上映射在Samba上共享的文件夹(在Docker容器内部).要映射它,请打开终端并运行以下命令:

The last thing that is needed to edit your files on MacOS,is just map on MacOS the folder that is shared on Samba (inside the Docker container). To map that, open the terminal and run the following command:

$ mount_smbfs //guest@localhost:/SharedFolderOnSamba source/

我们正在使用mount_smbfs方法,告诉我们将使用用户guest连接到SharedFolderOnSamba文件夹中的@localhost,然后将其映射到Source/文件夹中(创建新的Drive)在MacOS终端会话的currenct目录中.

What we're doing is using the method mount_smbfs, telling that we'll connect to the @localhost in the folder SharedFolderOnSamba using the user guest and then, we'll map (create a new Drive) in the source/ folder on the currenct directory of you terminal session on MacOS.

所以,请注意:

您可以使用任何其他用户来代替guest; 您必须具有源/文件夹或定义将要使用的另一个文件夹; 必须将SharedFolderOnSamba更改为使用Samba共享的文件夹的名称.要确认该文件夹的名称,请转至/etc/samba/并打开smb.conf并按您共享的文件夹进行搜索.

You can use any other user to use instead guest; You must have a source/ folder or define another folder that will be used; The SharedFolderOnSamba must be change to the name of the folder that you've shared using Samba. To confirm the name of the folder, go to /etc/samba/ and open smb.conf and search by the folder that you've shared.

这篇关于如何在Mac上从容器映射共享文件夹?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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