Docker 安装
1.卸载旧版本
yum -y remove docker docker-client docker-client-latest docker-common docker-latest \ docker-latest-logrotate docker-logrotate docker-selinux docker-engine-selinux docker-engine
2.安装依赖
yum -y install yum-utils device-mapper-persistent-data lvm2
3.添加安装源
yum-config-manager --add-repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
4.安装 Docker CE
yum makecache fastyum -y install docker-ce
6.启动服务
systemctl start dockersystemctl enable docker
5.验证安装
docker -vdocker version
配置 Docker镜像加速
手动配置
# 使用daocloud源mkdir /etc/dockercat < /etc/docker/daemon.json{ "registry-mirrors": ["http://3272dd08.m.daocloud.io"]}!# 重启服务systemctl restart docker# 使用清华源mkdir /etc/dockercat < /etc/docker/daemon.json{ "registry-mirrors": ["https://docker.mirrors.ustc.edu.cn/"]}!# 重启服务systemctl restart docker
使用脚本
mkdir /etc/dockercurl -sSL https://get.daocloud.io/daotools/set_mirror.sh | sh -s http://3272dd08.m.daocloud.iosystemctl restart docker
Docker compose 安装
1.获取最新版本号
releases='https://api.github.com/repos/docker/compose/releases'new_ver=$(curl $releases -s | grep -o '"tag_name": ".*"' |head -n 1| sed 's/"//g;s/v//g' | sed 's/tag_name: //g')
2.下载docker-compose
compose="https://github.com/docker/compose/releases/download/$new_ver/docker-compose-$(uname -s)-$(uname -m)"curl -L $compose -o /usr/local/bin/docker-compose --progresschmod +x /usr/local/bin/docker-compose
3.验证
docker-compose -v
使用脚本安装
bash <(curl -sSL https://gitee.com/yx571304/my_oschina/raw/master/docker/install.sh)