Published on

Docker

Authors

Docker

  1. what is docker Docker is a platform for building, running and shipping applications.

Docker is a set of platform as a service products that use OS-level virtualization to deliver software in packages called containers. Containers are isolated from one another and bundle their own software, libraries and configuration files; they can communicate with each other through well-defined channels. Wikipedia

Note: docker help us consistently build, run and ship applications

  1. Virtual Machines vs Containers

Container is an isolated environment for running an application

  • allow running multiple apps in isolation
  • are lightweight
  • use OS of the host
  • start quickly
  • need less hardware resources

Virtual Machine is an abstriction of a machine (physical hardware)

  1. Architecture of Docker

Containers share the kernal of os Akerna managmes applications and hardware resources container_vs_virtual_machines

  1. Installing Docker you can visit: https://docs.docker.com/get-docker/ to install docker on your Operating system

  2. Development Workflow

To build and run your app by docker, you need to make Dockerfile, it's an plain text file that contain the instruction for docker

  1. Docker in action

Instructions for deploying app

  • Start with an OS

  • Install node

  • Copy app files

  • Rung node app.js

  • Example:

    • create folder hello-docker

    • in folder create file app.js

    • in file set the following code:

      console.log('Hello, Docker');
      
      • create Dockerfile (width captal D only) in the root of your app
      • set the following instruction in the file:
      FROM node:alpine
      COPY . /app
      WORKDIR /app
      
      CMD node app.js
      
      • to build and run your app by docker, open terminal in the folder that contain you app and run the following commands
        1. docker build -t hello-docker .
        2. you can check you images created by: docker images or docker image ls
        3. docker run hello-docker