docker下载、安装及加速
docker下载
1,Docker 下载
1,官网 http://www.docker.com
2,中文官网 https://docker-cn.com
3,仓库 https://hub.docker.com
2,Docker 安装前提说明
2.1 CentOS Docker 安装
Docker支持以下的CentOS版本:
CentOS 7 (64-bit)
CentOS 6.5 (64-bit) 或更高的版本
2.2 前提条件
目前,CentOS 仅发行版本中的内核支持 Docker。
Docker 运行在 CentOS 7 上,要求系统为64位、系统内核版本为 3.10 以上。[我们基于7以上的版本来讲的哦]
Docker 运行在 CentOS-6.5 或更高的版本的 CentOS 上,要求系统为64位、系统内核版本为 2.6.32-431 或者更高版本[。
2.3 查看自己的内核
uname命令用于打印当前系统相关信息(内核版本号、硬件架构、主机名称和操作系统类型等)
3,Docker 的基本组成
1,客户端
|–从仓库下载镜像
|–自己构建镜像
|–把自己构建的镜像上传到镜像库
2,宿主机
|–给docker提供一个运行环境
3,镜像仓库
|–开外公开的镜像
docker安装
1,centos 下安装Docker 文档
https://docs.docker.com/install/linux/docker-ce/centos/
2,Docker 安装
2.1,确定是centos7的版本
cat /etc/redhat-release
2.2,yum安装gcc相关
1,确定centos7能上外网
2,yum -y install gcc
3,yum -y install gcc-c++
2.3,卸载旧版本
$ sudo yum remove docker
docker-client
docker-client-latest
docker-common
docker-latest
docker-latest-logrotate
docker-logrotate
docker-engine
2.4,安装方法
yum -y install docker
2.5,启动docker
systemctl start docker
2.6,查看版本
docker version
2.7,测试运行 nginx
docker run hello-world
2.8,卸载docker
systemctl stop docker
yum -y remover docker
rm -rf /var/lib/docker
docker加速配置和run
1,说明
Docker 运行容器前需要本地存在对应的镜像,如果镜像不存在本地,Docker 会从镜像仓库下载(默认是Docker Hub 公共注册服务器中的仓库)。
2, 获取镜像
通过网址可以找到目标镜像 https://hub.docker.com/explore/
可以使用docker pull 命令来从仓库获取所需要的镜像。
如要下载一个centos:centos7的镜像
docker pull centos:centos7
语法docker pull 镜像名:【tag】
如果没有tag那么默认最新版本 也就是latest
3,阿里云镜像加速
1.登录:https://dev.aliyun.com/search.html
2.登录阿里云 搜索 容器镜像服务 找到后如下图
可以看到加速器地址哦
编辑配置文件
vi /etc/docker/daemon.json
拷贝下面的内容/etc/docker/daemon.json中
{ “registry-mirrors”: [“https://32xw0apq.mirror.aliyuncs.com”] }
执行下面两条命令 刷新docker的配置
systemctl daemon-reload
systemctl restart docker
4,下载其它镜像
如tomcat
docker pull tomcat:8.5
5,docker镜像的相关常用命令
5.1 列出所有镜像
docker images
5.2 根据镜像id删除镜像
docker rmi 镜像id
5.3根据镜像id删除镜像
docker pull 镜像名:[TAG]
doocker pull 仓库/镜像名:[TAG]
6,run了啥
</div>
<link href="https://csdnimg.cn/release/phoenix/mdeditor/markdown_views-b6c3c6d139.css" rel="stylesheet">
<div class="more-toolbox">
<div class="left-toolbox">
<ul class="toolbox-list">
<li class="tool-item tool-active is-like "><a href="javascript:;"><svg class="icon" aria-hidden="true">
<use xlink:href="#csdnc-thumbsup"></use>
</svg><span class="name">点赞</span>
<span class="count">1</span>
</a></li>
<li class="tool-item tool-active is-collection "><a href="javascript:;" data-report-click="{"mod":"popu_824"}"><svg class="icon" aria-hidden="true">
<use xlink:href="#icon-csdnc-Collection-G"></use>
</svg><span class="name">收藏</span></a></li>
<li class="tool-item tool-active is-share"><a href="javascript:;" data-report-click="{"mod":"1582594662_002"}"><svg class="icon" aria-hidden="true">
<use xlink:href="#icon-csdnc-fenxiang"></use>
</svg>分享</a></li>
<!--打赏开始-->
<!--打赏结束-->
<li class="tool-item tool-more">
<a>
<svg t="1575545411852" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="5717" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><defs><style type="text/css"></style></defs><path d="M179.176 499.222m-113.245 0a113.245 113.245 0 1 0 226.49 0 113.245 113.245 0 1 0-226.49 0Z" p-id="5718"></path><path d="M509.684 499.222m-113.245 0a113.245 113.245 0 1 0 226.49 0 113.245 113.245 0 1 0-226.49 0Z" p-id="5719"></path><path d="M846.175 499.222m-113.245 0a113.245 113.245 0 1 0 226.49 0 113.245 113.245 0 1 0-226.49 0Z" p-id="5720"></path></svg>
</a>
<ul class="more-box">
<li class="item"><a class="article-report">文章举报</a></li>
</ul>
</li>
</ul>
</div>
<div class="right-toolbox"><a href="https://blog.youkuaiyun.com/qq_44013790/article/details/89711025" target="_blank" class="jump-net-article">
<svg t="1575545252354" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="5597" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><defs><style type="text/css"></style></defs><path d="M243.9 1022.2c-62.3 0-124-23.8-171.5-70.8C26.4 905.5 1.5 845 1.5 779.9s24.9-125.6 70.8-171.5l184-184.1c45.9-45.9 106.4-70.8 171.5-70.8s125.6 24.9 171.5 70.8c18.1 18.1 18.1 47 0 65.1s-47 18.1-65.1 0c-28.3-28.3-65.7-43.5-105.9-43.5s-78.1 15.3-105.9 43.7l-184 184c-58.3 58.3-58.3 153.4 0 212.3 28.3 28.3 65.7 43.5 105.9 43.5s78.1-15.3 105.9-43.5l184-184c18.1-18.1 47-18.1 65.1 0 18.1 18.1 18.1 47 0 65.1l-184 184c-46.9 48-109.1 71.2-171.4 71.2z m523.7-423l184-184c94.5-94.5 94.5-248 0-342.5s-248-94.5-342.5 0l-184 184c-18.1 18.1-18.1 47 0 65.1s47 18.1 65.1 0l184-184c28.3-28.3 65.7-43.5 105.9-43.5s78.1 15.3 105.9 43.5c58.3 58.3 58.3 153.4 0 212.3l-184 184c-58.3 58.3-153.4 58.3-212.3 0-18.1-18.1-47-18.1-65.1 0-18.1 18.1-18.1 47 0 65.1 47 47 109.3 70.8 171.5 70.8s123.9-23.2 171.5-70.8z" p-id="5598"></path></svg>
站内首发文章</a></div>
</div>
<div class="person-messagebox">
<div class="left-message"><a href="https://blog.youkuaiyun.com/yimenglin">
<img src="https://profile.csdnimg.cn/9/0/A/3_yimenglin" class="avatar_pic" username="yimenglin">
<img src="https://g.csdnimg.cn/static/user-reg-year/1x/11.png" class="user-years">
</a></div>
<div class="middle-message">
<div class="title"><span class="tit"><a href="https://blog.youkuaiyun.com/yimenglin" data-report-click="{"mod":"popu_379"}" target="_blank">yimenglin</a></span>
</div>
<div class="text"><span>发布了0 篇原创文章</span> · <span>获赞 27</span> · <span>访问量 8万+</span></div>
</div>
<div class="right-message">
<a href="https://im.youkuaiyun.com/im/main.html?userName=yimenglin" target="_blank" class="btn btn-sm btn-red-hollow bt-button personal-letter">私信
</a>
<a class="btn btn-sm bt-button personal-watch" data-report-click="{"mod":"popu_379"}">关注</a>
</div>
</div>
</div>