简体   繁体   English

无法在Vagrant上使用第2版docker-compose文件

[英]Cannot use Version 2 docker-compose files on Vagrant

I am having a baffling problem. 我有一个莫名其妙的问题。

I cannot use docker-compose version 2 files on a vagrant guest. 我不能在流浪汉中使用docker-compose版本2文件。 (If it matters the host is 15.10 ubuntu). (如果很重要,主机为15.10 ubuntu)。

I am getting the following error: The Docker Engine is less than the minimum required by Compose. 我收到以下错误: Docker引擎小于Compose要求的最小值。 Your current project requires a Docker Engine of version 1.10.0 or greater 您当前的项目需要1.10.0或更高版本的Docker引擎

The Vagrantfile I am using is the following: 我正在使用的Vagrantfile是以下内容:

# -*- mode: ruby -*-
# vi: set ft=ruby :
# SET THE IP ADDRESS AND BRIDGE SELECTION TO MATCH YOUR NETWORK
#

unless Vagrant.has_plugin?("vagrant-docker-compose")
  system("vagrant plugin install vagrant-docker-compose")
  system("vagrant plugin install vagrant-vbguest")
  puts "Dependencies installed, please try the command again."
  exit
end
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|

  config.vm.synced_folder "./web", "/var/www", create: true, group: "www-data", owner: "www-data"
  config.vm.provision :shell, path: "./provision/setup.sh"
  config.vm.provision "shell", inline:
     "ps aux | grep 'sshd:' | awk '{print $2}' | xargs kill"
  config.ssh.shell = "bash -c 'BASH_ENV=/etc/profile exec bash'"
  # Assign a name to your host VM
  config.vm.hostname = "docker"
  # Use the phusion ubuntu box for our host VM
  config.vm.box = "phusion/ubuntu-14.04-amd64"
  # Run scripts to place web, docker and repo files
  config.vm.provision :shell, path: "./provision/public_gitrepos_to_vagrant_dir.sh"

  # Forward port 8080 to host machine
  config.vm.network "forwarded_port", guest: 80, host: 8081
  config.vm.network "forwarded_port", guest: 443, host: 8082
  config.vm.network "forwarded_port", guest: 8000, host:8000
  #network
  config.vm.network "public_network", ip: "192.168.0.60"

  # Sync your project in the /vagrant directory inside the VM
  config.vm.synced_folder ".", "/vagrant"

  config.vm.provision :docker
  config.vm.provision :docker_compose, yml: "/vagrant/docker/docker-compose.yml", rebuild: true, run: "always"
  config.vm.provision :shell, path: "./provision/dockerstart.sh"
  end

Docker-compose works fine with V1 version YAML files, but gives me the warning and fails with V2. Docker-compose可以在V1版本的YAML文件中正常工作,但是会给我警告,并在V2中失败。 V2 works fine on the host machine, it is only on Vagrant that I have this issue. V2在主机上工作正常,只有在Vagrant上才出现此问题。

How can I get a V2 docker-compose files to work with Vagrant? 如何获得V2 docker-compose文件与Vagrant一​​起使用? Am I just missing something or it is a bigger issue? 我只是错过了什么还是一个更大的问题?

Problem 问题

Old Docker Version 旧的Docker版本

The Docker installation running on that Vagrant VM is old and out of date. 在该Vagrant VM上运行的Docker安装既旧又过时。 Per the error you're seeing, it is older than the minimum 1.10.0 required for v2 of Docker Compose. 根据您看到的错误,该错误早于Docker Compose v2所需的最低1.10.0

I am getting the following error: The Docker Engine is less than the minimum required by Compose. 我收到以下错误:Docker引擎小于Compose要求的最小值。 Your current project requires a Docker Engine of version 1.10.0 or greater 您当前的项目需要1.10.0或更高版本的Docker引擎

Here is the source of the boxes you downloaded: 这是您下载的盒子的来源:

https://oss-binaries.phusionpassenger.com/vagrant/boxes/ https://oss-binaries.phusionpassenger.com/vagrant/boxes/

Right off the Phusion page there is a link to the above via "Prebuilt boxes". Phusion页面的右边,有一个通过“预建盒子”链接到上面的链接。 You can see from the dates they were last updated in May 2014 , which is forever in Docker-time. 您可以从上次更新日期为20145月开始 ,这在Docker时间是永远的。

Per the Docker Compose documentation: https://docs.docker.com/compose/compose-file/#/version-2 根据Docker Compose文档: https : //docs.docker.com/compose/compose-file/#/version-2

Version 2 files are supported by Compose 1.6.0+ and require a Docker Engine of version 1.10.0+. Compose 1.6.0+支持版本2文件,并且需要1.10.0+版本的Docker Engine。

Solutions 解决方案

Native Docker on Ubuntu Host Ubuntu主机上的本机Docker

As you are running Ubuntu on your host, you can run native Docker directly. 在主机上运行Ubuntu时,可以直接运行本机Docker。 It will be faster and much simpler to work with than in a VM. 与在VM中相比,使用它会更快,更简单。

Install on Ubuntu: https://docs.docker.com/engine/installation/linux/ubuntulinux/ 在Ubuntu上安装: https : //docs.docker.com/engine/installation/linux/ubuntulinux/

Vagrant Docker Provider 流浪的Docker提供商

If your requirements are to run in Vagrant, you can use manage it using Vagrant's built-in Docker provider, with no VM/VBox: https://www.vagrantup.com/docs/docker/boxes.html 如果您的要求是在Vagrant中运行,则可以使用不带VM / VBox的Vagrant内置Docker提供程序进行管理: https : //www.vagrantup.com/docs/docker/boxes.html

The Docker provider does not require a Vagrant box. Docker提供程序不需要Vagrant框。 The config.vm.box setting is completely optional. config.vm.box设置是完全可选的。

Note: You will need Docker installed on your Ubuntu host for this. 注意:为此,您需要在Ubuntu主机上安装Docker。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM