容器共享目录开发示例:
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
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”目录下,查看共享文件夹:
共享目录完成,进行正常的开发。