1.9.5
Windows 10
ubuntu/trusty64
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.boot_timeout = 120
config.vm.box = "ubuntu/trusty64"
config.vm.hostname = "docker-provider-host"
config.vm.provider :virtualbox do |vb|
vb.name = "docker-provider-host"
vb.customize [
"modifyvm", :id,
"--memory", 8192,
]
end
config.vm.network "private_network", ip: "192.168.33.60"
config.ssh.username = "vagrant"
config.ssh.password = "vagrant"
config.ssh.insert_key = true
# Disable sync of current folders
config.vm.synced_folder ".", "/home/vagrant/sync", disabled: true
$logs_folders = <<-LOGS_FOLDERS
mkdir -p /var/log/my-application
LOGS_FOLDERS
config.vm.provision "logs_folders", type: "shell", inline: $logs_folders
# Make it possible for the volumes mounted into the container to be written to
# ref: https://goldmann.pl/blog/2014/07/18/logging-with-the-wildfly-docker-image/
# Observe that since the above post the base docker image for Wildfly has changed
# and now they use uid/gid 1000/1000 so first regular user, i.e. in a vagrant box
# it is the vagrant user.
# ref: https://github.com/jboss-dockerfiles/base/blob/master/Dockerfile
$logs_folders_permissions = <<-LOGS_FOLDERS_PERMISSIONS
chown -R vagrant:vagrant /var/log/my-application
LOGS_FOLDERS_PERMISSIONS
config.vm.provision "logs_folders_permissions", type: "shell", privileged: true, inline: $logs_folders_permissions
# Install docker
config.vm.provision "docker"
# Add user vagrant to docker group
$docker_group = <<-DOCKER_GROUP
usermod -a -G docker vagrant
restart docker
newgrp docker
DOCKER_GROUP
config.vm.provision "docker_group", type: "shell", privileged: true, inline: $docker_group
end
Vagrant.configure("2") do |config|
config.vm.provider "docker" do |docker|
# Some inspiration: http://theunic.github.io/2014/12/29/development-environments-with-vagrant-and-docker.html
config.vm.synced_folder ".", "/vagrant", disabled: true
docker.build_dir = "."
docker.dockerfile = "Dockerfile.dev"
docker.host_vm_build_dir_options = {
type: "rsync"
}
docker.remains_running = true
docker.vagrant_vagrantfile = "../Vagrantfile"
docker.force_host_vm = true
docker.create_args = ["-d", "-it", "-m", "2g"]
docker.ports = [
"9082:8080",
"9992:9990",
"8788:8787"
]
docker.name = "my-application-test"
docker.env = {
"JAVA_OPTS":"-Xms512m -Xmx1536m -Xdebug -Xnoagent -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=n"
}
docker.volumes = [
"/var/log/my-application:/opt/jboss/wildfly/standalone/log"
]
docker.cmd = [
"/opt/jboss/wildfly/bin/standalone.sh",
"-Dtarget.mode=test",
"-Ddev=true",
"-Djava.net.preferIPv4Stack=true",
"-Djava.net.preferIPv4Addresses",
"-b", "0.0.0.0",
"-bmanagement", "0.0.0.0"
]
end
end
FROM jboss/wildfly:10.1.0.Final
No debug yet, will provide upon request.
Worked in 1.9.4. Create docker image and container.
It appears the volumes parameter for docker provider tries to synch using the path formatting of the host machine instead of the host_vm created to build and run the docker containers from.
I get the following.
A Docker command executed by Vagrant didn't complete successfully!
The command run along with the output from the command is shown
below.
Command: "docker" "run" "--name" "my-application-test" "-d" "-e" "JAVA_OPTS=-Xms512m -Xmx1536m -Xdebug -Xnoagent -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=n" "-p" "9083:8080" "-p" "9993:9990" "-p" "8789:8787" "-v" "C:\cygwin64\var\log\my-application:/opt/jboss/wildfly/standalone/log" "-v" "-d" "-it" "-m" "2g" "43561cedfe70" "/opt/jboss/wildfly/bin/standalone.sh" "-Dtarget.mode=test" "-Ddev=true" " "-Djava.net.preferIPv4Stack=true" "-Djava.net.preferIPv4Addresses" "-b" "0.0.0.0" "-bmanagement" "0.0.0.0"
Stderr: docker: Error response from daemon: invalid bind mount spec "C:\\cygwin64\\var\\log\\my-application:/opt/jboss/wildfly/standalone/log": invalid mode: /opt/jboss/wildfly/standalone/log.
See 'docker run --help'.
Stdout:
default: The previous process exited with exit code 1.
Observe this specifically: "-v" "C:\cygwin64\var\log\my-application:/opt/jboss/wildfly/standalone/log"
None that I know about. I know there where some changes regarding force_host_vm flag in 1.9.4 but they worked. I don't know what other changes have been done to Docker provider for 1.9.5. I think @chrisroberts is very well informed.
UPDATE: Could this be caused by https://github.com/mitchellh/vagrant/commit/5d83c03bfc48407451999f21b0320a1ebb22a8cd?
My customers get this error which should be the same issue.
Command: "docker" "run" "--name" "spark" "-d" "-p" "21:21" ... "-v" "var\lib\docker\docker_1495457854_50822:/root/book" "-h" "spark" "scrapybook/spark"
Stderr: docker: Error response from daemon: create var\lib\docker\docker_1495457854_50822: volume name invalid: "var\\lib\\docker\\docker_1495457854_50822" includes invalid characters for a local volume name, only "[a-zA-Z0-9][a-zA-Z0-9_.-]" are allowed.
See 'docker run --help'.
@lookfwd Are your customers running on a Windows host? If that is the case maybe. However, the path that the error message says is invalid is not in Windows format:
var\\lib\\docker\\docker_1495457854_50822
So I'm not sure it's the same problem. Might be WSDL and that does that the WSDL and Windows gsub runs.
I can confirm that undoing the changes from https://github.com/mitchellh/vagrant/commit/5d83c03bfc48407451999f21b0320a1ebb22a8cd solves my problem. However I understand that it is not a permanent fix and this issue should be have a more proper fix.
For those interested, the file you need to change in Windows is:
C:\HashiCorp\Vagrant\embedded\gems\gems\vagrant-1.9.5\plugins\providers\docker\driver.rb
I can confirm the issue for an almost identical setup, removing the error causing patch as suggested by @agusti-t as workaround fixes the issue for now.
I've added a more proper fix here #8921
Hi there,
It looks like this has been resolved within a previously shipped version of Vagrant so I am now closing this issue. If the original issue was not fully resolved, please reopen this issue or create a new one.
Cheers!
I'm going to lock this issue because it has been closed for _30 days_ โณ. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.
Most helpful comment
I can confirm that undoing the changes from https://github.com/mitchellh/vagrant/commit/5d83c03bfc48407451999f21b0320a1ebb22a8cd solves my problem. However I understand that it is not a permanent fix and this issue should be have a more proper fix.
For those interested, the file you need to change in Windows is:
C:\HashiCorp\Vagrant\embedded\gems\gems\vagrant-1.9.5\plugins\providers\docker\driver.rb