Coder Social home page Coder Social logo

vagrant-docker-compose's Introduction

Vagrant Provisioner: Docker Compose

CircleCI

A Vagrant provisioner for Docker Compose. Installs Docker Compose and can also bring up the containers defined by a docker-compose.yml.

Install

vagrant plugin install vagrant-docker-compose

Usage

To install docker and docker-compose

Vagrant.configure("2") do |config|
  config.vm.box = "ubuntu/bionic64"

  config.vm.provision :docker
  config.vm.provision :docker_compose
end

To install and run docker-compose on vagrant up

Vagrant.configure("2") do |config|
  config.vm.box = "ubuntu/bionic64"

  config.vm.provision :docker
  config.vm.provision :docker_compose, yml: "/vagrant/docker-compose.yml", run: "always"
end

Equivalent to running:

docker-compose -f [yml] up -d

To install and run docker-compose, with multiple files, on vagrant up

Vagrant.configure("2") do |config|
  config.vm.box = "ubuntu/bionic64"

  config.vm.provision :docker
  config.vm.provision :docker_compose,
    yml: [
      "/vagrant/docker-compose-base.yml",
      "/vagrant/docker-compose.yml",
      ...
    ],
    run: "always"
end

Equivalent to running:

docker-compose -f [yml-0] -f [yml-1] ... up -d

To install, rebuild and run docker-compose on vagrant up

Vagrant.configure("2") do |config|
  config.vm.box = "ubuntu/bionic64"

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

Equivalent to running:

docker-compose -f [yml] rm --force
docker-compose -f [yml] build
docker-compose -f [yml] up -d

To install, rebuild and run docker-compose with options on vagrant up

Vagrant.configure("2") do |config|
  config.vm.box = "ubuntu/bionic64"

  config.vm.provision :docker
  config.vm.provision :docker_compose, yml: "/vagrant/docker-compose.yml", rebuild: true,
    options: "--x-networking", command_options: { rm: "", up: "-d --timeout 20"}, run: "always"
end

Equivalent to running:

docker-compose --x-networking -f [yml] rm
docker-compose --x-networking -f [yml] build
docker-compose --x-networking -f [yml] up -d --timeout 20

Other configs

  • yml – one or more Compose files (YAML), may be a String for a single file, or Array for multiple.
  • compose_version – defaults to 1.24.1.
  • project_name – compose will default to naming the project vagrant.
  • env – a Hash of environment variables to value that are passed to the docker-compose commands, defaults to an empty Hash.
  • executable_symlink_path – the location the executable will be symlinked to, defaults to /usr/local/bin/docker-compose.
  • executable_install_path – the location the executable will be stored, defaults to <executable_symlink_path>-<compose_version>, i.e. /usr/local/bin/docker-compose-1.5.0.
  • options - a String that's included as the first arguments when calling the docker-compose executable, you can use this to pass arbitrary options/flags to docker-compose, default to nil.
  • command_options - a Hash of docker-compose commands to options, you can use this to pass arbitrary options/flags to the docker-compose commands, defaults to: { rm: "--force", up: "-d" }.

Example

See example in the repository for a full working example.

vagrant-docker-compose's People

Contributors

fabiocorneti avatar harlannorth avatar leighmcculloch avatar slyden avatar waldyrious avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

vagrant-docker-compose's Issues

'docker_compose' provisioner not found on Windows 10

I have VirtualBox, Vagrant and vagrant-docker-compose plugin installed. Running vagrant up causes the following error:

vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
There are errors in the configuration of this machine. Please fix
the following errors and try again:

