Giter Club home page Giter Club logo

hello-docker's Introduction

Docker

Docker is an open platform for developing, shipping, and running applications. Docker enables you to separate your applications from your infrastructure so you can deliver software quickly. With Docker, you can manage your infrastructure in the same ways you manage your applications. By taking advantage of Docker’s methodologies for shipping, testing, and deploying code quickly, you can significantly reduce the delay between writing code and running it in production.

Docker provides the ability to package and run an application in a loosely isolated environment called a container. The isolation and security allow you to run many containers simultaneously on a given host. Containers are lightweight because they don’t need the extra load of a hypervisor, but run directly within the host machine’s kernel. This means you can run more containers on a given hardware combination than if you were using virtual machines. You can even run Docker containers within host machines that are actually virtual machines!

Docker - Overview

Docker uses features of Linux kernel:

  • Namespaces: each resource (Pid, Network, InterProcess Communication, Mount, Unix Timesharing System) of a container runs in an isolated area. (what a process can see)
  • Control groups: limits an application to a specific set of resources (Memory, CPU, Blkio, Cpuacct, Cpuset, Devices, Net_prio, Freezer). (what a process can use)
  • Union file systems: are file systems that operate by creating layers, making them very lightweight and fast.

Docker - Overview

Docker is a set of technologies, for example:

  • Docker Engine: a daemon for creating and executing Docker image.
  • Docker Hub: a public registry for Docker image.
  • Docker Compose: a tool for defining and running multi-container Docker applications.
  • Docker Swarm: is a clustering and scheduling tool for Docker containers.

N|Solid Docker - Architecture

Container

A container is a standard unit of software that packages up code and all its dependencies so the application runs quickly and reliably from one computing environment to another. A Docker container image is a lightweight, standalone, executable package of software that includes everything needed to run an application: code, runtime, system tools, system libraries and settings. Docker - What Container

Docker Image

Docker image is created in layers and these layers are used to create other images. This way makes the push / pull more efficient in the registry. Testing Image Layer and Creating Image.

Container x Virtual Machines

Docker - Get Started

Setting Up Docker on VM

Setting Up VM

  • Download VirtualBox
  • Download Linux image CentOS-7-x86_64-Minimal-1810.iso
  • Install VirtualBox and run
  • Create a VirtualBox image
    • New
    • Name: Docker/ Type: Linux/ Type: Red Hat 64-bit [Next]
    • Memory size: 1024MB [Next]
    • Create a virtual hard disk now [Next]
    • VDI [Next]
    • Dynamically allocated [Next]
    • Size 50GB [Create]
  • Run Docker image
    • Select Docker and start
    • In the first time, select the .iso file to install the OS
    • After the OS load, choose "Install CentOS 7"
  • Load OS
  • Update Repository
$ su yum update

1- Install required packages.

$ sudo yum install -y yum-utils \
  device-mapper-persistent-data \
  lvm2

2- Use the following command to set up the stable repository.

$ sudo yum-config-manager \
    --add-repo \
    https://download.docker.com/linux/centos/docker-ce.repo

3- Install the latest version of Docker CE

$ sudo yum install docker-ce

4- Start Docker.

$ sudo systemctl start docker

5- Verify that docker is installed correctly by running the hello-world image.

$ sudo docker run hello-world

1- Create/add user to the docker group

$ useradd docker -g docker

2- Configure Docker to start on boot

$ sudo systemctl enable docker

Common Commands

  • docker images: list images.
  • docker pull IMAGE_NAME: pull an image or a repository from a registry.
  • docker push IMAGE_NAME: push an image or a repository from a registry.
  • docker build -t IMAGE_NAME .: build an image from a Dockerfile.
  • docker tag SOURCE_IMAGE TARGET_IMAGE: create a tag TARGET_IMAGE that refers to SOURCE_IMAGE.
  • docker ps: list containers running.
  • docker ps -a: list containers.
  • docker run -it IMAGE_NAME: run container in iterative mode.
  • docker start CONTAINER_ID: start container.
  • docker stop CONTAINER_ID: stop container.
  • docker rm CONTAINER_ID: remove container.
  • docker container prune: remove all stopped containers.
  • docker rmi IMAGE_NAME: remove image.

References

Docker Documentation

Play with Docker Classroom

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.