1.为了快速下载安装切换yum源
1.1备份
# mv /etc/yum.repo.d/CentOS7-Base.repo /etc/yum.repo.d/CentOS7-Base.repo.bak
1.2 下载阿里yum源
# sudo wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
1.3 清除缓存,
# yum clear all
# yum makecache
2.安装docker
2.1 yum 安装
# yum install -y docker
2.2 查看docker 是否安装成功
# docker version
2.3 启动docker
# systemctl start docker
3.docker使用基本命令
3.1 拉取镜像
# docker pull xxx
3.2 查看镜像
# docker images
3.3 后台运行
# docker run -d <images>
3.4 进入容器
# docker exec -it [容器编号] bash(命令行启动)
3.5 docker网络映射并且启动容器
# docker run -d -p 8888:8080 <your container>
3.6 停止运行
# docker stop <容器编号>
3.7 查看运行镜像
# docker ps
4添加国内Dockerhub
4.1 进入 https://www.daocloud.io/ 微信登陆
https://www.daocloud.io/
4.2 下载加速器
# curl -sSL https://get.daocloud.io/daotools/set_mirror.sh | sh -s http://414714b4.m.daocloud.io
4.3 编辑(此处有坑….)
下载的数据如下(咳咳咳):
{"registry-mirrors": ["http://xxxxxxx.m.daocloud.io"],}
多了一个逗号。。。。。。。(去掉这个逗号)
# vim /etc/docker/daemon.json
4.4 注册仓库地址
# vim /etc/sysconfig/docker
复制上面的地址,添加两行如下:
# ADD_REGISTRY='--add-registry xxxxxxx.m.daocloud.io'
# INSECURE_REGISTRY='--insecure-registry 414714b4.m.daocloud.io'