vm:
* The 'docker_compose' provisioner could not be found.`

I've created the Vagrantfile based on the examples on the README. I've also tried to reinstall the vagrant-docker-compose and reboot the system.

I'm using Windows 10 64 bit, latest VirtualBox, Vagrant and vagrant-docker-compose. As VM box I'm using ubuntu/trusty32 as I have Hyper-V enabled (VirtualBox can't use 64 bit images in that case).

The configuration worked with Windows 7 64 bit and with Vagrant 1.9.6.

Redirect docker-compose logs to vagrant stdout

Haven't been able to figure this one out. When using docker-compose normally, an 'up' command shows the logs of each container running -- would love for the same thing to happen when using vagrant up here.

FYI This can be accomplished by running vagrant ssh -c "docker-compose logs -f", but I think it'd be a nice feature to replicate this like the docker-compose up command does natively.

Installing vagrant-docker-compose plugin fails

I get the following error when running the vagrant plugin install command...

vagrant plugin install vagrant-docker-compose
Installing the 'vagrant-docker-compose' plugin. This can take a few minutes...
Bundler, the underlying system Vagrant uses to install plugins,
reported an error. The error is shown below. These errors are usually
caused by misconfigured plugin installations or transient network
issues. The error from Bundler is:

An error occurred while installing ffi (1.9.10), and Bundler cannot continue.
Make sure that `gem install ffi -v '1.9.10'` succeeds before bundling.

Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.

    /opt/vagrant/embedded/bin/ruby extconf.rb
checking for ffi.h... *** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.  You may
need configuration options.

Provided configuration options:
    --with-opt-dir
    --with-opt-include
    --without-opt-include=${opt-dir}/include
    --with-opt-lib
    --without-opt-lib=${opt-dir}/lib
    --with-make-prog
    --without-make-prog
    --srcdir=.
    --curdir
    --ruby=/opt/vagrant/embedded/bin/ruby
    --with-ffi_c-dir
    --without-ffi_c-dir
    --with-ffi_c-include
    --without-ffi_c-include=${ffi_c-dir}/include
    --with-ffi_c-lib
    --without-ffi_c-lib=${ffi_c-dir}/
    --with-libffi-config
    --without-libffi-config
    --with-pkg-config
    --without-pkg-config
/opt/vagrant/embedded/lib/ruby/2.0.0/mkmf.rb:434:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
    from /opt/vagrant/embedded/lib/ruby/2.0.0/mkmf.rb:549:in `block in try_compile'
    from /opt/vagrant/embedded/lib/ruby/2.0.0/mkmf.rb:502:in `with_werror'
    from /opt/vagrant/embedded/lib/ruby/2.0.0/mkmf.rb:549:in `try_compile'
    from /opt/vagrant/embedded/lib/ruby/2.0.0/mkmf.rb:1044:in `block in have_header'
    from /opt/vagrant/embedded/lib/ruby/2.0.0/mkmf.rb:895:in `block in checking_for'
    from /opt/vagrant/embedded/lib/ruby/2.0.0/mkmf.rb:340:in `block (2 levels) in postpone'
    from /opt/vagrant/embedded/lib/ruby/2.0.0/mkmf.rb:310:in `open'
    from /opt/vagrant/embedded/lib/ruby/2.0.0/mkmf.rb:340:in `block in postpone'
    from /opt/vagrant/embedded/lib/ruby/2.0.0/mkmf.rb:310:in `open'
    from /opt/vagrant/embedded/lib/ruby/2.0.0/mkmf.rb:336:in `postpone'
    from /opt/vagrant/embedded/lib/ruby/2.0.0/mkmf.rb:894:in `checking_for'
    from /opt/vagrant/embedded/lib/ruby/2.0.0/mkmf.rb:1043:in `have_header'
    from extconf.rb:16:in `<main>'


Gem files will remain installed in /Users/Me/.vagrant.d/gems/gems/ffi-1.9.10 for inspection.
Results logged to /Users/Me/.vagrant.d/gems/gems/ffi-1.9.10/ext/ffi_c/gem_make.out

The plugin doesn't appear to be proxy-aware

Hi, I'm trying to use the docker-compose provisioner, but I need to use a proxy. I have configured the proxy settings in the VM using the vagrant proxyconf plugin.

  if Vagrant.has_plugin?("vagrant-proxyconf")
    config.proxy.http     = "http://10.xxx.xxx.xxx:3128/"
    config.proxy.https    = "http://10.xxx.xxx.xxx:3128/"
    config.proxy.no_proxy = "localhost,127.0.0.1"
  end

The problem stems from vagrant-docker-compose-1.5.1/lib/vagrant-docker-compose/installer.rb:47:in 'fetch_file' , resulting in this error:

/opt/vagrant/embedded/lib/ruby/2.4.0/net/protocol.rb:44:in `connect_nonblock': SSL_connect returned=1 errno=0 state=error: certificate verify failed (OpenSSL::SSL::SSLError)
	from /opt/vagrant/embedded/lib/ruby/2.4.0/net/protocol.rb:44:in `ssl_socket_connect'
	from /opt/vagrant/embedded/lib/ruby/2.4.0/net/http.rb:948:in `connect'
	from /opt/vagrant/embedded/lib/ruby/2.4.0/net/http.rb:887:in `do_start'
	from /opt/vagrant/embedded/lib/ruby/2.4.0/net/http.rb:876:in `start'
	from /opt/vagrant/embedded/lib/ruby/2.4.0/net/http.rb:608:in `start'
	from /opt/vagrant/embedded/lib/ruby/2.4.0/net/http.rb:485:in `get_response'

https://stackoverflow.com/questions/15792999/how-to-set-a-proxy-in-rubys-net-http might be a useful reference in making the plugin work with the configured proxy.

vagrant up fails

Due to this issue: hashicorp/vagrant#5697.

Adding

config.vm.provision :shell, inline: "sudo apt-get update"

before the docker provisioner statement fixes it for me.

Here's the detailed error message, for reference:

==> default: Running provisioner: docker...
    default: Installing Docker (latest) onto machine...
The following SSH command responded with a non-zero exit status.
Vagrant assumes that this means the command failed!

lsmod | grep aufs || modprobe aufs || apt-get install -y linux-image-extra-`uname -r`

Stdout from the command:

Reading package lists...
Building dependency tree...
Reading state information...
The following packages were automatically installed and are no longer required:
  libdrm-intel1 libdrm-nouveau2 libdrm-radeon1 libfontenc1 libgl1-mesa-dri
  libgl1-mesa-glx libglapi-mesa libice6 libllvm3.4 libpciaccess0 libpixman-1-0
  libsm6 libtxc-dxtn-s2tc0 libx11-xcb1 libxaw7 libxcb-dri2-0 libxcb-dri3-0
  libxcb-glx0 libxcb-present0 libxcb-sync1 libxcomposite1 libxdamage1
  libxfixes3 libxfont1 libxkbfile1 libxmu6 libxpm4 libxrandr2 libxrender1
  libxshmfence1 libxt6 libxxf86vm1 x11-common x11-xkb-utils xfonts-base
  xfonts-encodings xfonts-utils xserver-common xserver-xorg-core
Use 'apt-get autoremove' to remove them.
The following extra packages will be installed:
  crda iw libnl-3-200 libnl-genl-3-200 wireless-regdb
The following NEW packages will be installed:
  crda iw libnl-3-200 libnl-genl-3-200 linux-image-extra-3.13.0-55-generic
  wireless-regdb
0 upgraded, 6 newly installed, 0 to remove and 0 not upgraded.
Need to get 36.7 MB/36.8 MB of archives.
After this operation, 152 MB of additional disk space will be used.
Err http://archive.ubuntu.com/ubuntu/ trusty-updates/main linux-image-extra-3.13.0-55-generic amd64 3.13.0-55.92
  404  Not Found [IP: 91.189.91.14 80]
Err http://security.ubuntu.com/ubuntu/ trusty-security/main linux-image-extra-3.13.0-55-generic amd64 3.13.0-55.92
  404  Not Found [IP: 91.189.91.23 80]


Stderr from the command:

stdin: is not a tty
modprobe: FATAL: Module aufs not found.
E: Failed to fetch http://security.ubuntu.com/ubuntu/pool/main/l/linux/linux-image-extra-3.13.0-55-generic_3.13.0-55.92_amd64.deb  404  Not Found [IP: 91.189.91.23 80]

E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?

undefined method `group_by' for nil:NilClass (NoMethodError)

