Dockerification of your local virtual instance with SSH, XFCE & VNC

1. Docker: the client-server application made up of the Docker daemon, a REST API that specifies interfaces for interacting with the daemon, and a command line interface (CLI) client that talks to the daemon (through the REST API wrapper). Docker Engine accepts docker commands from the CLI, such as docker run , docker ps to list running containers, docker images to list images, and so on.

2. Docker Machine: a tool for provisioning and managing your Dockerized hosts (hosts with Docker Engine on them). Typically, you install Docker Machine on your local system. Docker Machine has its own command line client docker-machine and the Docker Engine client, docker. You can use Machine to install Docker Engine on one or more virtual systems.

engine-components-flow

We will be using Virtualbox based virtualization in docker which is supported on windows and mac.

A setup for linux instance is also available

I will be using docker toolbox as for my docker installation on windows.

 

1. Install the docker-toolbox using the default options and verify the versions from the Docker Quickstart Terminal.

$ docker-machine --version
  docker-machine.exe version 0.8.2, build e18a919

$ docker --version
  Docker version 1.12.2, build bb80604

 

2. Perfect, now we move to the docker machine toolbox which hosts the docker engine and give it a kickoff.

$ docker-machine rm default
$ docker-machine create --driver virtualbox --virtualbox-disk-size "500100" default
$ docker-machine start default
$ docker-machine env default
$ eval $("C:\Program Files\Docker Toolbox\docker-machine.exe" env default)

 

3. Lets work with docker engine CLI for management of the docker image

$ docker ps
$ docker info
$ docker --help
$ docker-machine ls
  NAME    ACTIVE DRIVER     STATE   URL                       SWARM DOCKER ERRORS
  default *      virtualbox Running tcp://192.168.99.100:2376       v1.12.3

 

4. Pull an image from docker hub and set it up locally

-- Verify the images that are downloaded, which  will be empty initially
$ docker images
-- Search for an image in docker hub and pull it
$ docker search ubuntu
$ docker pull ubuntu 
$ docker run ubuntu

 

5. Initialize and connect to bash for this image

-- Run a container and connect to its term
-- Also expose the ports and maps it to relevant exposed port in the image
$ docker run -it -p 52022:22 -p 52023:5900 -p 52021:80 ubuntu /bin/bash
-- Verify the version 
root@c:/# cat /etc/lsb-release
          apt-get update
          apt-get install -y build-essential openssh-server
          ip addr show
          service ssh restart

-- Exit from virtual host. This will also drop the changes if its uncommitted.
-- Keep this instance alive and go through the step 6 for persisting the changes.
root@c:/# exit

-- Get the IP from another console while keeping the image running 
$ docker ps
  CONTAINER ID IMAGE  COMMAND     CREATED       STATUS       PORTS NAMES
  dee57b8bba0e ubuntu "/bin/bash" 5 minutes ago Up 5 minutes 0.0.0.0:52022->22/tcp, 0.0.0.0:52021->80/tcp, 0.0.0.0:52023->5900/tcp sick_darwin 

$ docker inspect 
-- Look for the network configuration in the result
Obtained "IPAddress": "172.17.0.2"

 

6. Setup your new Ubuntu for vnc based desktop access

# apt-get update
-- Install the xfce desktop environment
# apt-get install -y build-essential xfonts-base xfce4 xfce4-goodies xubuntu-desktop
-- Install the vncserver
# apt-get install -y build-essential tightvncserver sudo vim openssh-server
# service ssh restart
-- Add a user for access to the instance
# adduser crusader
# usermod -aG sudo crusader
# su crusader
-- Initialize the VNC server for access
# export USER=crusader
# vncserver -geometry 1440x900 -rfbport 5900
# ps -eaf | grep vnc

 

7. Commit, persist and manage the image changes

-- Makes sure you commit the changes to docker and add a tag to it.
$ docker commit <container_id> vishwakarmarhl/ubshinydev:v01

-- Run a container and connect to its term
$ docker run -it -p 52022:22 -p 52023:5900 -p 52021:80 vishwakarmarhl/ubshinydev:v01 /bin/bash

-- Run the committed container image as a daemon, restart sshd and open bash
$ docker run -d -p 52022:22 -p 52023:5900 -p 52021:80 vishwakarmarhl/ubshinydev:v01 /bin/sh -c "while true; do echo hello world; sleep 10; done"
$ docker exec -it <container_id> /bin/bash
  # service ssh restart
 
-- Now you shoule be able to connect to the instance from the host
$ ssh -p 52022 crusader@192.168.99.100

-- Stop a container
$ docker stop

-- Remove Image by name. This will permanently delete your image
$ docker rmi -f ubuntu

 

8. Push Image to docker hub

Docker Hub Link : https://hub.docker.com/u/vishwakarmarhl

$ docker images
$ docker commit 162f8f8c5f19  vishwakarmarhl/ubunitydesk:v01
$ docker login
$ docker push vishwakarmarhl/ubunitydesk

-- Pull the images from docker hub
$ docker pull vishwakarmarhl/ubunitydesk

You should make sure you commit the changes done on this instance to the docker repository for persistence. This will be used to share at the docker hub repository.

 

9. Dockerfile for similar setup on Github

Download the docker file from the provided github link

Github Link: https://github.com/vishwakarmarhl/dockers/blob/master/Xubuntu-16-Desk-DockerFile

-- Build and run the docker container
$ docker build -t vishwakarmarhl/ubunitydesk:v01 . -f DockerFile 
$ docker run -it -p 52022:22 -p 52023:5900 -p 52021:80 vishwakarmarhl/ubunitydesk:v01 /bin/bash

Here upon you can configure your machine with any package. Will continue to describe how to use this environment for development purposes. This may as well be my notes but helps all the time for a quick reference.

Agilefant for your Agile ways

What is Agilefant?

Agilefant is a lean transformation tool that empowers your organization to execute change faster.

Setup on AWS EC2 & RDS(Mysql) Service instance

Referenced from the guide at https://github.com/Agilefant/agilefant/wiki/Agilefant-installation-guide

MySql RDS service with the following credentials.

mysql -h awdb.xxxxxxx.us-west-2.rds.amazonaws.com -u agilefant -p'agilefant123' agilefant

Deployment: http://ec2-xxxx.us-west-2.compute.amazonaws.com/

1.) Use this guide to setup tomcat server

Tomcat setup and deployment

2.) Setup the Database

Connect to your database

create database agilefant;
grant all on agilefant.* to agilefant@'%' identified by 'agilefant123';
exit;

 

3.) Configure the DB connection in Agilefant

Edit /WEB-INF/agilefant.conf in the agilefant.war package as

database {
 jndi-name = "jdbc/agilefant"
 driver-class = "com.mysql.jdbc.Driver"
 username = "agilefant"
 password = "agilefant123"
 url = "jdbc:mysql://awdb.xxxxxxx.us-west-2.rds.amazonaws.com:3306/agilefant?relaxAutoCommit=true&autoReconnect=true&useUnicode=true&characterEncoding=utf-8&autoReconnectForPools=true"
 }

 

4.) Start the server and verify the app

http://ec2-xxxx.us-west-2.compute.amazonaws.com/agilefant
N.B.! The username is admin and the password is secret.