1. 项目目标
(1)安装docker
(2)安装docker-compose
(3)配置镜像源
2. 项目准备
centos7.9系统
3. 项目实施
3.1. 安装docker
安装基本命令:
yum -y install wget
yum -y install vim
yum -y install git
安装docker:
sudo yum install -y yum-utils
sudo yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
sudo yum -y install docker-ce docker-ce-cli containerd.io
sudo systemctl start docker
sudo systemctl enable docker
sudo systemctl status docker
docker --version
安装docker-compose:
sudo curl -L "https://github.com/docker/compose/releases/download/v2.27.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
docker-compose version
3.2. 更换镜像源
更改镜像源:
[root@localhost]# cat /etc/docker/daemon.json
{
"registry-mirrors": [
"https://hub.docker.com",
"https://docker.m.daocloud.io",
"https://noohub.ru",
"https://huecker.io",
"https://dockerhub.timeweb.cloud",
"https://docker.shootchat.top",
"https://do.nark.eu.org"
]
}
重启docker
systemctl restart docker.service
尝试拉取镜像:
docker pull hello-world
可以拉 但是需要耐心捏。
4. 项目总结
本博客主要写了如何安装docker和docker-compose。