Reputation: 12870
I want to run a docker image on Vagrant machine. My Vagrantfile is straingforward:
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "ubuntu/trusty64"
config.vm.synced_folder "./project/", "/project/"
config.vm.network "forwarded_port", guest: 8000, host: 8000
config.vm.network :public_network, bridge: 'eth0'
config.vm.provision "docker" do |d|
d.run 'ldap', image: '10.5.6.19:5000/ldap'
end
end
I have this image on my machine:
>sudo docker images
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
10.5.6.19:5000/ldap latest ef7f4dcecd65 3 months ago 930.8 MB
but when I try to provision a machine with vagrant provision
. I achieve an error:
Stdout from the command:
Stderr from the command:
stdin: is not a tty
Unable to find image '10.5.6.19:5000/ldap:latest' locally
time="2014-12-30T13:50:37Z" level="fatal" msg="Error: Invalid registry endpoint https://10.14.6.19:5000/v1/: Get https://10.14.6.19:5000/v1/_ping: dial tcp 10.14.6.19:5000: i/o timeout. If this private registry supports only HTTP or HTTPS with an unknown CA certificate, please add `--insecure-registry 10.14.6.19:5000` to the daemon's arguments. In the case of HTTPS, if you have access to the registry's CA certificate, no need for the flag; simply place the CA certificate at /etc/docker/certs.d/10.14.6.19:5000/ca.crt"
I think this happens because I should use some kind of registry for images. Is there a way to use local images for vagrant provisioning?
Upvotes: 0
Views: 1428
Reputation: 1356
You need to add the following in /etc/default/docker
:
DOCKER_OPTS="--insecure-registry 10.14.6.19:5000"
On a side note, this goes in EXTRA_ARGS
in /var/lib/boot2docker/profile
in case you were using boot2docker.
There are a few options to choose from to fix this:
To use option 3, include this before the docker provisioner:
config.vm.provision "shell",
inline: <<-EOS
echo 'DOCKER_OPTS="--insecure-registry 10.14.6.19:5000 ${DOCKER_OPTS}"' \
>> /etc/default/docker
EOS
After this if you execute vagrant up
(or vagrant reload --provision
in case the vm is already running), you'll be able to run your image without any problems.
Upvotes: 2
Reputation: 8685
Provisioning with docker means that vagrant will manage a VM by provisioning it with docker and commands you supply. This will be a different machine than your host with different docker and independent pull of images. The way to get your image inside the vagrant would be to perform the same actions you did on your host to get that image in the first place, or to share the image via the docker hub.
If you can run docker natively (meaning you are on linux), you might alternatively consider using docker as vagrant provider. I guess in this case you will use the docker of the host and hence will get access to the images of it.
Upvotes: 1