Docker

1. What is docker?

A platform for building, running, and shipping applications.

Problem: Code work in your laptop -> didn't work somewhere

Reasons:

  • One or more files missing

  • Software version mismatch

  • Difference configuration settings

With docker you can do it.

  • Package Your machine

  • Remove machine and code in 1 line code

docker-compose up
docker-compose down

Consistency

2. Virtual Machines vs Containers

Container : An isolated environment for running an application.

Virtual Machines: An abstraction of a machine. You can run many machine like window, linux in mac devices by using a tool called hypervisor.

Hypervisor

  • VirtualBox

  • VMware

  • Hyper-V (window only)

Problems

  • Each VM needs a full-blown OS

  • Slow to start

  • Resource intensive

Containers

  • Allow running multiple apps in isolation

  • Are lightweight

  • Use OS of the host

  • Start quickly

  • Need less hardware resources

You want to use container to contribute your package to users.

3. Architecture of Docker

  • Client - Server Architecture

Kernel is machine of the car.

4. Installing Docker

  • Installing docker Hub from https://docs.docker.com

    • Requirements

    • Error W2L installation incomplete -> Download Linux kernel

5. Development Workflow

Application (Docker file) --> Image --> Container

Image

  • A cut-down OS

  • A runtime environment (eg Node)

  • Application files

  • Third-party libraries

  • Environment variables

Dev -> Registry -> Test

6. Docker in Action

Code:

mkdir hello-docker

cd hello-docker

Edit in VS code

Create Dockerfile -> install extension

Play with docker

  • Login docker

  • Add new instance

  • node -> not found

  • docker version

  • docker pull codewithmosh/hello-docker

  • docker image ls

  • docker run hello-docker

7. The linux command line

Because Docker is built on basic Linux concepts

8. Linux distributions

Open source

Distros

  • Ubuntu

  • Debian

  • Alpine

  • Fedora

  • CentOS

--> Same command

9. Running Linux

hub.docker.com --> search ubuntu -> download image

docker pull ubuntu // docker run ubuntu

docker ps - a

docker run -it ubuntu

Shell prompt :

10. Managing your packages

Package Managers

  • npm

  • yaml

  • pip ...

11. Linux File system

Tree systems

  • /

    • bin

    • root

    • home

    • etc //editable text configuration

12. Navigating the File System

13. Manipulating Files and Directories

14. Viewing and Editing file

15. Redirection

Last updated

Was this helpful?