简体   繁体   English

Ubuntu + Vagrant + docker无需使用Virtualbox即可撰写

[英]Ubuntu + Vagrant + docker compose without using Virtualbox

Hy, HY,

I have been using Vagrant + Docker on Windows PC for a while, with Virtualbox. 我已经使用Virtualbox在Windows PC上使用Vagrant + Docker已有一段时间了。 Since few weeks I have turned my mind toward Ubuntu 16.04 LTS, and started to migrate my Vagrant stuff on my new hardware. 几个星期以来,我开始转向Ubuntu 16.04 LTS,并开始在新硬件上迁移Vagrant。

Some of Vagrants were using docker-compose on my old PC. 一些流浪者在我的旧PC上使用了docker-compose。 Now, on Ubuntu, I want to use Docker and Docker-compose directly, without Virtualbox. 现在,在Ubuntu上,我想直接使用Docker和Docker-compose,而不使用Virtualbox。 Certainly I could forget Vagrant and work directly with Docker compose, but I prefer to have every environnement monitored via Vagrant, to stay homogeneous. 当然,我会忘记Vagrant并直接与Docker compose一起工作,但是我更喜欢通过Vagrant监视每个环境,以保持一致。

I can't find information on how to use "docker compose" in this new context (Ubuntu 16 + Vagrant : prodiver = Docker and Provisionner = Docker compose). 我在新的上下文中找不到有关如何使用“ docker compose”的信息(Ubuntu 16 + Vagrant:prodiver = Docker和Provisionner = Docker compose)。

Some link display the usage of "vagrant-docker-compose" plugin, but it dosen't work for me. 一些链接显示了“ vagrant-docker-compose”插件的用法,但对我不起作用。 I don't realy hunderstand why, but I think it's logical as I am using Docker directly on my machine, whitout VBox, and every example seems stating that your are using VBox. 我并不真正理解为什么,但是我认为这是合乎逻辑的,因为我直接在我的机器上使用Docker,使用了VBox,每个示例似乎都表明您正在使用VBox。

Am I mistaking about the right way to solve my issue ? 我是否对解决问题的正确方法感到误解?

Now my Vagrantfile looks like this (I tried other stuff...without any more success..): 现在我的Vagrantfile看起来像这样(我尝试了其他东西……没有更多的成功。):

Vagrant.configure(2) do |config|

  config.vm.provider "docker" do |docker|

    docker.image="ubuntu:16.04"
    docker.compose=true

  end

    config.vm.provision :docker

    config.vm.provision :docker_compose, rebuild: true, yml: "/direct/docker-compose.yml", run: "always"

end

But the docker-compose.yml isn't loaded....andd Vagrant says 但是docker-compose.yml没有加载.... and Vagrant说

"he container started either never left the "stopped" state or very quickly reverted to the "stopped" state. ..." “他的容器开始要么从未离开“停止”状态,要么很快恢复到“停止”状态……”

In fact : I don't understand where I must indicate the path to my docker-compose.yml file.... 实际上:我不知道该在哪里指示docker-compose.yml文件的路径。

Could you help me ? 你可以帮帮我吗 ? Do you have a clue, or a link to a tuto ? 您是否有线索或与tuto的链接? Can you enlight my mind saoul about the right way to solve it .... :[ 您能启迪我对解决问题的正确方法的想法吗....:[

Regards :) 问候 :)

First, just to clarify that even though you are on Ubuntu and running Linux natively, the docker and docker_compose provisioners (I'm assuming from https://github.com/leighmcculloch/vagrant-docker-compose ) will still run inside the Vagrant VM. 首先,我只想澄清,即使你是Ubuntu和本地运行Linux的dockerdocker_compose供应方(我是从假设https://github.com/leighmcculloch/vagrant-docker-compose )仍将在流浪中运行VM。 It is not using the native Docker on your host. 它没有在主机上使用本机Docker。

Next, the docker-compose.yml file that it is referencing is from inside the Vagrant machine. 接下来,它所引用docker-compose.yml文件来自Vagrant机器内部。 Usually, this is the shared folder for the project at /vagrant . 通常,这是项目的共享文件夹/vagrant In this case, assuming the docker-compose.yml file lives next to the Vagrantfile , the yml path should be /vagrant/docker-compose.yml . 在这种情况下,假设docker-compose.yml文件位于Vagrantfile ,则yml路径应为/vagrant/docker-compose.yml

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

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