CentOS7 docker试水
CentOS 7.0,无外网直接访问权限,有一台代理服务器。
首先安装docker-ce,参考http://blog.51cto.com/aaronsa/2056882
除非特殊说明,以下操作都用root用户:
$ export http_proxy=http://xxxx $ export https_proxy=http://xxxx $ yum install -y yum-utils # 安装yum-config-manager $ yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo # 添加docker-ce yum源 $ yum install docker-ce $ systemctl start docker
第一个坑,启动失败,通过journalctl -xe查看启动日志,报错
devmapper: Error while creating filesystem xfs on device ....
参考http://www.cnblogs.com/FoChen/p/8708932.html
$ yum update xfsprogs
第二个坑,普通用户无法使用docker命令,报错
Got permission denied while trying to connect to the Docker daemon socket at ...
查了一下资料,原来docker命令通过一个Unix socket与docker daemon通信,涉及到对Unix socket 访问权限问题,参考https://www.cnblogs.com/franson-2016/p/6412971.html
查了一下已经有docker组了,应该是yum install docker-ce时自动创建的,于是把普通用户添加进docker组就可以了;
$ gpasswd -a <user> docker
普通用户需要重新登录;
第三个坑,docker pull hello-world,报错:
Error response from daemon: Get https://registry-1.docker.io/v2/: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)
确认了一下代理服务器,不是代理服务器出了问题;
在浏览器里试了一下https://registry-1.docker.io,没有内容,以为是被墙了,大误,导致走了一大段错路,后来回头想想看,这应该是个api服务器,只是对空请求返回空结果而已,HTTP返回码是200,不是被墙,哪怕当时试一下https://registry-1.docker.io/v2/,都不会走这条弯路;
刚开始按照错误思路,想添加国内registry镜像,查找资料:
- 尝试在/etc/default/docker和/etc/sysconfig/docker中通过DOCKER_OPTS设置--registry-mirror参数无效,疑似配置文件不对;
- 参考了很多资料之后(尤其是DaoCloud的Docker加速器文档和set_mirror.sh脚本),了解到docker从1.10~1.12版本经历了一次改版,开始使用/etc/docker/daemon.json下的json格式的配置文件,连版本号格式都变了;于是在/etc/docker/daemon.json中写入docker镜像加速器的地址;(无论aliyun还是daocloud,都要求注册登录以获取专用加速器地址,如果按照别人的文档把别人的加速器地址拿来用了,应该会发生带宽抢占);
既然是错误思路,当然没有解决我的问题,不过也不算是空手而归,对docker的架构有了些微了解:
- docker pull的时候,dockerd服务是干活的主体,docker工具就是个命令行封装;
- docker的hub与registry服务器,有点类似于openstack里的glance和swift;
正确思路是将代理设置到dockerd的环境变量里,这就涉及到了systemd的一点知识,参考了Arch-wiki;
然后重启dockerd服务;
$ vi /etc/systemd/system/docker.service.d/proxy.conf [Service]
Environment="HTTP_PROXY=192.168.1.1:8080"
Environment="HTTPS_PROXY=192.168.1.1:8080" $ systemctl daemon-reload $ systemctl show docker --property Environment #确认环境变量生效 $ systemctl restart docker
用普通用户再试一下:
$ docker pull hello-world
Using default tag: latest
latest: Pulling from library/hello-world
9bb5a5d4561a: Pull complete
Digest: sha256:f5233545e43561214ca4891fd1157e1c3c563316ed8e237750d59bde73361e77
Status: Downloaded newer image for hello-world:latest $ docker image ls
REPOSITORY TAG IMAGE ID CREATED SIZE
hello-world latest e38bc07ac18e 2 weeks ago 1.85kB $ docker run hello-world Hello from Docker!
This message shows that your installation appears to be working correctly. To generate this message, Docker took the following steps:
1. The Docker client contacted the Docker daemon.
2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
(amd64)
3. The Docker daemon created a new container from that image which runs the
executable that produces the output you are currently reading.
4. The Docker daemon streamed that output to the Docker client, which sent it
to your terminal. To try something more ambitious, you can run an Ubuntu container with:
$ docker run -it ubuntu bash Share images, automate workflows, and more with a free Docker ID:
https://hub.docker.com/ For more examples and ideas, visit:
https://docs.docker.com/engine/userguide/
CentOS7 docker试水的更多相关文章
- docker试水
1.清理旧版本yum remove docker \ docker-common \ docker-selinux \ ...
- POJ 2502 - Subway Dijkstra堆优化试水
做这道题的动机就是想练习一下堆的应用,顺便补一下好久没看的图论算法. Dijkstra算法概述 //从0出发的单源最短路 dis[][] = {INF} ReadMap(dis); for i = 0 ...
- 大众点评试水O2O新模式:实体店试穿,扫描二维码付款 现场取货
在餐饮美食行业取得不错的成绩之后,大众点评将触角延伸到了线下的传统商铺,开始涉足线下商品的 O2O 团购.和传统的线上下单,线下消费的 O2O 模式不同.大众点评的 O2O 团购用户,可在店内试穿后通 ...
- Json.Net6.0入门学习试水篇
原文:Json.Net6.0入门学习试水篇 前言 JSON(JavaScript Object Notation) 是一种轻量级的数据交换格式.简单地说,JSON 可以将 JavaScript 对象中 ...
- 第一回:Scrapy的试水
前言:今天算是见到Scrapy的第二天,之前只是偶尔查了查,对于这个框架的各种解释,我-----都-----看------不------懂----,没办法,见面就是刚. 目的:如题,试水 目标:< ...
- CSharpGL(49)试水OpenGL软实现
CSharpGL(49)试水OpenGL软实现 CSharpGL迎来了第49篇.本篇内容是用C#编写一个OpenGL的软实现.暂且将其命名为SoftGL. 目前已经实现了由Vertex Shader和 ...
- CentOS7 Docker私有仓库搭建及删除镜像 【转】
文章来源:centos7 Docker私有仓库搭建及删除镜像 如果不想用私有镜像库,你可以用docker的库 https://hub.docker.com 环境准备 环境:两个装有Docker 17. ...
- centos7 docker升级到最新稳定版本
原文:centos7 docker升级到最新稳定版本 一.前言 docker的版本分为社区版docker-ce和企业版dokcer-ee社,区版是免费提供给个人开发者和小型团体使用的,企业版会提供额外 ...
- UITableView(自定义cell)试水心得
初次试水自定义cell的UITableView 实现目标 最终实现结果 界面复原度:98% 未能完全复刻的地方:下半部分的tableview与头部的控件间距上的误差 原因:在做table ...
随机推荐
- memocache 分布式搭建
memcached+magent实现memcached集群 首先说明下memcached存在如下问题 本身没有内置分布式功能,无法实现使用多台Memcache服务器来存储不同的数据,最大程度的使用 ...
- Django升级1.9.6出现的中文本地化bug
Error日志: Error opening file for reading: Permission denied ERROR Internal Server Error: / Traceback ...
- SQLServer Merger Using语法使用和注意点
SQL多表关联数据更新,如果数据量比较少的情况下,用Update也是可以的:脚本如下: UPDATE NA_AgentGrpOrder SET AttrServSIItem=b.AttrValue F ...
- 如何用plugman编辑和添加cordova插件
1.安装工具 进入nodejs, 安装工具plugman,管理插件,输入命令npm install -g plugman 等待下载安装 2.使用plugman命令生成插件框架 cmd 进入用于生成插件 ...
- SSH项目的pom.xml文件
<!-- 属性 --> <properties> <spring.version>4.2.4.RELEASE</spring.version> < ...
- Python_sqlite3
import sqlite3 #导入模块 conn = sqlite3.connect('example.db') #连接数据库 c = conn.cursor() #创建表 c.execute('' ...
- PAT1084:Broken Keyboard
1084. Broken Keyboard (20) 时间限制 200 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue On a ...
- Linux获取网络接口信息
linux获取网络接口信息需要用到的函数为ioctl(),结构体struct ifreq,struct ifconf 1.ioctl()函数原型及作用 #include <sys/ioctl.h ...
- 【线程系列五】什么时候释放锁—wait()、notify()
由于等待一个锁定线程只有在获得这把锁之后,才能恢复运行,所以让持有锁的线程在不需要锁的时候及时释放锁是很重要的.在以下情况下,持有锁的线程会释放锁: 1. 执行完同步代码块. 2. 在执行 ...
- 并行(Parallelism)与并发(Concurrency)
并行(Parallelism):多任务在同一时刻运行.例如,多个任务在多核处理器上运行. 并发(Concurrency):两个或者两个以上的任务在一段时间内开始.运行.完成,这意味着它们不是在同一时刻 ...