Installing Docker under Linux (CentOS7) (super detailed)

1. Introduction to Docker

  • Docker is divided into two major versions: CE and EE.
  • CE: Community version, free, support period is 7 months
  • EE: Enterprise version, which emphasizes security, is paid for use, and has a 24-month support period.

1. In the days without Docker

        In the previous development era, developers delivered the war they developed to the operation and maintenance personnel. In order to deploy the war to the server and ensure that it can run, the operation and maintenance personnel must set up a good operating environment on the server!
        But The problem this brings is that if the development environment and the deployment environment are inconsistent (such as version), it will cause the problem of being unable to run on the server environment. You will often hear complaints from developers saying: "It works fine on my machine"!
In order to solve this problem and allow these programs to execute smoothly in the deployment environment, the development team must not only deliver the application code , you must also prepare complete deployment files so that the operation and maintenance team can deploy the application successfully. Even so, deployment failures often occur on the server.

Therefore, we often see weird things like "programmers worshiping the server". In order to maintain the peace of the universe and for the unity of developers and operation and maintenance personnel, docker came into being!

2. What is Docker?


        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 completely use the sandbox mechanism and will not have any interfaces with each other. (Excerpted from Baidu Encyclopedia)

3. What can Docker do?


The role of docker:

        To put it simply, you package your business code and deployment environment together. The packaged stuff is called a "mirror", and then you just hand the "mirror" directly to the operation and maintenance personnel, and the operation and maintenance personnel get it. The "mirror" given to him is equivalent to getting the business code and deployment environment at the same time. The operation and maintenance personnel no longer need to download any environment packages themselves (even the operation and maintenance personnel do not need it, and DevOps came into being). That is
        , It is said that docker can ensure that the development environment and the deployment environment are absolutely consistent! In the case of using docker, as long as the developer can ensure that the application can run normally during the development phase, then after the project is delivered to the operation and maintenance personnel, it will also be guaranteed in the deployment environment. It works!
        In addition, horizontal expansion (cluster) is also very convenient when using docker.

If you want to understand Docker, just read its two slogans. The first sentence is "Build, Ship and Run".

         In other words, "build, send, run", the three pillars. For example: I came to a vacant land and wanted to build a house, so I moved stones, chopped wood, and drew drawings. After a while, I finally built the house. As a result, I lived there for a while and wanted to move to another place. Go to a clearing. At this time, according to the previous methods, I can only move stones, chop wood, draw drawings, and build houses again. However, an old witch came and taught me a magic. This kind of magic can make a copy of the house I built, make it into a "mirror image", and put it in my backpack. I take this bag and go to another open space, and use this "mirror image" to copy a house. , place it over there, and move in with your bags.

The second slogan of Docker is: "Build once, Run anywhere", build once, run anywhere! ! ! !

2. Docker installation

The following takes the installation of the CE (Community Edition) version as an example

1. Be sure to configure Alibaba’s yum source so that the speed of installing Docker will not be too slow.

# 1、备份备份官方的原yum源的配置
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup


# 2、下载Centos-7.repo文件
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo

# 注意:部分小伙伴可能没有安装wget,需要先安装wget,或者用下面的命令下载repo文件
curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo

# 3、清除yum缓存
yum clean all

# 4、缓存阿里云源
yum makecache

# 5、测试阿里云源 
yum list



2. Uninstall the old version of Docker. The old version of the Docker program is called Docker or Docker-engine. If it has been installed in the system before, then uninstall it, along with its dependencies of course!

yum remove docker \
docker-client \
docker-client-latest \
docker-common \
docker-latest \
docker-latest-logrotate \
docker-selinux \
docker-logrotate \
docker-engine-selinux\
docker-engine

The execution results are as follows:

 

3. Install the required packages

yum install -y yum-utils device-mapper-persistent-data lw2

The execution results are as follows:

 

4. Use the following commands to build a stable warehouse

yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo

The execution results are as follows:

 

5. Officially install Docker-ce. The installation will take a little longer, please wait patiently.

yum -y install docker-ce

The execution results are as follows:

6. Start Docker 

systemctl start docker

Don't be nervous, there will be no display effect after executing here.

7. Check Docker startup status

systemctl status docker

The execution results are as follows:

8. The installation is successful, check the Docker version

docker -v

 9. Bonus command: Stop Docker

systemctl stop docker

The installation is over now, friends who think it is good, please be careful, learn together and make progress together!

Guess you like

Origin blog.csdn.net/FebruaryQ/article/details/131840954