centos 7.x 安装docker
#删除已有Docker
sudo yum remove docker \
docker-client \
docker-client-latest \
docker-common \
docker-latest \
docker-latest-logrotate \
docker-logrotate \
docker-engine
#设置仓库
sudo yum install -y yum-utils \
device-mapper-persistent-data \
lvm2
sudo yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
#安装
sudo yum install docker-ce docker-ce-cli containerd.io
#启动 Docker。(sudo systemctl enable docker #是开机启动)
sudo systemctl enable docker && sudo systemctl start docker
docker-compose 安装
1脚本安装:
sudo curl -L "https://github.com/docker/compose/releases/download/1.27.4/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
2手动安装:
sudo yum -y install epel-release
sudo yum -y install python-pip python-devel
pip install docker-compose
修改docker国内镜像源
1.修改或创建daemon.json文件:vi /etc/docker/daemon.json
将以下配置写入到文件中,保存并退出(不会操作的百度下vi命令吧):
{
"registry-mirrors": ["https://docker.mirrors.ustc.edu.cn"]
}
2.重启docker:systemctl restart docker.service