Learn Docker Beginner

If you are in Software industry then you must use this phrase to prove yourself.

But I m sure after reading this tutorial you won’t be able to say this again.

1. What is Docker

Docker is a software platform designed to make it easier to create, deploy, and run applications by using containers. It allows developers to package up an application with all the parts it needs in a container, and then ship it out as one package

2. Virtual Machines vs. Docker

Virtual machines have a full OS with its own memory management installed with the associated overhead of virtual device drivers. Every guest OS runs as an individual entity from the host system.

On the other hand Docker containers are executed with the Docker engine rather than the hypervisor.


3. Introduction to Dockerfiles, images and containers

A Dockerfile is a text file that Docker reads in from top to bottom. It contains a bunch of instructions which informs Docker HOW the Docker image should get built.

A Docker image gets built by running a Docker command (which uses that Dockerfile)

A Docker container is a running instance of a Docker image

If you are too much into object oriented design then you can assume Docker image as a class, where as a Docker container is an instance of that class.

4. The Docker Hub

Docker Hub is a cloud-based repository in which Docker users and partners create, test, store and distribute container images which you can get from here.


Create and Run docker image

prerequisite : Must have docker installed in system


In this scenario, you’ll learn how to create a Docker Image for running a static HTML website using Nginx.
The scenario will explain how to build a Docker Image running Nginx with your HTML site.
The aim is to help you understand how to create and run Docker Images created by yourself.

create folder Docker and add file hello.html file into that.

<h1>Hello World</h1>

add one more file name Dockerfile make sure file name should be like this only without ant extension.

Open terminal and reach at folder Docker
vikash@vikash-pc:~/D-Drive/RKS_DOCS$ cd /home/vikash/D-Drive/RKS_DOCS/Docker/
vikash@vikash-pc:~/D-Drive/RKS_DOCS/Docker$ ls -lrt
total 8
-rw-rw-r-- 1 vikash vikash 20 Jan 27 16:03 Hello.html
-rw-rw-r-- 1 vikash vikash 49 Jan 27 16:04 Dockerfile

Step 1 – Create Dockerfile

Copy the below content in your Dockerfile for building your image.

Copy to EditorFROM nginx:alpine

COPY . /usr/share/nginx/html

The first line defines our base image.

The second line copies the content of the current directory into a particular location inside the container.

Step 2 – Build Docker Image
The Dockerfile is used by the Docker CLI build command. The build command executes each instruction within the Dockerfile. The result is a built Docker Image that can be launched and run your configured app. The build command takes in some different parameters.
The format is

docker build -t <build-directory>

The -t parameter allows you to specify a friendly name for the image and a tag, commonly used as a version number. This allows you to track built images and be confident about which version is being started.

sudo docker build -t webserver-image:v1 .


vikash@vikash-pc:~/D-Drive/RKS_DOCS/Docker$ sudo docker build -t webserver-image:v1 .
[sudo] password for vikash: 
Sending build context to Docker daemon  3.072kB
Step 1/2 : FROM nginx:alpine
alpine: Pulling from library/nginx
cd784148e348: Pull complete 
6e3058b2db8a: Pull complete 
7ca4d29669c1: Pull complete 
a14cf6997716: Pull complete 
Digest: sha256:385fbcf0f04621981df6c6f1abd896101eb61a439746ee2921b26abc78f45571
Status: Downloaded newer image for nginx:alpine
 ---> 315798907716
Step 2/2 : COPY . /usr/share/nginx/html
 ---> 6c54defc9f09
Successfully built 6c54defc9f09
Successfully tagged webserver-image:v1

As you can see in above output that above command executes all given steps in Dockerfile one by one.

You can view a list of all the images on the host using

sudo docker images

vikash@vikash-pc:~/D-Drive/RKS_DOCS/Docker$ sudo docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
webserver-image     v1                  6c54defc9f09        2 minutes ago       17.8MB
hello-world         latest              fce289e99eb9        3 weeks ago         1.84kB
nginx               alpine              315798907716        4 weeks ago         17.8MB

The built image will have the name webserver-image with a tag of v1.

Step 3 – Run

Launch our newly built image providing the friendly name and tag. As it’s a web server, bind port 80 to our host using the -p parameter.

docker run -d -p 80:80 webserver-image:v1

Once started, you’ll be able to access the results of port 80 via


You now have a static HTML website being served by Nginx.

330 total views, no views today

Install docker on Ubuntu

Step :1  

Open terminal using command Ctrl+T.

Step 2:

Update your existing list of packages.

