如果将Vagrant文​​件配置为forward_port不起作用怎么办;有其他选择吗?

时间:2018-12-12 03:03:45

标签: vagrant jupyter-notebook

因此,我花了几天的时间来寻找解决办法,以使Jupyter笔记本电脑使用流浪汉在VM中启动。

config.vm.network "forwarded_port", guest: 80, host: 8080

似乎是最常见的解决方案;但是我的流浪汉文件与其他建议更改的流浪汉文件不同,我找不到合适的参考,此刻我非常困惑。

Reference to DigitalOcean Guide

Vagrant Refused to connect to browser

这是我目前流浪的文件;所以我不确定如何设置配置以允许jupyter运行;因为它被拒绝访问

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

require 'json'
require 'yaml'

VAGRANTFILE_API_VERSION ||= "2"
confDir = $confDir ||= File.expand_path(File.dirname(__FILE__))

homesteadYamlPath = confDir + "/Homestead.yaml"
homesteadJsonPath = confDir + "/Homestead.json"
afterScriptPath = confDir + "/after.sh"
customizationScriptPath = confDir + "/user-customizations.sh"
aliasesPath = confDir + "/aliases"

require File.expand_path(File.dirname(__FILE__) + '/scripts/homestead.rb')

Vagrant.require_version '>= 2.1.0'

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
    if File.exist? aliasesPath then
        config.vm.provision "file", source: aliasesPath, destination: "/tmp/bash_aliases"
        config.vm.provision "shell" do |s|
            s.inline = "awk '{ sub(\"\r$\", \"\"); print }' /tmp/bash_aliases > /home/vagrant/.bash_aliases"
        end
    end

    if File.exist? homesteadYamlPath then
        settings = YAML::load(File.read(homesteadYamlPath))
    elsif File.exist? homesteadJsonPath then
        settings = JSON::parse(File.read(homesteadJsonPath))
    else
        abort "Homestead settings file not found in #{confDir}"
    end

    Homestead.configure(config, settings)

    if File.exist? afterScriptPath then
        config.vm.provision "shell", path: afterScriptPath, privileged: false, keep_color: true
    end

    if File.exist? customizationScriptPath then
        config.vm.provision "shell", path: customizationScriptPath, privileged: false, keep_color: true
    end

    if Vagrant.has_plugin?('vagrant-hostsupdater')
        config.hostsupdater.aliases = settings['sites'].map { |site| site['map'] }
    elsif Vagrant.has_plugin?('vagrant-hostmanager')
        config.hostmanager.enabled = true
        config.hostmanager.manage_host = true
        config.hostmanager.aliases = settings['sites'].map { |site| site['map'] }
    end
end

1 个答案:

答案 0 :(得分:0)

没关系;我设法通过腻子的工作终于找到了解决方案。

按照"Kratens Answer"

这对于帮助有类似问题的任何人也是很好的参考;

Getting Started with Vagrant on Windows

希望有帮助!