This error occurs during install.

/usr/lib/ruby/2.3.0/rubygems/specification.rb:946:in

all=': undefined method group_by' for nil:NilClass (NoMethodError)
from /usr/lib/ruby/vendor_ruby/vagrant/bundler.rb:275:in with_isolated_gem' from /usr/lib/ruby/vendor_ruby/vagrant/bundler.rb:231:in internal_install'
from /usr/lib/ruby/vendor_ruby/vagrant/bundler.rb:102:in install' from /usr/lib/ruby/vendor_ruby/vagrant/plugin/manager.rb:62:in block in install_plugin'
from /usr/lib/ruby/vendor_ruby/vagrant/plugin/manager.rb:72:in install_plugin' from /usr/share/vagrant/plugins/commands/plugin/action/install_gem.rb:37:in call'
from /usr/lib/ruby/vendor_ruby/vagrant/action/warden.rb:34:in call' from /usr/lib/ruby/vendor_ruby/vagrant/action/builder.rb:116:in call'
from /usr/lib/ruby/vendor_ruby/vagrant/action/runner.rb:66:in block in run' from /usr/lib/ruby/vendor_ruby/vagrant/util/busy.rb:19:in busy'
from /usr/lib/ruby/vendor_ruby/vagrant/action/runner.rb:66:in run' from /usr/share/vagrant/plugins/commands/plugin/command/base.rb:14:in action'
from /usr/share/vagrant/plugins/commands/plugin/command/install.rb:32:in block in execute' from /usr/share/vagrant/plugins/commands/plugin/command/install.rb:31:in each'
from /usr/share/vagrant/plugins/commands/plugin/command/install.rb:31:in execute' from /usr/share/vagrant/plugins/commands/plugin/command/root.rb:56:in execute'
from /usr/lib/ruby/vendor_ruby/vagrant/cli.rb:42:in execute' from /usr/lib/ruby/vendor_ruby/vagrant/environment.rb:268:in cli'
from /usr/bin/vagrant:173:in `

Issue with example provided

Hello, so I've been trying to use the example.
I'm still a new user to Vagrant, and Docker itself, but the problem was that whenever I did Vagrant Up
I would get

Couldn't connect to Docker daemon at http+docker://localunixsocket - is it running?

If it's at a non-standard location, specify the URL with the DOCKER_HOST environment variable.

By ssh into VM problem would persist by doing docker version.

Solution was to change box used to Trusty64 in the Vagrantfile of example, and all is working.
Don't know if anyone else had the same issue, but this worked out for me.

Docker provisioner not running before docker-compose provisioner

Hi,

When attempt to build my docker-compose boxes I get this error:

==> default: Running provisioner: docker_compose...
    default: Checking for Docker Compose installation...
    default: Symlinking Docker Compose 1.8.0
    default: Running docker-compose up...
==> default: mesg:
==> default: ttyname failed
==> default: :
==> default: Inappropriate ioctl for device
==> default: Couldn't connect to Docker daemon. You might need to install Docker:
==> default:
==> default: https://docs.docker.com/engine/installation/
The following SSH command responded with a non-zero exit status.
Vagrant assumes that this means the command failed!

 /usr/local/bin/docker-compose-1.8.0  -f "/srv/docker/docker-compose.yml" up -d

Stdout from the command:



Stderr from the command:

mesg: ttyname failed: Inappropriate ioctl for device
Couldn't connect to Docker daemon. You might need to install Docker:

https://docs.docker.com/engine/installation/

Here is my Vagrantfile:

# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
  config.vm.hostname = "test.devel"

  config.vm.provision :docker
  config.vm.provision :docker_compose, yml: "/srv/docker/docker-compose.yml", run: "always"
end

If I comment out the docker_composes provisioner line and allow docker to install then uncomment it and reprovision it works fine.

My understanding from the doco is that these should run sequentially:
https://www.vagrantup.com/docs/provisioning/basic_usage.html

Is there anything you can think of as to why this might be taking place?

Thanks.

example doesn't work out of the box

I'm trying to get this plugin working and currently debugging the issue. I tested the example as it does not work out of the box as expected. I'll post a message if I figure out how to solve this problem...

root@UbuntuServe-0:~/vagrant-docker-compose/example#

vagrant status
No usable default provider could be found for your system.

Vagrant relies on interactions with 3rd party systems, known as
"providers", to provide Vagrant with resources to run development
environments. Examples are VirtualBox, VMware, Hyper-V.

The easiest solution to this message is to install VirtualBox, which
is available for free on all major platforms.

If you believe you already have a provider available, make sure it
is properly installed and configured. You can see more details about
why a particular provider isn't working by forcing usage with
vagrant up --provider=PROVIDER, which should give you a more specific
error message for that particular provider.
root@UbuntuServe-0:~/vagrant-docker-compose/example# vagrant status --provider=docker
An invalid option was specified. The help for this command
is available below.

Usage: vagrant status [name]
-h, --help Print this help

`