sudo apt update

Step 3:

Install prerequisite packages which let apt use packages over HTTPS:

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

Step 4:

Add GPG key for the official Docker repository to your system:

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

Step 5:
Add the Docker repository to APT sources:

sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu bioni

Step 6:

Update the package database 

sudo apt update

Step 7:

Make sure you are about to install from the Docker repo instead of the default Ubuntu repo:

apt-cache policy docker-ce

You’ll see output like this, although the version number for Docker may be different:

Notice that docker-ce is not installed

Step 8:

Finally, install Docker:

sudo apt install docker-ce

Step 9:

Docker should now be installed, the daemon started, and the process enabled to start on boot. Check that it’s running:

sudo systemctl status docker

Installing Docker now gives you not just the Docker service (daemon) but also the docker command line utility,

Step 10:

To view system-wide information about Docker, use:

docker info

This will give you permission error so try with sudo you can check more on how to avoid using sudo everytime

sudo docker info

To check whether you can access and download images from Docker Hub, type:

Step 11:

sudo docker run hello-world

To see the images that have been downloaded to your computer, type:

sudo docker images

The output should look similar to the following:

The hello-world container you ran in the previous step is an example of a container that runs and exits after emitting a test message. Containers can be much more useful than that, and they can be interactive.

After using Docker for a while, you’ll have many active (running) and inactive containers on your computer. To view the active ones, use:

sudo docker ps

check latest one

sudo docker ps -l


To view all containers — active and inactive, run docker ps with the -a switch:

sudo docker ps -a

Thats all in terms of installing Docker and some basic commands.

333 total views, no views today

Template for API gateway creation using CI-CD

Below is the template which can be used for api gateway creation in AWS
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: >
  Application containing RestAPI for First

    Timeout: 30

  #s3 bucket name
    Type: String
    Description: Bucket to be used
    Default: lambda-deployment-d1

    Type: 'AWS::SSM::Parameter::Value<String>'
    Default: /<parameterPath>/EnvironmentName                        
    # /myDemo/d1/EnvironmentName

    Type: 'AWS::SSM::Parameter::Value<String>'
    Default: /<parameterPath>/StageName                             
    # /myDemo/d1/EnvironmentName

    Type: String
    Description: bucket prefix
    Default: first-project-api                                   
    # /myDemo/d1/EnvironmentName

    Type: 'AWS::SSM::Parameter::Value<String>'
    Default: /<parameterPath>/CertificateARN    
    # /myDemo/d1/CertificateARN

    Type: 'AWS::SSM::Parameter::Value<String>'
    Default: /<parameterPath>/DomainName        
    # /myDemo/d1/DomainName


    Type: AWS::IAM::Role                                            
    # https://serverless.com/framework/docs/providers/aws/guide/resources/
        Version: "2012-10-17"
        - Effect: "Allow"
            - "lambda.amazonaws.com"
          - "sts:AssumeRole"
      #policy name
      - PolicyName: "LambdaVpcPolicy"
          Version: "2012-10-17"
          - Effect: "Allow"
            - "logs:CreateLogGroup"
            - "logs:CreateLogStream"
            - "logs:PutLogEvents"
            - "ec2:CreateNetworkInterface"
            - "ec2:DescribeNetworkInterfaces"
            - "ec2:DeleteNetworkInterface"
            - "dynamodb:*"
            - "apigateway:*"
            Resource: "*"
  #creates api gateway using swagger.yml
    Type: AWS::Serverless::Api                 
    # https://docs.aws.amazon.com/serverless-alication-model/latest/developerguide/serverless-sam-template.html
      Name: !Join ['', [' first-rest-api-', !Ref EnvironmentName]]
      StageName: !Ref StageName
      # https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-transform.html
         # Fn::Transform specifies a macro to perform custom processing on part of a stack template. 
          Name: 'AWS::Include'
          # Replace <bucket> with your bucket name
            Location: !Join ['', [ 's3://',!Ref BucketName, '/',!Ref BucketPrefix, '/swagger.yaml'  ] ]

    Type: AWS::Serverless::Function 
    # https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-transform.html
    FunctionName: !Join ['', [ 'FirstRestAPIGetByItem-', !Ref EnvironmentName ] ]
      #python code base containg lambdas which process request
      CodeUri: First-rest-api/build/
      #lambda name and its method
      Handler: ItemByName.lambda_handler
      Runtime: python3.7
      #role of lambda
      Role: !GetAtt LambdaRoleForVPCResources.Arn
      #these are environment variable which are required for lambda
          First_TABLE:  !Join ['', [ 'Item-table-', !Ref EnvironmentName ] ]
        #listner of lambda fucntion ...this can be api kinesis or any aws service
        #type of service to subscribe
          Type: Api
            #name of service this is declared above
            RestApiId: !Ref FirstRestAPI
            #path to access api this is also maed to swagger.yml
            Path: /item
            #method type
            Method: post

    #done for static name creation --create name of api
    Type: 'AWS::ApiGateway::DomainName'
      CertificateArn: !Ref CertificateARN
      DomainName: !Join ['', ['first-api-', !Ref EnvironmentName, '.', !Ref DomainName]]
   #done for static name creation -- create maing for api
    Type: 'AWS::ApiGateway::BasePathMapping'
      BasePath: v1
      DomainName: !Ref ApiDomainName
      RestApiId: !Ref FirstRestAPI
      Stage: !Ref StageName

