Tuesday, April 22, 2014

Vagrant + Docker :: Could not find repository on any of the indexed registries

ahoProblem

I was trying my hands on Docker provisioning with Vagrant and came across this error when I tried to provision a VM with a docker container that I uploaded to the docker registry earlier.

Vagrantfile

Vagrant.configure("2") do |config|
  config.vm.box = "oel631"
  config.vm.network :forwarded_port, guest: 9090, host: 9090, auto_correct: true
  config.vm.synced_folder "/Users/Naga/Downloads/Software", "/Software"
  config.vm.provider :virtualbox do |vb|
     vb.customize ["modifyvm", :id, "--memory", 4096]
     vb.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
     vb.customize ["modifyvm", :id, "--natdnsproxy1", "on"]
  end
  config.vm.provision "docker" do |d|
    d.run "asnagaraj/java7u55tomcat7053ubuntu", 

      daemonize: true, 
      cmd: "echo hello world",
      args: "-v '/Software:/Software'"
   end
end


Could not find repository on any of the indexed registries

Solution

Add dns="8.8.8.8" argument to the run command to make sure the docker container has access to internet to resolve hosts and access and download the images

Updated Vagrantfile

Vagrant.configure("2") do |config|
  config.vm.box = "oel631"
  config.vm.network :forwarded_port, guest: 9090, host: 9090, auto_correct: true
  config.vm.synced_folder "/Users/Naga/Downloads/Software", "/Software"
  config.vm.provider :virtualbox do |vb|
     vb.customize ["modifyvm", :id, "--memory", 4096]
     vb.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
     vb.customize ["modifyvm", :id, "--natdnsproxy1", "on"]
  end
  config.vm.provision "docker" do |d|
    d.run "asnagaraj/java7u55tomcat7053ubuntu",
      daemonize: true,
      cmd: "echo hello world",
      args: "--dns='8.8.8.8'  -v '/Software:/Software'"
  end
end


[vagrant@localhost ~]$ sudo docker images
REPOSITORY                           TAG                 IMAGE ID            CREATED             VIRTUAL SIZE
asnagaraj/java7u55tomcat7053ubuntu   latest              7e10245f1e4c        4 days ago          737.3 MB

1 comment:

  1. thanks for suggestion you can change dns on host computer too.

    ReplyDelete