像docker一样挂载文件映射目录到虚拟机VM内部进行开发详细实现步骤及介绍

容器共享目录开发示例:

docker run --name manage -itd -v `pwd`:/app -p 8090:8080 golang:1.16
docker exec -it manage bash
export GO111MODULE=on && export GOPROXY=https://goproxy.io && CGO_ENABLED=0 GOOS=linux go mod tidy

虚拟机共享目录开发示例:

前置条件:利用VMware虚拟机软件安装一个Linux系统,这里以CentOS7为例。

1、点击外部菜单"虚拟机"》“安装 VMware Tools”》确定挂在对应CD/ROM设备;

2、在虚拟机系统里面,查看对应的设备:lsblk

3、在虚拟机系统里面,挂载对应的设备:mkdir /root/tool && mount /dev/sr0 /root/tool

4、在虚拟机系统里面,解压对应的文件:cd /root/tool/ && tar -C /root/ -zxvf VMwareTools-10.3.21-14772444.tar.gz

5、在虚拟机系统里面,安装程序依赖环境:yum -y install kernel-headers kernel-devel kernel gcc gcc-c++ perl make

6、在虚拟机系统里面,安装对应的程序:cd /root/vmware-tools-distrib/ && ./vmware-install.pl

安装过程如下:

Do you still want to proceed with this installation? [no] yes

In which directory do you want to install the binary files?
[/usr/bin] 回车

What is the directory that contains the init directories (rc0.d/ to rc6.d/)?
[/etc/rc.d] 回车

What is the directory that contains the init scripts?
[/etc/rc.d/init.d] 回车

In which directory do you want to install the daemon files?
[/usr/sbin] 回车

In which directory do you want to install the library files?
[/usr/lib/vmware-tools] 回车

The path “/usr/lib/vmware-tools” does not exist currently. This program is
going to create it, including needed parent directories. Is this what you want?
[yes] 回车

In which directory do you want to install the common agent library files?
[/usr/lib] 回车

In which directory do you want to install the common agent transient files?
[/var/lib] 回车

In which directory do you want to install the documentation files?
[/usr/share/doc/vmware-tools] 回车

The path “/usr/share/doc/vmware-tools” does not exist currently. This program
is going to create it, including needed parent directories. Is this what you
want? [yes] 回车

Before running VMware Tools for the first time, you need to configure it by
invoking the following command: “/usr/bin/vmware-config-tools.pl”. Do you want
this program to invoke the command for you now? [yes] 回车

The VMware Host-Guest Filesystem allows for shared folders between the host OS
and the guest OS in a Fusion or Workstation virtual environment. Do you wish
to enable this feature? [yes] 回车

The path “/bin/gcc” appears to be a valid path to the gcc binary.
Would you like to change it? [no] 回车

The path “” is not a valid path to the 3.10.0-862.el7.x86_64 kernel headers.
Would you like to change it? [yes] no

  • This program could not find a valid path to the kernel headers of the running
    kernel. Please ensure that the header files for the running kernel are
    installed on this sytem.
    [ Press Enter key to continue ] 回车

If you wish to have the shared folders feature, you can install the driver by
running vmware-config-tools.pl again after making sure that gcc, binutils, make
and the kernel sources for your running kernel are installed on your machine.
These packages are available on your distribution’s installation CD.
[ Press Enter key to continue ] 回车

The vmblock enables dragging or copying files between host and guest in a
Fusion or Workstation virtual environment. Do you wish to enable this feature?
[yes] 回车

Do you want to enable Guest Authentication (vgauth)? Enabling vgauth is needed
if you want to enable Common Agent (caf). [yes] 回车

Do you want to enable Common Agent (caf)? [no] 回车

关闭虚拟机系统。

7、点击"虚拟机"》“设置”》“共享”,点击"+“添加对应的文件夹路径,并勾选"启用共享文件夹”;

8、在虚拟机系统里面“/mnt”目录下,查看共享文件夹:

共享目录完成,进行正常的开发。

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

代码讲故事

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值