2013-12-20 4 views
0

Я начал новый проект Vagrant, чтобы изучить Django. VM работает хорошо, и все работает, но я не знаю, как получить доступ к файлам внутри моей виртуальной машины для редактирования с помощью текстового редактора, такого как Sublime.Как получить доступ к домашнему каталогу Vagrant VM?

На VM cd/vagrant попадает в папку «Мой рабочий стол». Тем не менее, я не могу найти, где хранятся папки моего домашнего каталога VM на моем хосте.

/бродяга

-Vagrantfile 
-cookbooks 
--apache2 
--apt 
--build-essential 
--git 
--vim 

~ $

-build 
-django_project 
--django_project 
--manage.py 
-postinstall.sh 

ответ

1

домашний каталог на ваших гостей не является общим, вам необходимо установить его вручную в Vagrantfile.

Edit:

Просмотр этого файла и раскомментируйте строки (читай комментарий выше линии, чтобы получить более подробную информацию):

# config.vm.synced_folder "../data", "/vagrant_data" 
+0

Как бы это сделать в Vagrantfile? – Contechtions

+0

@Contechtions Я обновил свой ответ. – mariodev

0

Вы можете совместно любую папку, которую вы хотите. Вам нужно только указать в файл Vagrantfile, какую папку вы хотите разделить с догадкой

В этом случае я создаю папку с данными , потому что по умолчанию этот один не существует. Это моя структура проекта. Папка данных и Vagrantfile находятся на одном уровне каталогов.

. 
├── attributes 
├── Berksfile 
├── Berksfile.lock 
├── chefignore 
├── **data** 
│   └── **hello** 
├── definitions 
├── files 
│   └── default 
├── Gemfile 
├── Gemfile.lock 
├── libraries 
├── LICENSE 
├── metadata.rb 
├── providers 
├── README.md 
├── recipes 
│   ├── default.rb 
│   └── gem_sources.rb 
├── resources 
├── templates 
│   └── default 
├── test 
│   └── integration 
│    └── default 
├── Thorfile 
└── **Vagrantfile** 

Это конфигурация файла Vagrantfile.

# -*- mode: ruby -*- 
# vi: set ft=ruby : 

Vagrant.configure("2") do |config| 
    # All Vagrant configuration is done here. The most common configuration 
    # options are documented and commented below. For a complete reference, 
    # please see the online documentation at vagrantup.com. 

    config.vm.hostname = "ubuntu" 

    # Every Vagrant virtual environment requires a box to build off of. 
    config.vm.box = "ubuntu-12.04" 


    # Share an additional folder to the guest VM. The first argument is 
    # the path on the host to the actual folder. The second argument is 
    # the path on the guest to mount the folder. And the optional third 
    # argument is a set of non-required options. 
    config.vm.synced_folder "data", "/vagrant_data" 
end 

Все в папке с данными доступно в папке vagrant_data в предположении. Вы можете увидеть файл приветствия.

[email protected]:~/Desktop/stack$ vagrant ssh 
Welcome to Ubuntu 12.04 LTS (GNU/Linux 3.2.0-23-generic-pae i686) 

* Documentation: https://help.ubuntu.com/ 
Welcome to your Vagrant-built virtual machine. 
Last login: Sun Jan 19 13:20:49 2014 from 10.0.2.2 
[email protected]:~$ cd /vagrant_data/ 
[email protected]:/vagrant_data$ ls 
hello 
[email protected]:/vagrant_data$ 

Надеюсь, это поможет вам. Извините за мой английский

Смежные вопросы