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

Issues using Docker provisioning on Vagrant

Problem

I wanted to try my hands with Docker provisioning on Vagrant this weekend and came across tons of issues and the main issue was around docker provisioner...

* The 'docker' provisioner could not be found.  (was using super old Vagrant version 1.3.5 so upgraded to 1.5.3)

Vagrantfile Sample 1

Vagrant.configure("2") do |config|
  config.vm.box = "oel631"
  config.vm.provision "docker",
    images: ["ubuntu"]
end



Error while trying to bring up my VM / provision it when it was already running

Docker is not running on the guest VM.


Vagrantfile Sample 2 

VAGRANTFILE_API_VERSION = "2"

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
  config.vm.box = "precise64"

  config.vm.provision "docker" do |d|
    d.pull_images "ubuntu"
  end
end


Vagrant assumes that this means the command failed!
service docker start
Stdout from the command:
Stderr from the command:
stdin: is not a tty
start: Job is already running: docker


Vagrantfile Sample 3

VAGRANTFILE_API_VERSION = "2"

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
  config.vm.box = "precise64"

  config.vm.provision "docker" do |d|
    d.run "ubuntu",
      cmd: "bash -l",
      args: "-v '/vagrant:/var/www'"
    end
end


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

service docker start

Stdout from the command:



Stderr from the command:

stdin: is not a tty
start: Job is already running: docker


Solution

Got a resolution to upgrade to Vagrant 1.5.4 from the issue below after spending so much time on Google reading 1000's of post where people have used Docker provisioning on Vagrant. Seems to me like Vagrant 1.5.3 was the killer. I personally think Vagrant 1.5.3 doesnt really work well with Docker provisioning.

https://github.com/mitchellh/vagrant/issues/3487

Thursday, April 17, 2014

Vagrant shows startup warnings about Vagrantfile using earlier version syntax

Problem

My vagrant shows the following message when I try to bring up my vagrant 

There were warnings and/or errors while loading your Vagrantfile
for the machine 'default'.

Your Vagrantfile was written for an earlier version of Vagrant,
and while Vagrant does the best it can to remain backwards
compatible, there are some cases where things have changed
significantly enough to warrant a message. These messages are
shown below.

Warnings:
* `config.vm.customize` calls are VirtualBox-specific. If you're
using any other provider, you'll have to use config.vm.provider in a
v2 configuration block.


The issue seem to be because I was using vagrant 1.3.5 and was using some older syntax
Vagrant::Config.run do |config|
  config.vm.box = "precise64"
  config.vm.forward_port 8080, 8080
  config.vm.share_folder("vagrant-root", "/vagrant", ".")
  config.vm.customize ["modifyvm", :id, "--memory", 4096]
end


Solution

I changed my Vagrantfile as follows as my error/warning is gone now..During the transition I got the following error

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

vm:
* The following settings shouldn't exist: forward_port, share_folder

as I was using configure("2") and using older syntax for forwarding ports and sharing folders, which also got fixed with the following updates


Vagrant.configure("2") do |config|
  config.vm.box = "precise64"
  config.vm.network :forwarded_port, guest: 8080, host: 9090, auto_correct: true
  config.vm.synced_folder "/Users/Naga/Downloads/Software/AHold", "/Software"
  config.vm.provider :virtualbox do |vb|
     vb.customize ["modifyvm", :id, "--memory", 4096]
  end

end


Monday, June 3, 2013

MacOSX Quick Look Plugin to view Zip files - This is Kewl

I always wanted to see whats inside the zip without really extracting it, which was pretty simple and straight forward with all the tools that I used on Windows (yea those days :-)) but somehow after I switched to Mac (as part of job, but am loving it) I really missed that feature of just peeking into the zip without extracting it, somehow there isnt any (or i dont know off) way to peek into the zip files on the Mac when you double click the Archive (utility) just extracts it, I was always annoyed about it, and today that is gone. Thanks to BetterZip QuickLook plugin




Thursday, May 30, 2013

Things I did not know before


1. To change to US keyboard in linux you can type the following command (make sure you are logged in as root, or do switch to root user if you have the auth)

loadkeys us

Monday, May 27, 2013

Finally got Acrobat Reader back on my Mac

Preview had been the defacto PDF / Image viewer for me after I started using my mac. I remember having an Acrobat reader installed sometime initially but never used it as Preview is open most of the time on my Mac and I did not want to burden my CPU with one more Application. But suddenly a few days back when I tried to open a PDF on my Preview it showed nothing but a small PDF watermark on all the pages and nothing else. I tried opening the PDF in Google Chrome and Firefox using the Acrobat plugin and they just display the contents with no problem, thats when I wanted the Acrobat Reader back on my Mac. I never thought it would be so difficult to get it back. I kept trying to download the Acrobat Reader from Adobe site and got nothing but a switch off your Antivirus message but nothing else. I couldnt get through that - neither the Apple communites nor the Adobe forums could be of any help and finally Google came to the rescue by showing me this site - http://www.oldapps.com/mac/adobe_reader.php. I am now back with the reader, even though I am still continuing to have Preview as my default PDF viewer :-) Thanks OldApps. 

Saturday, January 7, 2012

Java - Adding references to Framework API Documentation (docs) while generating Javadocs

In continuation to my earlier posts about using Maven to generate Javadocs for your project source code, I want to provide some inputs on how you can link your project's generated apiDocs to the apiDocs of the framework it is dependent on. In my case, I was working on an ATG project and used Maven javadoc plugin to generate javadocs for my project source code, the apiDocs got generated successfully but all the ATG Framework classes that my project source code referred to were linked to the Oracle java documentation. This was because the javadoc plugin assumes that any class thats not defined in the project source code is actually a java class. To avoid this from happening, you can add links/link tag combination (as given in the snippet below) and point the same to the folder/URL which contains the apiDocs/package-list (in my case this file was inside the folder mentioned in the link tag) file. This file helps the javadoc utility understand as to which packages are covered by the docs provided by the folder in the link tag. This way if your project is referring to multiple frameworks you can download the framework documentation to a folder and add the offline links to the javadoc plugin configuration section and rerun the maven command to regenerate the apiDocs with the updated links.

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-javadoc-plugin</artifactId>
    <version>2.8</version>
    <configuration>
        <reportOutputDirectory>C:/Project/apiDocs</reportOutputDirectory>
        <doclet>org.umlgraph.doclet.UmlGraphDoc</doclet>
        <docletArtifact>
            <groupId>org.umlgraph</groupId>
            <artifactId>doclet</artifactId>
            <version>5.1</version>
        </docletArtifact>
        <additionalparam>-views</additionalparam>
        <useStandardDocletOptions>true</useStandardDocletOptions>
        <links>
            <link>file:///C:/Users/nseshadr/Downloads/E22630_01/Platform.1002/apidoc</link>
        </links>

    </configuration>
    <executions>
        <execution>
            <id>aggregate</id>
            <goals>
                <goal>aggregate</goal>
            </goals>
        </execution>
    </executions>
</plugin>

You can always refer to the Maven Javadoc Plugin page for more information and options.

Note: Also you can download the Oracle Sun Java API documentation and add information about the same to the links/link section and that will make all your java class references point to the local API folder as against the internet URL.