Update to latest Docker Compose

Hello,

First of all, great work! Please keep it up.

I'd like to ask if there are any known incompatibilities regarding the latest Docker Compose version (currently 1.11.2). I know that compose format has reached v3 with some options removed.

Could these cause us a problem with Vagrant?

Support for v2 compose files

I've noticed that there is no support for v2 compose files. Have you considered implementing support for v2 files?

How to sync `vagrant` folder?

I need to sync the folder /vagrant/ on the guest machine to a folder on the host without a reload vagrant. How can I doing that?

How to pass environment variables to docker-compose?

Can you provide an example in which environment variables, which are defined within the Vagrantfile, are made available to the docker-compose command? The goal is to have a Dockerfile that references them, like so:

RUN ["login-npm", "${NPM_USERNAME}", "${NPM_PASSWORD}", "${NPM_EMAIL}"]

Nothing I've tried so far seems to work.

Thank you.

Named Provisioner

I use named provisioners so I can rerun a specific one when I want to, e.g.:

    config.vm.provision "install_less", type: "shell", path: "#{host_script_dir}/misc/install_less.sh",
      args: [
        "--provisioned-dir=#{vm_provisioned_dir}",
        "--runfile-name=install_less",
        "--script-dir=#{vm_script_dir}"
      ]

I can rerun that with vagrant provision --provision-with=install_less. How do I name a docker-compose provisioner?

Context path with multiple docker-compose files

I have an issue with this plugin.
I have multiple docker-compose files, and any of them have Dockerfile pathes in it. Furthermore, there are external links between them.

It seems that the first path declared in yml array will be the current path in context for all building and running docker-compose files.
I have two problems :

  • First one, the relative path to the Dockerfile will always start to the first yml file declared, so docker-compose can't find it. I solved temporarily the problem by setting absolute path, but this path isn't relevant outside my vagrant.
  • Second one, as docker-compose name built images with the parent directory of the docker-compose, all my built images will have wrong name, and all my external links are wrong too.

Sorry for my english, I hope that is understandable.

Permission denied on windows babun?

==> default: stdin: is not a tty
==> default: bash: line 3: /usr/local/bin/docker-compose-1.11.2: Permission denied
The following SSH command responded with a non-zero exit status.
Vagrant assumes that this means the command failed!

/usr/local/bin/docker-compose-1.11.2 --x-networking -f "/vagrant/docker-compose.yml" rm

Stdout from the command:

Stderr from the command:

stdin: is not a tty
bash: line 3: /usr/local/bin/docker-compose-1.11.2: Permission denied

Error while building a project

Hello,

I started my vagrant up with this file:

Vagrant.configure("2") do |config|
  config.vm.box = "ubuntu/trusty64"

        config.vm.provision :docker
        config.vm.provision :docker_compose, yml: "/vagrant/docker-compose.yml",  run: "always", compose_version: "1.14.0"
end

It works well but there is a crash that return this error:
Service 'web' failed to build: The command '/bin/sh -c npm install' returned a non-zero code: 137

I don't know what append

Thanks

Old version

Hi!

This seems to be installing Docker Compose v1.6.x, while the latest is 1.8.x.

I'm used to using docker compose with the --build flag, but that's not available in 1.6 but later.

gr,

Tom

docker-compose V2?

This doesn't work with V2 any more. The download URL has changed, so it simply can't pull it.

