安装docker (centos7.6)
Docker
更新yum包
sudo yum update
卸载旧版本
sudo yum remove docker docker-common docker-selinux docker-engine
安装软件包, yum-util 提供yum-config-manager功能,device-mapper-persistent-data和lvm2是devicemapper驱动依赖
sudo yum install -y yum-utils device-mapper-persistent-data lvm2
设置源
sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
查看所有仓库中所有docker版本,可以选择特定版本安装
yum list docker-ce --showduplicates | sort -r
安装docker
sudo yum install docker-ce 安装最新版
sudo yum install docker-ce-xx.xx.x.ce 安装指定版本
开机启动
sudo systemctl enable docker
sudo systemctl start docker
查看安装是否成功
docker version
允许远程访问
vim /usr/lib/systemd/system/docker.service
在 ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock 后面添加-H tcp://0.0.0.0:2375 -H unix://var/run/docker.sock
变成ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock -H tcp://0.0.0.0:2375 -H unix://var/run/docker.sock
systemctl daemon-reload
systemctl restart docker
使用Docker 中国加速器
vi /etc/docker/daemon.json
{
"registry-mirrors": ["https://registry.docker-cn.com"],
"live-restore": true
}
systemctl restart docker
Docker-Compose
yum install epel-release -y
yum install python -y
yum install python-pip
更换 epel 源
yum install epel-release -y
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
更换 pip 源
mkdir ~/.pip
vim ~/.pip/pip.conf
[global]
timeout = 6000
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
trusted-host = pypi.tuna.tsinghua.edu.cn
pip install --upgrade pip
yum install python36
pip3 install docker-compose
docker-compose -version
进入https://github.com/docker/compose/releases查看最新版本和安装命令
安装,当前版本为1.25.0
curl -L https://github.com/docker/compose/releases/download/1.25.0/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
设置权限
chmod +x /usr/local/bin/docker-compose
查看是否安装成功
docker-compose --version
卸载
sudo rm /usr/local/bin/docker-compose