How to install KoboToolbox by using Docker on Ubuntu Server 16.04

KoBoToolbox is a suite of tools for field data collection for use in challenging environments. KoboToolbox is free and open source. Most of the users are the staff who are working in humanitarian crises, as well as aid professionals and researchers working in developing countries. KoboToolbox developers and researchers are based in Cambridge, MA and many other places around the world.

Installation

You can find a nice instruction on KoboToolbox GitHub site

First of all, you need to check for Docker installation by this link

Clone the repository by typing:

~$ git clone https://github.com/kobotoolbox/kobo-docker.git

It will clone the necessary documents in kobo-docker folder

~$ cd kobo-docker

The first decision to make is whether your instance (kobo) will use secure (https) or insecure (http) communications when interacting with clients.

If it is local one:

~$ nano envfile.local.txt

If it is server one

~$ nano envfile.server.txt

Fill the lines as shown below with your username and password:

Save and exit.

Then type :

For Local:

~$ ln -s docker-compose.local.yml docker-compose.yml

For Server:

~$ ln -s docker-compose.server.yml docker-compose.yml

 

~$ docker-compose pull

~$ docker-compose up

It will take some time based on connection

After it is finished you can check on your browser (for local):

http://[IP_address_of_your_machine]:8000/

Congratulations you have a fresh instance of KoboToolbox!

Use the below link for Site Administration

http://[IP_address_of_your_machine]:8000/admin/

To stop the container you can type:

~$ docker-compose stop

 

Congratulations!

What is Vagrant and how to manage it on Ubuntu Server 16.04

Vagrant is a tool for building and managing virtual machine environments in a single workflow. With an easy-to-use workflow and focus on automation, Vagrant lowers development environment setup time, increases production parity, and makes the “works on my machine” excuse a relic of the past.

If you are a developer, Vagrant will isolate dependencies and their configuration within a single disposable, consistent environment, without sacrificing any of the tools you are used to working with (editors, browsers, debuggers, etc.). Once you or someone else creates a single Vagrantfile, you just need to ~$ vagrant up and everything is installed and configured for you to work. Other members of your team create their development environments from the same configuration, so whether you are working on Linux, Mac OS X, or Windows, all your team members are running code in the same environment, against the same dependencies, all configured the same way. Say goodbye to “works on my machine” bugs.

Download & install the latest version of Vagrant & Virtual Box, by visiting Vagrant Downloads and VirtualBox Downloads.

~$ wget https://releases.hashicorp.com/vagrant/2.0.1/vagrant_2.0.1_x86_64.deb

~$ wget https://download.virtualbox.org/virtualbox/5.2.6/virtualbox-5.2_5.2.6-120293~Ubuntu~xenial_amd64.deb

Install them by:

~$ sudo dpkg -i vagrant_2.0.1_x86_64.deb

~$ sudo dpkg -i virtualbox-5.2_5.2.6-120293~Ubuntu~xenial_amd64.deb

 

Vagrant Box

A box is basically a package containing a representation of a virtual machine running a specific operating system. To be more simple, it is a base image of any Operating System or Kernel. It may be for a specific Provider.

For example: https://app.vagrantup.com/boxes/search

Providers

The Provider is the piece of software responsible for creating and managing the virtual machines used by Vagrant. The main providers are Virtualbox and VMware, but the default one is VirtualBox since it’s free and open source.

Provisioners

Provisioner will do some task(s) using the VM instance already provided. The provisioners are used to set up the virtual server, installing all necessary software and executing different tasks. The most used provisioners are : PuppetChef, and Ansible. Shell Script is also a very common option. You can find more information about vagrant provisioners here.

The Vagrantfile

The basic vagrant configuration is based in one file, the Vagrantfile. It shall be placed in your repository root. In this file you will define which base box you want a box is, basically, a package with an operational system to be run on your virtual machine.

After the installation is done, let us download one box from https://app.vagrantup.com/boxes/search with below commands

~$ mkdir vagrant-test

~$ cd vagrant-test

Let us command our first vagrant command: vagrant init

~$ vagrant init

It will create a file: Vagrantfile

Let us edit it:

~$ nano Vagrantfile

That is Ruby!

find config.vm.box = ‘base’ and change base with a image name on https://app.vagrantup.com/boxes/search

For example config.vm.box = “ubuntu/trusty64”

So it is basically

Vagrant.configure(“2”) do |config|
    config.vm.box = “ubuntu/trusty64”
end

or you can run the below command instead of changing Vagrantfile

~$ vagrant init ubuntu/trusty64

Then the final command for provisioning:

~$ vagrant up

If it gives error execute with sudo!

It will take some time to finalize it.

After it is done when you check your VirtualBox you will see there is an virtual client running.

The default username is vagrant and password is also vagrant

But you can easily reach the virtual client from host (without knowing username/password) with below ssh command:

~$ vagrant ssh

Don’t forget: To run the commands you should be in the folder! If you have another VM then you should change folder (cd ….) to execute them!

Congratulations! You have a full box in a very short time!

What is Docker and How to install on Ubuntu Server 16.04

Docker is a tool designed to make it easier to create, deploy, and run applications by using containers. Containers allow a developer to package up an application with all of the parts it needs, such as libraries and other dependencies, and ship it all out as one package. By doing so, thanks to the container, the developer can rest assured that the application will run on any other Linux machine regardless of any customized settings that machine might have that could differ from the machine used for writing and testing the code.

 

In a way, Docker is a bit like a virtual machine. But unlike a virtual machine, rather than creating a whole virtual operating system, Docker allows applications to use the same Linux kernel as the system that they’re running on and only requires applications be shipped with things not already running on the host computer. This gives a significant performance boost and reduces the size of the application.

 

A container image is a lightweight, stand-alone, executable package of a piece of software that includes everything needed to run it: code, runtime, system tools, system libraries, settings. Available for both Linux and Windows based apps, containerized software will always run the same, regardless of the environment. Containers isolate software from its surroundings, for example differences between development and staging environments and help reduce conflicts between teams running different software on the same infrastructure.

Set up the docker repository on Ubuntu

$ sudo apt-get update

$ sudo apt-get install apt-transport-https ca-certificates curl software-properties-common

$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add –

$ sudo add-apt-repository “deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable”

Check for details on this link

Install Docker CE (Community Edition)

$ sudo apt-get update

$ sudo apt-get install docker-ce docker-compose

 

The docker cli is used when managing individual containers on a docker engine. It is the client command line to access the docker daemon api.

The docker-compose cli can be used to manage a multi-container application. It also moves many of the options you would enter on the docker run cli into the docker-compose.yml file for easier reuse. It works as a front-end “script” on top of the same docker api used by docker, so you can do everything docker-compose does with docker commands and a lot of shell scripting

 

An Example:

Go for https://hub.docker.com/explore/ and choose a repo

For example, let us choose nginx 

Let us create a folder for this ~$ mkdir nginx-test

Then go in the folder ~$ cd nginx-test

Run the pull command

~$ docker pull nginx

After installation is done you can run one instance of the nginx as follows(this is the simplest way):

~$ docker run nginx

 

To print all containers on the machine (active ones)

~$ docker ps 

To print all containers on the machine

~$ docker ps -a

List all images on the machine

~$ docker images 

To remove container

~$ docker rm [contrainer_name]

Run container

~$ docker run [contrainer_name]

Stop container

~$ docker stop [contrainer_name]

Stop all containers

~$ docker stop $(docker ps -a -q)

Remove all containers

~$ docker rm $(docker ps -a -q)