/Users/user/.vagrant.d/gems/2.7.6/gems/vagrant-docker-compose-1.5.1/lib/vagrant-docker-compose/installer.rb:55:in `fetch_file': 
Error: unable to download docker-compose: https://github.com/docker/compose/releases/download/2.11.0/docker-compose-Linux-x86_64 (RuntimeError)

With v2 the URL is https://github.com/docker/compose/releases/download/v2.11.0/docker-compose-Linux-x86_64 (there's a v in the version. There are probably other issues.

If this project is dead, what's the standard way of provisioning docker compose these days?

Can't install plugin

Hi! Could you please help me. When trying to install this plugin I'm receiving the following error:

Vagrant version 1.8.3. On another machine with Vagrant 1.8.1 it is working fine.

$ vagrant plugin install vagrant-docker-compose
Installing the 'vagrant-docker-compose' plugin. This can take a few minutes...
Bundler, the underlying system Vagrant uses to install plugins,
reported an error. The error is shown below. These errors are usually
caused by misconfigured plugin installations or transient network
issues. The error from Bundler is:

Checksum of /versions does not match the checksum provided by server! Something is wrong.

Warning: this Gemfile contains multiple primary sources. Using source more than once without a block is a security risk, and may result in installing unexpected gems. To resolve this warning, use a block to indicate which gems should come from the secondary source. To upgrade this warning to an error, run bundle config disable_multisource true.

What could be done to resolve that?

Thanks

Installs docker-compose even if docker-compose is already installed

In my vagrant box, docker-compose version 1.9.0 is installed in the /usr/local/bin directory.
When starting with vagrant up, the plugin checks for docker-compose but does not find it and installs docker-compose 1.8.0.
How does the plugin check if docker-compose is installed?
Thanks.

Cannot use "docker-compose" right on first "vagrant up"

Given the following setup:

  • Vagrantfile:

    Vagrant.configure("2") do |config|
      config.vagrant.plugins = [
        "vagrant-docker-compose",
      ]
    
      config.vm.box = "ubuntu/trusty64"
      config.vm.provision :docker
      config.vm.provision :docker_compose,
        compose_version: "1.22.0"
    
      config.vm.provision :shell,
        keep_color: true,
        privileged: false,
        run: "always",
        inline: <<-SCRIPT
          cd /vagrant
          docker-compose up --detach
        SCRIPT
    end
  • docker-compose.yml:

    version: '3'
    
    services:
      hello:
        image: hello-world

The very first vagrant up fails since the Docker daemon does not seem to be ready yet:

$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: [vagrant-faster] Setting CPUs: 2, Memory: 4082
==> default: Importing base box 'ubuntu/trusty64'...
==> default: Matching MAC address for NAT networking...
==> default: Checking if box 'ubuntu/trusty64' is up to date...
==> default: A newer version of the box 'ubuntu/trusty64' for provider 'virtualbox' is
==> default: available! You currently have version '20150427.0.0'. The latest is version
==> default: '20181029.0.0'. Run `vagrant box update` to update.
==> default: Setting the name of the VM: test_default_1541059062991_6785
==> default: Clearing any previously set forwarded ports...
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
    default: Adapter 1: nat
==> default: Forwarding ports...
    default: 22 (guest) => 2222 (host) (adapter 1)
==> default: [vagrant-faster] Setting CPUs: 2, Memory: 4082
==> default: Running 'pre-boot' VM customizations...
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
    default: SSH address: 127.0.0.1:2222
    default: SSH username: vagrant
    default: SSH auth method: private key
    default: Warning: Connection reset. Retrying...
    default: Warning: Connection aborted. Retrying...
    default: Warning: Connection reset. Retrying...
    default: Warning: Connection aborted. Retrying...
    default: Warning: Connection reset. Retrying...
    default: Warning: Connection aborted. Retrying...
    default: Warning: Connection reset. Retrying...
    default: Warning: Connection aborted. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
    default: Warning: Connection reset. Retrying...
    default: Warning: Connection aborted. Retrying...
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...
    default: The guest additions on this VM do not match the installed version of
    default: VirtualBox! In most cases this is fine, but in rare cases it can
    default: prevent things such as shared folders from working properly. If you see
    default: shared folder errors, please make sure the guest additions within the
    default: virtual machine match the version of VirtualBox you have installed on
    default: your host and reload your VM.
    default:
    default: Guest Additions Version: 4.3.10
    default: VirtualBox Version: 5.2
==> default: Mounting shared folders...
    default: /vagrant => C:/.../test
==> default: Running provisioner: docker...
    default: Installing Docker onto machine...
==> default: Running provisioner: docker_compose...
    default: Checking for Docker Compose installation...
    default: Installing Docker Compose 1.22.0
    default: Symlinking Docker Compose 1.22.0
==> default: Running provisioner: shell...
    default: Running: inline script
    default: Couldn't connect to Docker daemon at http+docker://localhost - is it running?
    default:
    default: If it's at a non-standard location, specify the URL with the DOCKER_HOST environment variable.
The SSH command responded with a non-zero exit status. Vagrant
assumes that this means the command failed. The output for this command
should be in the log above. Please read the output to determine what
went wrong.

Subsequent runs are fine afterwards:

$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Checking if box 'ubuntu/trusty64' is up to date...
==> default: A newer version of the box 'ubuntu/trusty64' for provider 'virtualbox' is
==> default: available! You currently have version '20150427.0.0'. The latest is version
==> default: '20181029.0.0'. Run `vagrant box update` to update.
==> default: Machine already provisioned. Run `vagrant provision` or use the `--provision`
==> default: flag to force provisioning. Provisioners marked to run always will still run.
==> default: Running provisioner: shell...
    default: Running: inline script
    default: Creating network "vagrant_default" with the default driver
    default: Pulling hello (hello-world:)...
    default: latest: Pulling from library/hello-world
    default: Digest: sha256:0add3ace90ecb4adbf7777e9aacf18357296e799f81cabc9fde470971e499788
    default: Status: Downloaded newer image for hello-world:latest
    default: Creating vagrant_hello_1 ...
Creating vagrant_hello_1 ... done

$ vagrant halt
==> default: Attempting graceful shutdown of VM...

$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Checking if box 'ubuntu/trusty64' is up to date...
==> default: A newer version of the box 'ubuntu/trusty64' for provider 'virtualbox' is
==> default: available! You currently have version '20150427.0.0'. The latest is version
==> default: '20181029.0.0'. Run `vagrant box update` to update.
==> default: Clearing any previously set forwarded ports...
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
    default: Adapter 1: nat
==> default: Forwarding ports...
    default: 22 (guest) => 2222 (host) (adapter 1)
==> default: [vagrant-faster] Setting CPUs: 2, Memory: 4082
==> default: Running 'pre-boot' VM customizations...
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
    default: SSH address: 127.0.0.1:2222
    default: SSH username: vagrant
    default: SSH auth method: private key
    default: Warning: Connection reset. Retrying...
    default: Warning: Connection aborted. Retrying...
    default: Warning: Connection reset. Retrying...
    default: Warning: Connection aborted. Retrying...
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...
    default: The guest additions on this VM do not match the installed version of
    default: VirtualBox! In most cases this is fine, but in rare cases it can
    default: prevent things such as shared folders from working properly. If you see
    default: shared folder errors, please make sure the guest additions within the
    default: virtual machine match the version of VirtualBox you have installed on
    default: your host and reload your VM.
    default:
    default: Guest Additions Version: 4.3.10
    default: VirtualBox Version: 5.2
==> default: Mounting shared folders...
    default: /vagrant => C:/.../test
==> default: Machine already provisioned. Run `vagrant provision` or use the `--provision`
==> default: flag to force provisioning. Provisioners marked to run always will still run.
==> default: Running provisioner: shell...
    default: Running: inline script
    default: Starting vagrant_hello_1 ...
Starting vagrant_hello_1 ... done

Also a plain docker run seems to work fine.

  • Vagrantfile
Vagrant.configure("2") do |config|
  config.vagrant.plugins = [
    "vagrant-docker-compose",
  ]

  config.vm.box = "ubuntu/trusty64"
  config.vm.provision :docker
  config.vm.provision :docker_compose,
    compose_version: "1.22.0"

  config.vm.provision :shell,
    inline: "docker run hello-world"
end

Result:

$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: [vagrant-faster] Setting CPUs: 2, Memory: 4082
==> default: Importing base box 'ubuntu/trusty64'...
==> default: Matching MAC address for NAT networking...
==> default: Checking if box 'ubuntu/trusty64' is up to date...
==> default: A newer version of the box 'ubuntu/trusty64' for provider 'virtualbox' is
==> default: available! You currently have version '20150427.0.0'. The latest is version
==> default: '20181029.0.0'. Run `vagrant box update` to update.
==> default: Setting the name of the VM: test_default_1541059744399_81486
==> default: Clearing any previously set forwarded ports...
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
    default: Adapter 1: nat
==> default: Forwarding ports...
    default: 22 (guest) => 2222 (host) (adapter 1)
==> default: [vagrant-faster] Setting CPUs: 2, Memory: 4082
==> default: Running 'pre-boot' VM customizations...
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
    default: SSH address: 127.0.0.1:2222
    default: SSH username: vagrant
    default: SSH auth method: private key
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...
    default: The guest additions on this VM do not match the installed version of
    default: VirtualBox! In most cases this is fine, but in rare cases it can
    default: prevent things such as shared folders from working properly. If you see
    default: shared folder errors, please make sure the guest additions within the
    default: virtual machine match the version of VirtualBox you have installed on
    default: your host and reload your VM.
    default:
    default: Guest Additions Version: 4.3.10
    default: VirtualBox Version: 5.2
==> default: Mounting shared folders...
    default: /vagrant => C:/.../test
==> default: Running provisioner: docker...
    default: Installing Docker onto machine...
==> default: Running provisioner: docker_compose...
    default: Checking for Docker Compose installation...
    default: Installing Docker Compose 1.22.0
    default: Symlinking Docker Compose 1.22.0
==> default: Running provisioner: shell...
    default: Running: inline script
    default: Unable to find image 'hello-world:latest' locally
    default: latest: Pulling from library/hello-world
    default: d1725b59e92d: Pulling fs layer
    default: d1725b59e92d: Download complete
    default: d1725b59e92d: Pull complete
    default: Digest: sha256:0add3ace90ecb4adbf7777e9aacf18357296e799f81cabc9fde470971e499788
    default: Status: Downloaded newer image for hello-world:latest
    default:
    default: Hello from Docker!
    default: This message shows that your installation appears to be working correctly.
    default:
    default: To generate this message, Docker took the following steps:
    default:  1. The Docker client contacted the Docker daemon.
    default:  2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
    default:     (amd64)
    default:  3. The Docker daemon created a new container from that image which runs the
    default:     executable that produces the output you are currently reading.
    default:  4. The Docker daemon streamed that output to the Docker client, which sent it
    default:     to your terminal.
    default:
    default: To try something more ambitious, you can run an Ubuntu container with:
    default:  $ docker run -it ubuntu bash
    default:
    default: Share images, automate workflows, and more with a free Docker ID:
    default:  https://hub.docker.com/
    default:
    default: For more examples and ideas, visit:
    default:  https://docs.docker.com/get-started/

Any idea what's wrong here? Notice that I need to use the shell provisioner due to #52.

One of "build_dir" or "image" must be set

After running vagrant up I get the following error:

There are errors in the configuration of this machine. Please fix
the following errors and try again:

docker provider:
* One of "build_dir" or "image" must be set

Vagrantfile:

# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant.configure(2) do |config|
  config.vm.box = "ubuntu/trusty64"

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

docker-compose.yml

services: 
  redis: 
    image: redis
  web: 
    build: "."
    depends_on: 
      - redis
    ports: 
      - "5000:5000"
    volumes: 
      - ".:/code"
version: "2"

Support for docker-compose run

Is it possible to add support for the run command of docker-compose? So i can do the following in the Vagrantfile:

config.vm.provision :docker

config.vm.provision :docker_compose, compose_version: "1.5.1", yml: "/vagrant/docker-compose.yml", rebuild: false, run: "always"

config.vm.provision :docker_compose, yml: "/vagrant/docker-compose.yml", rebuild: false,
            command_options: { run: "--rm php sh bin/setup_mysql.sh"}, run: "always"

With this i can run an install script.

".env" not taken into account

We noticed that our local .env file is not used by docker-compose which is used to set various options.

I assume that's becaues docker-compose is executed in the default login directory (e.g. /home/vagrant) instead of the directory of the .env file. In our case that would be /vagrant where the Compose files are located too.

Would it be possible to add an option to switch the working directory for the docker-compose command?

This could be related to #43.

Names of created images

I'm using vagrant-docker-compose to create a set of images within a VM using one Vagrantfile & docker-compose.yml file, bundling that VM and then launching containers within it using another Vagrantfile & docker-compose.yml file.

The original images (which are built) are automatically named as eg vagrant_foo and vagrant_bar based on the name given in the YAML file. These images exist in the VM, eg as per:

$docker images

REPOSITORY                   TAG                 IMAGE ID            CREATED             VIRTUAL SIZE
vagrant_ipynb                latest              1bb94ebe6e38        3 hours ago         3.138 GB
vagrant_mongo                latest              51be69974278        3 hours ago         278 MB
ipython/scipystack           latest              720dc652b731        24 hours ago        2.857 GB

If I set eg image: vagrant_mongo as the name of an image in a new docker-compose.yml file, I get the error Error: image library/vagrant_mongo:latest not found.

If I set the name as ./vagrant_mongo I get HTTPS endpoint unresponsive and insecure mode isn't enabled..

So how do I address the created images? Is there anyway I can configure vagrant-docker-compose to get names of the form myimage/vagrant_mongo and then try to load those

GPG key not found

Hello! I got this error today on my Vagrant + Docker environment:

The following SSH command responded with a non-zero exit status.
Vagrant assumes that this means the command failed!

curl http://get.docker.io/gpg | apt-key add -

Stdout from the command:



Stderr from the command:

stdin: is not a tty
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:--  0:00:01 --:--:--     0
gpg: no valid OpenPGP data found.

And efectively there is no GPG key performing that curl. Maybe it could be avoided using the installation shell script?

This is my Vagrantfile:

# -*- mode: ruby -*-
# vi: set ft=ruby :

unless Vagrant.has_plugin?("vagrant-docker-compose")
  system("vagrant plugin install vagrant-docker-compose")
  puts "Dependencies installed, please try the command again."
  exit
end

Vagrant.configure(2) do |config|
  config.vm.box = "ubuntu/trusty64"
  config.vm.network "forwarded_port", guest: 80, host: 80
  config.vm.network "forwarded_port", guest: 3306, host: 3306

  config.vm.provision :shell, inline: "apt-get update"
  config.vm.provision :docker
  config.vm.provision :docker_compose,
      yml: "/vagrant/docker-compose.yml",
      rebuild: true,
      project_name: "pm",
      run: "always"
end

Thank you and best regards!

compose_version check, and auto-update

Hi. I have been using the following line in my Vagrantfile for the past little while:

pocket.vm.provision :docker_compose, compose_version: "1.6.0"

I was hoping that setting the version to 1.7.0 (released 8 days ago) would auto-magically upgrade docker-compose, but it does not. One thing that did work however was to delete /usr/local/bin/docker-compose and do a 'vagrant reload'. Maybe the plugin could check to see if the version installed matches the compose_version option? Just an idea, thanks!

docker-compose default version change to 1.5.0

Hi,

I like this plugin very much, and have been using it successfully; thanks for that. I will like to use some of the new features that docker-compose version 1.5.0 offers. The default version this plugin installs is 1.4.0.

I understand the latest version of this plugin (0.0.5) was released on Aug, and the new docker-compose release (1.5.0) was released barely one week ago.

Please I need help to understant:
a) how to change the default release of docker-compose to 1.5.0 instead of 1.4.0, or
b) how to use the "compose_version" config (as specified at the end of the README.md)?

Thanks,
Juan

Don't rely on curl only

For the download/installation of docker-compose curl is used inside of the vm. But not all images have curl preinstalled (e.g. debian/stretch64), which leads to the following error:

==> default: Running provisioner: docker_compose...
    default: Checking for Docker Compose installation...
    default: Installing Docker Compose 1.11.2
The following SSH command responded with a non-zero exit status.
Vagrant assumes that this means the command failed!

curl -L https://github.com/docker/compose/releases/download/1.11.2/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose-1.11.2

Stdout from the command:



Stderr from the command:

bash: line 4: curl: command not found

The installation would be more robust if additional wget would be used.
Something like:

URL=https://github.com/docker/compose/releases/download/1.11.2/docker-compose-`uname -s`-`uname -m` ; (curl -L $URL || wget -O- $URL) > ...

Is "docker-compose.override.yml" supported?

Hi,
I was wondering if "docker-compose.override.yml" was supported as stated in Extending services and Compose files

By default, Compose reads two files, a docker-compose.yml and an optional docker-compose.override.yml file. By convention, the docker-compose.yml contains your base configuration. The override file, as its name implies, can contain configuration overrides for existing services or entirely new services.

I tried but it didn't work for me (both yml files residing in the same folder)

[Feature] Add start support

It is possible to use the Docker Compose start option if the container exists and only use up -d at the first time (provision)? So always means:

docker-compose -f [yml] start

This would be great.

Copy files from a mounted directory to a Docker image

My use case is:
I would like to copy files from a mounted directory (in Vagrantfile) to a Docker image.

Vagrantfile:
config.vm.synced_folder "./services", "/services", create: true

Dockefile:
COPY services/myapp.jar /app.jar

Since services has to be in the Docker build context, I cannot say
COPY /services/myapp.jar /app.jar

So it would help, if I could configure the Vagrant docker-compose provider to be run in a specific directory, e.g. "/"

An alternative would be to specify in the Vagrantfile:
config.vm.synced_folder "./services", "/directory-where-docker-compose-is-run/services", create: true

What is the default directory where docker-compose is run?

Multiple docker-compose files

Is it possible to use multiple docker-compose files in the Vagrantfile with this provisioner? I am looking to be able to mimic running docker-compose -f docker-compose.yml -f docker-compose.dev.yml up on vagrant up. Thanks!

Set docker-compose version to latest

Is there any way to achieve setting docker-compose version to latest stable? Just like the docker installation defaults to latest stable version.

Multiple docker-compose provisions doesn't work as expected

If i want to run multiple docker-compose.yml files like:

config.vm.provision :docker_compose, yml: "/vagrant/docker-compose-dev.yml", rebuild: true, run: "always", project_name: "ris", compose_version: "1.4.2"                                                                         
config.vm.provision :docker_compose, yml: "/vagrant/logging/docker-logstash-forwarder.yml", rebuild: true, run: "always", project_name: "logging", compose_version: "1.4.2"

Both will run, but I will not be able to ssh in and manage using docker-compse -f /vagrant/docker-compose-dev, only the last provision I ran.

Example:

vagrant@vagrant-ubuntu-trusty-64:/vagrant$ docker-compose -f logging/docker-logstash-forwarder.yml ps
            Name                          Command               State                       Ports                      
----------------------------------------------------------------------------------------------------------------------
logging_elasticsearch_1        /usr/local/sbin/start.sh         Up      0.0.0.0:9200->9200/tcp, 0.0.0.0:9300->9300/tcp 
logging_logstash-forwarder_1   /usr/local/bin/docker-logs ...   Up                                                     
logging_logstash_1             /usr/local/sbin/start.sh         Up      5043/tcp  
root@vagrant-ubuntu-trusty-64:/vagrant# docker-compose -f docker-compose-dev.yml ps
Name   Command   State   Ports 
------------------------------
root@vagrant-ubuntu-trusty-64:/vagrant# docker ps                                                                                                                                                                                  
CONTAINER ID        IMAGE                             COMMAND                CREATED             STATUS              PORTS                                            NAMES
b660943180e8        nuthman/logstash-forwarder        "/usr/local/bin/dock   9 minutes ago       Up 9 minutes                                                         logging_logstash-forwarder_1   
5408195ff0c1        digitalwonderland/logstash        "/usr/local/sbin/sta   9 minutes ago       Up 9 minutes        5043/tcp                                         logging_logstash_1             
5a3506214754        digitalwonderland/elasticsearch   "/usr/local/sbin/sta   9 minutes ago       Up 9 minutes        0.0.0.0:9200->9200/tcp, 0.0.0.0:9300->9300/tcp   logging_elasticsearch_1        
26680ddbebaf        ris_solr                          "java -jar /opt/solr   9 minutes ago       Up 9 minutes                                                         ris_solr_1                     
5ba65a7c4767        cmfatih/phantomjs                 "phantomjs /mnt/ris-   9 minutes ago       Up 9 minutes                                                         ris_phantom_1 

I'm fairly new to vagrant, so the issue might be something there, but I'm not sure.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.