Linux(CentOS6.8)配置Docker
Centos6.8
1.查看自己的内核
[1].uname
[root@host79 ~]# uname -r 2.6.32-642.el6.x86_64 |
[2].查看CentOS版本信息
CentOS6.8有,CentOS7无该命令
[root@host79 ~]# lsb_release -a LSB Version: :base-4.0-amd64:base-4.0-noarch:core-4.0-amd64:core-4.0-noarch:graphics-4.0-amd64:graphics-4.0-noarch:printing-4.0-amd64:printing-4.0-noarch Distributor ID: CentOS Description: CentOS release 6.8 (Final) Release: 6.8 Codename: Final [root@host79 ~]# cat /etc/redhat-release CentOS release 6.8 (Final) |
2.Docker基本组成
[1].镜像(Image)
Docker 镜像(Image)就是一个只读的模板。镜像可以用来创建 Docker 容器,一个镜像可以创建很多容器。
[2].容器(Container)
[3].仓库(Repository)
[4].总结
[5].Docker架构图
3.安装Docker
[1].安装EPEL仓库
Docker使用EPEL发布,RHEL系的OS首先要确保已经持有EPEL仓库,否则先检查OS的版本,然后安装相应的EPEL包。
[root@host79 ~]# yum install -y epel-release |
[2].DockerIO
方法一:
[root@host79 ~]# yum install -y docker-io |
若出现No package docker-io available.则使用方法二安装
方法二:
[root@host79 ~]# yum install https://get.docker.com/rpm/1.7.1/centos-6/RPMS/x86_64/docker-engine-1.7.1-1.el6.x86_64.rpm |
[3].配置文件是否存在
[root@host79 ~]# ls -l /etc/sysconfig/docker |
[4].启动Docker服务
[root@host79 ~]# service docker start |
[5].查看Docker版本信息
[root@host79 ~]# docker version |
3.Docker加速
鉴于国内网络问题,后续拉取 Docker 镜像十分缓慢,我们可以需要配置加速器来解决,我使用的是阿里云的本人自己账号的镜像地址(需要自己注册有一个属于你自己的):https://xxxx.mirror.aliyuncs.com
[1].获取阿里云的加速器地址
https://xxxxxxxx.mirror.aliyuncs.com |
[2].配置加速地址
将获得的自己账户下的阿里云加速地址配置进
(other_args="--registry-mirror=https://你自己的账号加速信息.mirror.aliyuncs.com")
[root@host79 ~]# vim /etc/sysconfig/docker https://xxxxxxxx.mirror.aliyuncs.com [root@host79 ~]# service docker restart |
[3].检查配置是否成功
如果从结果中看到了配置的--registry-mirror参数说明配置成功
[root@host79 ~]# ps -ef|grep docker |
4.HelloWorld
[root@host79 ~]# docker run hello-world |
问题:Error response from daemon: Get https://registry-1.docker.io/v2/: dial tcp: lookup registry-1.docker.io on [::1]:53: read udp [::1]:51086->[::1]:53: read: connection refused
解决:
如果可以docker run hello-world,因网速慢报该错误;因国内访问国外网速慢我们只需要,更换阿里源即可 |
DNS解析问题,docker.io DNS无法解析, 更改宿主机DNS。在/etc/network/interfaces 最后添加 dns-nameservers 8.8.8.8 然后 service network restart
|
参考文档:https://docs.docker.com/engine/install/