Install Docker
Docker is divided into two major versions, CE and EE. CE stands for Community Edition (free), EE stands for Enterprise Edition, emphasizing security and paying for use.
Docker CE is divided into three update channels: stable, test and nightly.
We can install on CentOS, Ubuntu, Windows, MacOS, but the market basically chooses
Install Docker on CentOS
Docker CE supports the 64-bit version of CentOS 7, and requires a kernel version not lower than 3.10. CentOS 7 meets the minimum kernel requirements, so we install Docker on CentOS 7.
So it must be CentOS7, if it is lower than this version, there will be problems! ! !
1. Uninstall (optional)
If you have installed an old version of Docker before, you can use the following command to uninstall it:
yum remove docker \
docker-client \
docker-client-latest \
docker-common \
docker-latest \
docker-latest-logrotate \
docker-logrotate \
docker-selinux \
docker-engine-selinux \
docker-engine \
docker-ce
2. Install the yum tool
First of all, you need to connect the virtual machine to the Internet and install the yum tool
yum install -y yum-utils \
device-mapper-persistent-data \
lvm2 --skip-broken
3. Update the local mirror source
The default is to use the image of Alibaba Cloud, set the docker image source
yum-config-manager \
--add-repo \
https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
sed -i 's/download.docker.com/mirrors.aliyun.com\/docker-ce/g' /etc/yum.repos.d/docker-ce.repo
yum makecache fast
4. Install docker
It may take a long time, so be sure to perform step 3 first, and it can be much faster with a mirror image!
yum install -y docker-ce
In this way, docker has been installed! ! !
5. Precautions Turn off the firewall (important!!!)
Docker applications need to use various ports, and modify the firewall settings one by one. It is very troublesome, so it is recommended that you close the firewall directly!
Before starting docker, be sure to close the firewall! !
# 关闭
sudo systemctl stop firewalld
# 禁止开机启动防火墙
sudo systemctl disable firewalld
查看防火墙的状态(确保是不是真的关闭了!)
Display Active: inactive (dead) means closed!
Use of Docker
1. Start docker by command
Start the docker service
sudo systemctl start docker
stop docker service
systemctl stop docker
Restart the docker service
sudo systemctl restart docker
2. Enter the command to view the docker version
Used to judge docker
docker -v
3. Configure mirror acceleration
The network speed of docker's official mirror warehouse is poor (just like when we visit github), we need to set up a domestic mirror service, and Alibaba Cloud is the first choice!
Complete docker image acceleration configuration
sudo mkdir -p /etc/docker
sudo tee /etc/docker/daemon.json <<-'EOF'
{
"registry-mirrors": ["https://9bugzlv8.mirror.aliyuncs.com"]
}
EOF
sudo systemctl daemon-reload
sudo systemctl restart docker