Docker series 01_Docker introduction + installation

1. Overview of Docker

1. Why does Docker appear?

When publishing a project, release it with the environment, not just one jar package.
Docker means that when the project is released, it can be released with the environment, such as: (jar + (Redis, ES, Hadoop...))
Now: development, packaging and deployment are online, and a set of processes is completed.

Docker's solution process:
Java - jar (environment) - package the project with the environment (image) - (Docker warehouse: store) - download the image we released - just run it directly.
Docker idea: Provide server utilization through isolation mechanism.
Docker: Compared with virtual machines, it is very lightweight and only has some of the most core environments.
Docker: It is developed based on the Go language.

2. What can Docker do?

Containerization technology: not a complete operating system. Containers include operating environments and applications, run directly on the operating system, and can fully utilize the operating system's resources.

Compare the difference between virtual machine technology and Docker:

  • A traditional virtual machine virtualizes a piece of hardware, runs a complete operating system, and then installs and runs software on this system.
  • Docker, the application in the container runs directly on the host machine, the container does not have its own kernel, nor does it virtualize our hardware, so it is relatively lightweight. And each container is isolated from each other.
    insert image description here

insert image description here

3. DevOps (development, operation and maintenance)

Faster application delivery and deployment
Traditional: a bunch of help documentation, installer
Docker: one-click run, package image, release test

Easier upgrade and scaling
After using Docker, our deployment is like building blocks The
project is packaged as an image to expand the server

Simpler system operation and maintenance
After containerization, our development and test environments are highly consistent

More efficient utilization of computing resources
Docker is a kernel-level virtualization that can run many container instances on a physical machine

Second, the installation of Docker

1. The basic composition of Docker

insert image description here
Image : A Docker image is like a template through which container services can be created. tomcat image->run->tomcat01 container (providing server), multiple containers can be created through this image (the final server runs or the project runs in the container).

Container : Docker uses container technology to independently run one or a group of applications and create them through images. This container can be understood as a simple linux system.

Repository : A place to store images. Divided into public repositories and private repositories.

2. Docker installation (Ubuntu)

Docker is officially installed on ubuntu

Install the latest official version of Docker:
uninstall the old version first:

 sudo apt-get remove docker docker-engine docker.io containerd runc

Upgrade apk tools to support https library:

 sudo apt-get update
 sudo apt-get install \
    ca-certificates \
    curl \
    gnupg \
    lsb-release

Add official GPG key:

 curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg

Configure to use the stable version:

 echo \
  "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu \
  $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

Install Docker:

sudo apt-get update
 sudo apt-get install docker-ce docker-ce-cli containerd.io

Check the version after successful installation:

docker -v

insert image description here

Verify installation status:

 sudo docker run hello-world

insert image description here
Check out this hello world image:

docker images

insert image description here

3. Uninstall Docker

Uninstall dependencies:

 sudo apt-get purge docker-ce docker-ce-cli containerd.io

Delete resource:

 sudo rm -rf /var/lib/docker
 sudo rm -rf /var/lib/containerd

where /var/lib/dockeris the default working path of Docker

3. Run process and Docker principle

insert image description here

1. The underlying principle of Docker

How does Docker work?

Docker is a system with Client-Server structure. The Docker daemon runs on the host and is accessed from the client through Socket.
DockerServer receives the command from Docker-Client and executes this command.
insert image description here

Why is Docker faster than VM?
1. Docker has fewer abstraction layers than virtual machines.
insert image description here
2. Docker uses the kernel of the host machine, and the VM needs the Guest OS.
Therefore, when creating a new container, Docker does not need to reload an operating system kernel like a virtual machine, avoiding booting. The virtual machine is loaded with the Guest OS, in minutes, while docker is in seconds.

Guess you like

Origin blog.csdn.net/wxfighting/article/details/123946404