当前位置:首页 » 《随便一记》 » 正文

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

3 人参与  2022年07月21日 13:13  分类 : 《随便一记》  评论

点击全文阅读


容器共享目录开发示例:

docker run --name manage -itd -v `pwd`:/app -p 8090:8080 golang:1.16docker exec -it manage bashexport 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”目录下,查看共享文件夹:

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


点击全文阅读


本文链接:http://m.zhangshiyu.com/post/43622.html

<< 上一篇 下一篇 >>

  • 评论(0)
  • 赞助本站

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

关于我们 | 我要投稿 | 免责申明

Copyright © 2020-2022 ZhangShiYu.com Rights Reserved.豫ICP备2022013469号-1