configurationstream浪机:Dockerfile(Dockerfile)必须位于构build上下文中

我试图在一个stream浪汉虚拟主机上搭build一个docker集装箱。 容器的Vagrantfile和Dockerfile将被build立在相同的目录中,并且在虚拟机上,它们都在预期的默认同步文件夹/ vagrant中被find。 不幸的是,构build容器不起作用 – 我得到The Dockerfile (Dockerfile) must be within the build context 。 在这种情况下什么是适当的构build上下文? 我是否需要将Dockerfile复制到某个地方才能使用它?

Vagrantfile:

 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 

输出:

 $ vagrant provision ==> default: Running provisioner: docker... ==> default: Building Docker images... ==> default: -- Path: /vagrant/Dockerfile ==> default: stdin: is not a tty ==> default: The Dockerfile (Dockerfile) must be within the build context (/vagrant/Dockerfile) The following SSH command responded with a non-zero exit status. Vagrant assumes that this means the command failed! docker build /vagrant/Dockerfile Stdout from the command: Stderr from the command: stdin: is not a tty The Dockerfile (Dockerfile) must be within the build context (/vagrant/Dockerfile) 

在这种情况下, d.build_image "/vagrant/Dockerfile"选项应该引用d.build_image "/vagrant/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