Sunday, May 21, 2017

Docker Commands

Docker commands

  • Version, Info …

>docker version

>docker info

  • Search

Searches images in docker registry.

docker search <Image Name>

>docker search ubuntu

  • Images

List all the downloaded images

>docker images

>docker ps –a

    -a – show all

    -l – show last

  • Pull

Pulls the image if it is not available locally. It runs automatically by docker run.

>docker pull <Image name>

  • Run

Docker run starts the container by giving the image name a process to run in that container. The container stops when the main process stops. It automatically pulls the image.

>docker run –ti <image>:[<version/latest>] <program to run>

    -ti – terminal interactive

    -d – detach – will run in the background

    -c – command

    -p – port. eg. –p 1234:3456 Expose port 1234 on the inside of the container to the outside of container as port 3456.

          docker run –p <outside-port>:<inside-port>/protocol(tcp/udp)

    -v – volume

         docker run –v <path in host>:<inside the container path>

        >docker run –ti –v /home/docker/example:/shared-folder ubuntu bash

    --name – name of the container

    --memory – maximum allowed memory

    --cpu-shares – relative to other containers

    --cpu-quota – limit it

    --link <Name of container> – for communication between two containers. It automatically assigns a hostname. Link can break when containers restart.

    --net==<Network name>

    --volumes-from <Name of the container that we want to use the volume> – To share data/file between containers.

  • Commit and Tag

>docker commit <id of the container>

Tagging gives images names

>docker tag <id received from commit> <Image/Tag name>

     or

>docker commit <Name of the container> <Image/Tag name>

  • Build

Creates an image for the docker file

    >docker build –t <Name of tag> .

The (.) shows the docker file in here. Otherwise need to pass the path of docker file.

  • Push

Upload a tagged image to docker hub

    >docker push <Tag name>

  • Attach

>docker attach <Container name>

  • Exec

>docker exec

Starts another process in an existing container.

  • Logs

Docker logs keep the output of the container.

>docker logs <Container name or ID>

  • Stopping and Removing

>docker kill <Container name/ID>

>docker rm <Container name/ID>

  • Network

>docker network create <Network name>

  • Clean Up

>docker rmi <Image name/Image ID>:<Tag>

  • Login

Login in to docker hub

Monday, February 27, 2017

Modules & Classes in ES6

Modules:
Module help us with encapsulation by exposing from a given file the pieces we want to be access publically. An export statement will be used for that.

export {
     show: someFunc()
}


Then an import statement is used to import that piece:

import { show } from './my-file.js'

Sunday, February 19, 2017

ES6 Features

New features in ES6 are:

  • let, const and Block Scoping,
  • Arrow Functions =>,
  • Default Function Parameters,
  • Rest and Spread,
  • Object Literal Extensions,
  • for…of Loops,
  • Octal and Binary Literals,
  • Template Literals
  • Destructuring

let, const and Block Scoping:

let

let statement allows to declare variables that are limited in scope to the block, statement or expression on which it is used.

Arrow Functions =>

Arrow functions are anonymous functions with shorter syntax than a function.

Arrow function without any arguments.

var geEmployee = () => console.log(‘Employee Name’);

Default Function Parameters:

var getEmployee = function(id = 101){
     console.log(id)
};
getEmployee();

Thanks,
Bimal