Docker引擎安装与Docker-compose工具安装
1.docker引擎安装下面以centos为例
#清除历史安装文件
sudo yum remove docker \
docker-client \
docker-client-latest \
docker-common \
docker-latest \
docker-latest-logrotate \
docker-logrotate \
docker-engine
#配置docker仓库源
sudo yum install -y yum-utils
sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
#安装前准备工作(可选)
touch /etc/docker/daemon.json
vim /etc/docker/daemon.json
#这里可以配置镜像加速,docker数据目录等
{
"registry-mirrors": ["https://xxx.mirror.aliyuncs.com"],
"insecure-registries":["https://xxx.mirror.aliyuncs.com"],
"bip": "172.13.0.2/24",
"data-root": "/data/docker"
}
#安装前准备工作(可选)
systemctl daemon-reload
#安装docker引擎默认是最新的
sudo yum install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
#指定安装docker版本
sudo yum install docker-ce-20.10.21 docker-ce-cli-20.10.21 containerd.io docker-buildx-plugin-20.10.21 docker-compose-plugin-20.10.21
#启动docker
sudo systemctl start docker
2.docker-compose工具安装,方便编写compose文件的方式安装容器
#下载地址https://github.com/docker/compose/releases/
sudo curl -L "https://github.com/docker/compose/releases/download/v2.2.2/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
测试是否安装成功:
$ docker-compose version
docker-compose version 1.24.1, build 4667896b
评论区