如何从Vagrant提供Docker文件 [英] How do I provision a Dockerfile from Vagrant

查看:133
本文介绍了如何从Vagrant提供Docker文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何通过外部Dockerfile启动Docker的配置?
我的Vagrantfile目前看起来像这样。

How can I start the provisioning of Docker via an external Dockerfile? My Vagrantfile looks like this at the moment

Vagrant.configure("2") do |config|
  config.vm.box = "precise64"
  config.vm.define :server_infrastructure do |t|
  end

  config.vm.provision "docker" do |d|
    d.pull_images "ubuntu"
    #how does the below work?
    #d.build "new-container-name" "local-docker-file-name"
  end
end

非常感谢您的帮助

推荐答案

Docker供应商构建图像的一个选项已添加到 V1.6.0 。从 Vagrant网站下载最新版本。

An option for the Docker provisioner to build images was added in v1.6.0. Download the latest version from the Vagrant website.

一旦你完成了那就把Dockerfile放在你的Vagrantfile旁。将其添加到您的Vagrantfile中:

Once you've done that, put a Dockerfile next to your Vagrantfile. Add this to your Vagrantfile:

config.vm.provision "docker" do |d|
  d.build_image "/vagrant", args: "-t my-name/my-new-image"
  d.run "my-name/my-new-image"
end

现在,您的Docker图像将使用 vagrant up

Now your Docker image will be built and run with vagrant up.

这篇关于如何从Vagrant提供Docker文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