配置vagrant机器:Dockerfile(Dockerfile)必须在构建上下文中

时间:2015-08-27 23:58:34

标签: docker vagrant

我试图在流浪者的vm中动态建造一个码头工人集装箱。要构建容器的Vagrantfile和Dockerfile位于同一目录中,并且在VM上,它们都可以在预期的默认同步文件夹/ vagrant中找到。不幸的是,构建容器不起作用 - 我得到import pandas as pd items = {'neuro': 'N', 'cardio': 'C', 'cancer': 'L', 'anesthetics': 'N01', 'analgesics': 'N02', 'antiepileptics': 'N03', 'anti-parkinson drugs': 'N04', 'psycholeptics': 'N05', 'psychoanaleptics': 'N06', 'addiction_and_other_neuro': 'N07', 'Adrugs': 'A', 'Mdrugs': 'M', 'Vdrugs': 'V', 'all_drugs': ''} # Create data containers using dictionary comprehension. dfs = {item: pd.DataFrame() for item in items.keys()} monthly_summaries = {item: list() for item in items.keys()} # Perform monthly groupby operations. for year in xrange(2005, 2013): for month in xrange(1, 13): if year == 2005 and month < 7: continue filename = 'PATH/STUB_' + str(year) + '_mon'+ str(month) +'.txt' monthly = pd.read_table(filename,usecols=[0,3,32]) monthly['year'] = year monthly['month'] = month dfs = {name: monthly[(monthly.ATC.str.startswith('{0}'.format(code))) & (~(monthly.TKOST.isnull()))] for name, code in items.iteritems()} [monthly_summaries[name].append(dfs[name].groupby(['LopNr','year','month']).sum() .astype(int, copy=False)) for name in items.keys()] # Now concatenate all of the monthly summaries into separate DataFrames. dfs = {name: pd.concat([monthly_summaries[name]], ignore_axis=True) for name in items.keys()} # Now regroup the aggregate monthly summaries. monthly_summaries = {name: dfs[name].reset_index().groupby(['LopNr','year','month']).sum() for name in items.keys()} # Finally, save the aggregated results to files. [monthly_summaries[name].to_csv('PATH/monthly_{0}_costs.csv'.format(name)) for name in items()] 。在这种情况下,正确的构建上下文是什么?我是否需要将Dockerfile复制到某个地方才能使用它?

Vagrantfile:

The Dockerfile (Dockerfile) must be within the build context

输出:

Vagrant.configure("2") do |config|
    config.vm.provider "virtualbox"
    config.vm.box = "ubuntu/trusty64"
    config.vm.hostname = "ubuntu"

    config.vm.network :private_network, ip: "192.168.0.200"
    config.ssh.forward_agent = true
    config.ssh.insert_key = false

    config.vm.provision "docker" do |d|
        d.build_image "/vagrant/Dockerfile"
        d.build_args = ['--tag "container"']
        d.run "container"
    end
end

1 个答案:

答案 0 :(得分:1)

d.build_image "/vagrant/Dockerfile"选项应该引用Dockerfile的包含文件夹,在这种情况下:

Vagrant.configure("2") do |config|
    config.vm.provider "virtualbox"
    config.vm.box = "ubuntu/trusty64"
    config.vm.hostname = "ubuntu"

    config.vm.network :private_network, ip: "192.168.0.200"
    config.ssh.forward_agent = true
    config.ssh.insert_key = false

    config.vm.provision "docker" do |d|
        d.build_image "/vagrant"
        d.build_args = ['--tag "container"']
        d.run "container"
    end
end