#generates output url for the generated services      

    Description: URL of API endpoint
    Value: !Join
    - ''
    - - https://
      - !Ref FirstRestAPI
      - '.execute-api.'
      - !Ref 'AWS::Region'
      - '.amazonaws.com/'
      - !Ref StageName
      - '/item'

   #shows details of all created api's
    Description: " Rest API Function ARN"
    Value: !GetAtt FirstRestAPIGetByItem.Arn

362 total views, 1 views today

Caused by: java.lang.ClassNotFoundException: javax.jms.JMSContext

I was also facing the same issue when I moved from spring-3.0 to spring-5.0 while using Tomcat-7 to deploy my application. I added below maven dependency in pom.xml file and it got resolved.
The root cause I found is, UserCredentialsConnectionFactoryAdapter class provided by spring-jms-5.0.2.RELEASE.jar was using JMSContext class internally. This class was not available in jms-1.1.jar which I was using with spring-jms-3.2.4.jar.
So I replaced jms-1.1.jar with javax.jms-api-2.0.1.jar
I would suggest you to add/upgrade your jms jar as mentioned above according to you spring version.
Hope this works!

994 total views, no views today

Hello World Nest js

Follow below URL for prerequisite i.e install NPM on your system


Step 1 : Create a new directory anywhere you want in your PC.

Step 2 : Open command prompt window and enter below command to execute.

D:Rakesh_kumar_SinghaniaIonicFrameWorkNestJs>npm i -g @nestjs/cli

this will get all dependency for your Nest Js project.

Step 3:  Generate new project using below command

D:Rakesh_kumar_SinghaniaIonicFrameWorkNestJs>npm new firstProject

Step 3: This command will ask for few parameters like below
just enter all required details as per your specifications.

D:Rakesh_kumar_SinghaniaIonicFrameWorkNestJs>nest new project

⚡️  Creating your Nest project...
🙌  We have to collect additional information:

? description : FirstProject
? version : 1.0.0
? author : rakeshkumar.singhania

💥  Thank you for your time!
This will also generate few files for you to start a new project and also ask for your preference between NPM or YARN.
Choose according to your need and project setup.
As I have used NPM so I have selected NPM as a build tool here.

Once process is completed your screen look like above screen with all settings.

219 total views, no views today

Configuration ‘prod’ could not be found


I am trying to serve the app via configuration for prod in Angular 6 using below command.

ng serve --configuration=prod

But it gives me below error :

Configuration 'prod' could not be found in project 'platform-ui'.

Error: Configuration 'prod' could not be found in project 'platform-ui'.

Solution :

If you look at your angular.json file, you’ll see that you have finer control over settings for each configuration.

Now look for serve tag in json

