Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/docker/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Docker 如何通过Vagrantfile设置环境变量和/etc/hosts? 流浪版_Docker_Vagrant_Docker Compose_Vagrantfile_Vagrant Plugin - Fatal编程技术网

Docker 如何通过Vagrantfile设置环境变量和/etc/hosts? 流浪版

Docker 如何通过Vagrantfile设置环境变量和/etc/hosts? 流浪版,docker,vagrant,docker-compose,vagrantfile,vagrant-plugin,Docker,Vagrant,Docker Compose,Vagrantfile,Vagrant Plugin,流浪汉1.9.7 主机操作系统 Darwin bogon 16.6.0达尔文内核版本16.6.0:Fri Apr 14 16:21:16 PDT 2017;根目录:xnu-3789.60.24~6/RELEASE_X86_64 X86_64 来宾操作系统 发布者ID:Ubuntu 说明:Ubuntu 16.04.2 LTS 发行日期:16.04 代号:xenial 问题: 如何通过Vagrantfile设置环境变量和/etc/hosts 在docker composer中,我可以设置环境和额外主

流浪汉1.9.7

主机操作系统 Darwin bogon 16.6.0达尔文内核版本16.6.0:Fri Apr 14 16:21:16 PDT 2017;根目录:xnu-3789.60.24~6/RELEASE_X86_64 X86_64

来宾操作系统 发布者ID:Ubuntu

说明:Ubuntu 16.04.2 LTS

发行日期:16.04

代号:xenial

问题: 如何通过Vagrantfile设置环境变量和/etc/hosts

在docker composer中,我可以设置环境额外主机


在vagrant中,如何做到这一点?

vagrant在与虚拟箱(而不是容器)一起使用时管理虚拟机

如果要定义环境变量或特定文件,最好使用

您可以直接使用推送文件,也可以使用shell脚本编辑文件并添加一些行

将提供一个简单的shell脚本来添加环境变量

  config.vm.provision "shell", privileged: false, inline: <<-SHELL
    echo "export VARIABLE=VALUE" > /home/vagrant/.profile
  SHELL
config.vm.provision“shell”,特权:false,内联: