一、安装Docker
服务器系统:centos 7
1.本地有docker的首先卸载本机docker
yum remove docker \docker-client \docker-client-latest \docker-common \docker-latest \docker-latest-logrotate \docker-logrotate \docker-selinux \docker-engine-selinux \docker-engine
yum remove docker-ce \docker-ce-cli \containerd
删除docker的文件
systemctl stop docker
rm -rf /etc/systemd/system/docker.service.d
rm -rf /etc/systemd/system/docker.service
rm -rf /var/lib/docker
rm -rf /var/run/docker
rm -rf /usr/local/docker
rm -rf /etc/docker
rm -rf /usr/bin/docker* /usr/bin/containerd* /usr/bin/runc /usr/bin/ctr
2.安装对应依赖环境
sudo yum install -y yum-utils
3.映射仓库地址
源地址
sudo yum-config-manager \--add-repo \https://download.docker.com/linux/centos/docker-ce.repo
如果安装过慢的话可以用阿里的地址`
sudo yum-config-manager \--add-repo \http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
4.安装Docker CE(docker-ce 也叫社区版)
sudo yum install docker-ce docker-ce-cli containerd.io
启动Docker服务
sudo systemctl start docker
查看Docker版本
sudo docker version
设置开机自启动
sudo systemctl enable docker
测试Docker安装是否正常
sudo docker run hello-world
docker images //查看镜像
5.安装docker-compose
github上下载二进制文件
https://github.com/docker/compose/releases/download/v2.5.0/docker-compose-linux-x86_64
放入/usr/local/bin/ 路径下并重新命名添加可执行权限
mv docker-compose-linux-x86_64 docker-compose //修改名字
chmod +x docker-compose
查看docker-compose 是否正常运行
docker-compose version