“serve”: {
“builder”: “@angular-devkit/build-angular:dev-server”,
“options”: {
“browserTarget”: “platform-ui:build”

and add configuration for your custom server like this :

“configurations”: {
“production”: {
“browserTarget”: “platform-ui:build:production”
“qa”: {
“browserTarget”: “platform-ui:build:qa”

now try to run below command again

ng serve --configuration=prod

201 total views, no views today

Get URL in angular 5

The Location class has prepareExternalUrl() that takes base href into account.

You can also try to inject 

constructor(@Inject(APP_BASE_HREF) href:string){}

It seems APP_BASE_HREF can’t be injected anymore without explicitly providing it.

PlatformLocation provides more details about the URL:   

PlatformLocation is a service available in Angular 5+ apps that makes it easy to interact with the current URL path.

PlatformLocation service can come-in really handy when coupled with the router to perform certain operations.

you can get URL like this.

constructor(platformLocation: PlatformLocation) {
console.log((platformLocation as any).location);
console.log((platformLocation as any).location.href);
console.log((platformLocation as any).location.origin);

191 total views, no views today

Create a new component in angular

If you are Not aware of basis environment set up and Hello world of angular please go through below links for the context.

1 . https://javaquicky.com/p/angular-456-set-up-environment.html
2 . https://javaquicky.com/2018/07/17/angular-5-hello-world-step-by-step/

Above links help us in creating ready made application which angular CLI provide us but now we want a component of our own.

Step 1:  

Creating a Custom Component

navigate to your folder structure where you want to create your custom component
and then run below command

ng g component customHelloWorld

like this :

ng g component customHelloWorld

This command will create your component and also it make sure to mark an entry in your app.module.ts file.

app.module.ts — This file holds all the source required by the project which include all the imports of the components.

below is the snapshot of generated files :

Beauty of command ng g component customHelloWorld is 

This command generated 4 for the component :

1 . HTML file of your component
2. Test file for your component
3. TS file for writing your logic.
4. CSS file for styling.

Step 2:  

Open auto generated file custom-hello-world.component.ts.

  selector: 'app-custom-hello-world',
  templateUrl: './custom-hello-world.component.html',
  styleUrls: ['./custom-hello-world.component.css']
export class CustomHelloWorldComponent implements OnInit {

  constructor() { }

  ngOnInit() {   

and and modify custom-hello-world.component.html according to your need.

  custom-hello-world works!

Below code is important in sense of mapping your HTML file and CSS file specific to this component.

  selector: 'app-custom-hello-world',
  templateUrl: './custom-hello-world.component.html',
  styleUrls: ['./custom-hello-world.component.css']

So whenever you use app-custom-hello-world selector in any of your HTML it will render the
HTML part of custom-hello-world.component.html.

Lets use app-custom-hello-world  selector tag in our app.component.html.

<!--The content below is only a placeholder and can be replaced.-->
<div style="text-align:center">
    Welcome to Custom component {{ title }}!

Start the server using

 ng serve

Hit on the url http://localhost:4200

Output :

179 total views, no views today

Angular 5 Hello world step by step

Step 1: Prerequisites

Install Node.js & npm


Install Angular CLI

Creating a new Angular app is a bit tedious job especially when you are new to Typescript as there will be lot of initial configurations involved. In order make it simpler Google came up with the utility called Angular CLI, using which we can create and manage our app from command line itself

In order to install Angular CLI open Node.js command prompt/command prompt and run the below command

npm install -g @angular/cli

Install Code Editor

There are multiple code editors available in market

1. Microsoft Visual Code Studio
2. Brackets
3. Notepad++,
4. Sublime Text

As I m Fond of eclipse so I have installed angular plugin in eclipse as Angular editor.

Step 2: Create Project

Lets build our First Angular 5 Hello World application

Create a new folder with folder name “Angular5HelloWorld” anywhere you want.

Open command prompt and navigate to the folder.

Use the ng new command to create our Hello World Angular Project ng new hello-world-app

Ng stands for aNGular. NG is a core module, and this module contains all the directives that comes built in with the AngularJS library file.

D:Rakesh_kumar_SinghaniaAngular5HelloWorld>ng new hello-world-app

In case you get error that ‘ng‘ is not recognized command

To solve that go to :

Control Panel > User accounts > Change my environmnet variables

and add the path to your AppDataRoamingnpm, in my case it was


Above command ng new helloworldapp creates a MAGIC…!!

This command add 1102 packages and all required dependencies for your first project.

Now your project ‘hello-world-app’ is successfully created.

Step 3: Run our first application

Navigate to your newly created project and run below command to run your application.

D:Rakesh_kumar_SinghaniaAngular5HelloWorldhello-world-app>ng serve

This command will start the server and will launch the default Angular Application build by Angular CLI.

If you see above screen after running command then congratulations everything is fine with your application and your are good to go.

Default url to launch application is : http://localhost:4200/

Step 4 :Output

Next :create a customize component

206 total views, no views today

TypeError: Cannot read property ‘thisCompilation’ of undefined

Follow these steps one by one  to resolve the error

npm i -g @angular/cli@latest
rm -rf node_modules / rd /s /q node_modules
npm cache clear --force
npm cache verify
npm install
npm uninstall webpack
npm install --save-dev --save-exact @angular/cli@latest

You might get below error also 


npm remove webpack -g

npm i webpack --save-dev

228 total views, no views today