Docker (1) opening: Docker introduction, installation, image acceleration

1. What is Docker

Insert picture description here

1.1 Introduction

Docker is an open source application container engine that allows developers to package their applications and dependencies into a portable image, and then publish it to any popular Linux or Windows machine, which can also be virtualized. Containers use the sandbox mechanism completely, and there will be no interfaces between them.

1.2 Application scenarios

  • Automated packaging and publishing of web applications
  • Automated testing and continuous integration, release
  • Deploy and adjust databases or other background applications in a service-oriented environment

Using Docker can achieve the consistency of the development environment of developers, the test environment of testers, and the production environment of operation and maintenance personnel.

Docker borrows the concept of standard containers. Standard containers transport goods all over the world. Docker applies this model to its own design
. The only difference is that containers transport goods, while Docker transports software .

1.3 Container

  • Flexible: Even the most complex applications can be containerized.
  • Lightweight: The container utilizes and shares the host kernel.
  • Interchangeable: You can deploy updates and upgrades instantly.
  • Portable: You can build locally, deploy to the cloud, and run anywhere.
  • Scalable: You can add and distribute container copies automatically.
  • Stackable: You can stack services vertically and instantly.

2. The difference between Docker and virtual machine

Insert picture description here

Traditional virtual machine Docker container
Disk usage From a few GB to dozens of GB From a few GB to dozens of GB
CPU memory usage Virtual operating system is very CPU and memory intensive Docker engine occupies very low
Start speed (From booting to running the project) a few minutes (From opening the container to running the project) a few seconds
Installation management Need specialized operation and maintenance technology Easy to install and manage
Application deployment Every deployment takes time and effort Easy and simple from the second deployment
Coupling Multiple application services are installed together and easily affect each other Each application serves a container to achieve isolation
System dependence Fives Needs the same or similar kernel, currently recommended is Linux

3. The core of Docker

Insert picture description here

  • Mirror: A mirror represents an application environment, which is a read-only file, such as mysql mirror, tomcat mirror, nginx mirror, etc.
  • Container: Each time the image is run, a container is generated, which is the running image, which is characterized by readable and writable
  • Warehouse: The location used to store the mirror, similar to the maven warehouse, but also the location of the mirror download and upload
  • dockerFile: docker generates a mirror configuration file, which is used to write some configurations of custom mirrors
  • tar: A file packaged for the image, which can be restored to the image in the future

4. Docker installation and startup

4.1 Docker installation

# 1、yum 包更新到最新
sudo yum update

# 2、作用:安装需要的软件包, yum-util 提供yum-config-manager功能,另外两个是devicemapper驱动依
赖的
sudo yum install -y yum-utils device-mapper-persistent-data lvm2

# 3、 设置yum源
# 3.1、方案一:使用ustc的
sudo yum-config-manager --add-repo http://mirrors.ustc.edu.cn/docker-ce/linux/centos/docker-ce.repo
# 3.2、方案二:使用阿里云(我这里用的阿里云)
sudo yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo

# 4、 安装docker;出现输入的界面都按 y
sudo yum install -y docker-ce

# 5、 查看docker版本
docker -v

4.2 Alibaba Cloud image acceleration

tip: ustc image acceleration moves: Docker (2) docker image acceleration

  1. Open container mirroring service
    Visit: https://help.aliyun.com/document_detail/60750.html
    Insert picture description here
  2. Go to the console.
    If it is not activated, follow the prompt steps to activate, as follows:

Click to activate

Insert picture description here

Click set password

Insert picture description here
Insert picture description here

  1. Mirror acceleration
点击镜像加速,这里就会有加速器地址和具体配置了

Insert picture description here

Then just make a json file configuration, the specific operations are as follows:

  • New json file
# 在etc目录下新建dorker文件夹:
mkdir /etc/docker
# 新建daemon.json文件并编辑
vi /etc/docker/daemon.json
  • Join in the daemon.json file
{
    
    
  "registry-mirrors": ["https://****.mirror.aliyuncs.com"]
}

Change here to your own acceleration address, then save and exit.

4.3 Docker start, stop, self-start

# 启动docker服务:
systemctl start docker
# 停止docker服务:
systemctl stop docker
# 重启docker服务:
systemctl restart docker
# 查看docker服务状态:
systemctl status docker
# 设置开机启动docker服务:
systemctl enable docker

I hope it can help everyone. If you don’t understand, please leave a comment below, and add Q:995062855 for technical exchange (same as WeChat)
That's all for today's sharing, we are going to move bricks.

Guess you like

Origin blog.csdn.net/weixin_42201180/article/details/107376128