Introduction to docker installing docker

Posted by akdrmeb on Fri, 14 Jan 2022 06:51:26 +0100

Introduction to docker (I) installing docker

Source of Docker

It was initiated and officially named by dotCloud company, but the enterprise is small and has insufficient influence, so when it is about to lose its hold, it began to eat a hundred meals - open source. If you don't open it, it's amazing. More and more IT engineers found the advantages of Docker, and then flocked to join the Docker open source community.

Docker overview

What is Docker?

We've all used virtual machines. Virtual machine is to install a software in the operating system, and then simulate one or more "sub computers" through this software, such as VMWare.

On these virtual computers, I can also run programs. If I want, I can virtual many "sub computers" and open QQ on them. Moreover, the "sub computers" are isolated from each other and do not affect each other.

Virtual machine belongs to virtualization technology, and Docker also belongs to virtualization technology, but it is a lightweight virtualization.

Why is it lightweight virtualization? The container starts very quickly, completes in a few seconds, and has a very high utilization of resources (a host can run thousands of Docker containers at the same time). In addition, it takes up very little space, which is at the process level. Virtual machines generally need several GB - tens of GB, while containers are only MB or even KB.

linux

Dokcer

Highlight: Docker itself is not a container. It is just a tool for creating containers and an engine for applying containers.

Role of Docker

Let's take a look at the two slogans of docker:

slogan

  • “Build, Ship and Run”. Build, deliver, run.
  • “Buidl onceļ¼ŒRun anywhere”. Once built, it can be used anywhere.

For example, the company has a project to deploy the 87 server. It took half a day to install jdk, mysql, redis and rabbitmq on the 87 server, Successfully deployed online.

After a month, for some reason, the project will redeploy the server on 86. According to the previous method, only jdk, mysql One stop deployment.

The docker method is to package the programs, libraries, resources, configuration files, environment variables, etc. required for the operation of various containers into a docker image, put it into the docker warehouse, and use it when you need it.

Docker installation

Basic composition of Docker

  • image:

    The docker image is equivalent to a template through which container services can be created

    Example: Tomcat image = > Run = > tomcat01 container (providing server). Multiple Tomcat containers can be created through this Tomcat image.

  • container

    docker uses container technology to run one or a group of applications independently and create them through image.

    There are basic commands such as start, stop and delete.

    For the time being, consider it as a simple version of linux system.

  • repository

    The warehouse is where the images are stored

    Like git, it is divided into public warehouse and private warehouse

    Official: Docker Hub (extranet)

    Alicloud (configuring image acceleration), similar to maven configuring alicloud image acceleration

Install Docker

Environmental preparation

  1. centos7

  2. Kernel above 3.10

    [root@izbp1h615wcf61lkfqrqk2z ~]# uname -r
    3.10.0-514.26.2.el7.x86_64
    

install

#1. Uninstall the old docker version
sudo yum remove docker \
                  docker-client \
                  docker-client-latest \
                  docker-common \
                  docker-latest \
                  docker-latest-logrotate \
                  docker-logrotate \
                  docker-engine
#2. Install the required installation package
sudo yum install -y yum-utils

#3. Set the warehouse of the image
sudo yum-config-manager \
    --add-repo \
    https://download.docker.com/linux/centos/docker-ce.repo # default foreign

sudo yum-config-manager \
    --add-repo \
    http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo # recommends Alibaba cloud
# 4. Update the yum package index
yum makecache fast
#5. Install docker CE community version ee enterprise version related to docker
sudo yum install docker-ce docker-ce-cli containerd.io
#6. Start docker
sudo systemctl start docker
#7. Use docker version to check whether the installation is successful
#8. Test hello world
sudo docker run hello-world
#9. Check whether the hello world image is pull ed
docker images

Delete docker

#Delete docker
sudo yum remove docker-ce docker-ce-cli containerd.io
sudo rm -rf /var/lib/docker

Topics: Docker