1. What is Docker?
Before using docker, we should first clarify what kind of problem docker exists to solve.
1. Deploy your application on another computer
For example, if you write a web application, you can debug it locally without any problem. However, if you want to deploy this web application to a remote server, or send a message to your friend, first of all, another computer wants to run your For web applications, the other computer needs to be configured such as database, web server, necessary plug-ins, operating environment, etc., and there is no guarantee that the software can run completely. Even if the same operating system is configured, it will be caused by version problems. web application not working
To solve this problem and make the application run normally on another computer, we need to simulate the same running environment as our local. At this time, we may think of virtual machines, but virtual machines must not only simulate software, but also Simulate hardware, run the entire operating system, the memory usage is high, and the program performance will also be affected, which is very bloated
2. Docker solves the deployment problem
At this time, docker comes in handy,
Docker is very similar in concept to virtual machines, but it is much more lightweight and flexible. Docker does not simulate the underlying hardware, but only provides a completely isolated operating environment for each application . We can configure the configuration in each environment . Different tools and software, and each environment does not affect each other at all, and this environment, in docker, is also called a container .
2. Three important concepts in Docker
1. Image / Mirror
You can think of an image as a snapshot of a virtual machine that contains your application and all the libraries it needs to run
2, Container / Container
Through mirroring, we can create many different containers . The containers here are like running virtual machines, which run your application, and each container runs independently.
The image is like the installation package of your app. You can install many software through this installation package. Each software is a container. They run independently and do not interfere with each other.
3、Dockerfile
Dockerfile is an automated script. It is mainly used to create our image. This process is like installing an operating system and software in a virtual machine. Dockerfile creates an image and configures applications in the image through a script. and operating environment
4. Registry / Warehouse
We can upload our own image to a remote repository, Docker Hub , you should know what this is doing by listening to the name, it is similar to github, but GitHub is to save our code, and Docker Hub is to save our image
3. Docker installation
1. Check the Linux version
Docker requires a kernel above 3.10
uname -r
2. Uninstall the old version of docker
If you have not installed docker before, you can skip this step
sudo yum remove docker \
docker-client \
docker-client-latest \
docker-common \
docker-latest \
docker-latest-logrotate \
docker-logrotate \
docker-selinux \
docker-engine-selinux \
docker-engine
3. Install and download the tools that Docker depends on
sudo yum install -y yum-utils device-mapper-persistent-data lvm2
4. Add the software source of Alibaba Cloud
sudo yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
sudo yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
5. Update the yum cache (in order to ensure that the required services can be updated and downloaded: such as docker)
sudo yum makecache timer
6. Start installing Docker
sudo yum -y install docker-ce
7. Start docker
sudo systemctl start docker
7.1 If an error is reported
(1) View installed packages:
yum list installed | grep docker
(2) Delete the installed Docker-related packages:
yum -y remove docker.x86_64
yum -y remove docker-client.x86_64
yum -y remove docker-common.x86_64
8. Check if Docker is successful
docker info
9. Self-start at boot
sudo systemctl enable docker