简体   繁体   中英

Homestead/Vagrant - no mounted folders

I'm trying to get a Homestead VM setup for my laravel project. I have followed the instructions here exactly . The only difference is the folder I put the Homestead directory in; I simply put it in C:/.

Otherwise I have set up the Vagrant box, cloned and inited Homestead, and set up the homestead.yaml file exactly as instructed. I then start the VM with vagrant ssh . When I use ls to view the folders in the mapped directory - nothing.

This is my homestead.yaml file:

p: "192.168.10.10"
memory: 2048
cpus: 1
provider: virtualbox

authorize: ~/ssh/id_rsa.pub

keys:
    - ~/ssh/id_rsa.pub

folders:
    - map: c:/laravelprojects
      to: /home/vagrant/Code

sites:
    - map: app.dev
      to: /home/vagrant/Code/username/public

databases:
    - homestead

When I run vagrant up , this is the output:

Bringing machine 'default' up with 'virtualbox' provider...
==> default: Importing base box 'laravel/homestead'...
==> default: Matching MAC address for NAT networking...
==> default: Checking if box 'laravel/homestead' is up to date...
==> default: Setting the name of the VM: homestead-7
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
    default: Adapter 1: nat
    default: Adapter 2: hostonly
==> default: Forwarding ports...
    default: 80 (guest) => 8000 (host) (adapter 1)
    default: 443 (guest) => 44300 (host) (adapter 1)
    default: 3306 (guest) => 33060 (host) (adapter 1)
    default: 5432 (guest) => 54320 (host) (adapter 1)
    default: 22 (guest) => 2222 (host) (adapter 1)
==> default: Running 'pre-boot' VM customizations...
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
    default: SSH address: 127.0.0.1:2222
    default: SSH username: vagrant
    default: SSH auth method: private key
    default: Warning: Remote connection disconnect. Retrying...
    default:
    default: Vagrant insecure key detected. Vagrant will automatically replace
    default: this with a newly generated keypair for better security.
    default:
    default: Inserting generated public key within guest...
    default: Removing insecure key from the guest if it's present...
    default: Key inserted! Disconnecting and reconnecting using new SSH key...
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...
==> default: Setting hostname...
==> default: Configuring and enabling network interfaces...
==> default: Mounting shared folders...
    default: /vagrant => C:/Homestead

As you can see, the last two lines seem to be mounted the wrong folder, ie the folder the Vagrant machine is being started from. However, checking in Virtualbox shows that both this and the folder specified in the .yaml file are set and mapped.

What gives?

/vagrant is mounted by default from the project where Vagrantfile is.

I am not sure if it can be disable from homestead.yaml file directly, but you can edit the Vagrantfile and add

config.vm.synced_folder ".", "/vagrant", disabled: true

so it will not create a /vagrant directory in the VM and VirtualBox will show only your folder specified from the yaml.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM