安装
# yum包更新
> yum update
# 添加依赖
> yum install -y yum-utils device-mapper-persistent-data lvm2
# 设置镜像源(可选)
> yum-config-manager --add-repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
# 查看版本
> yum list docker-ce --showduplicates|sort -r
# 安装
> yum install -y docker-ce
# 启动服务
> systemctl start docker
加速器
> vim /etc/docker/daemon.json
{
"registry-mirrors": ["https://dockerpull.com"]
}
# 重启服务
> systemctl daemon-reload
> systemctl restart docker
远程访问
Linux
参考官方文档:Use TLS (HTTPS) to protect the Docker daemon socket
Winodws
# Docker开启2375端口后执行以下命令
> netsh interface portproxy add v4tov4 listenaddress=127.0.0.1 listenport=2375 connectaddress=127.0.0.1 connectport=2375
卸载
# 查询docker安装过的包
> yum list installed | grep docker
# 删除安装包
> yum -y remove <包名>
# 删除镜像/容器
> rm -rf /var/lib/docker
查看、启动、重启、关闭
# 开机自启动
> systemctl enable docker
# 启动服务
> systemctl start docker
# 查看服务
> systemctl status docker
# 重启服务
> systemctl daemon-reload
> systemctl restart docker
# 关闭服务
> systemctl stop docker