阿里云CentOS 6.5 模板上安装 Docker(3)

# service docker start
Starting cgconfig service:                                [  OK  ]
Starting docker:                                          [  OK  ]
# docker version
Client version: 1.2.0
Client API version: 1.14
Go version (client): go1.3.3
Git commit (client): fa7b24f/1.2.0
OS/Arch (client): linux/amd64
2014/11/05 21:03:08 Cannot connect to the Docker daemon. Is 'docker -d' running on this host?
使用 docker -d 来查看详细的启动过程。

# docker -d
2014/11/05 21:10:56 docker daemon: 1.2.0 fa7b24f/1.2.0; execdriver: native; graphdriver:
[40a2dcc2] +job serveapi(unix:///var/run/docker.sock)
[info] Listening for HTTP on unix (/var/run/docker.sock)
[40a2dcc2] +job init_networkdriver()
[40a2dcc2.init_networkdriver()] creating new bridge for docker0
Could not find a free IP address range for interface 'docker0'. Please configure its address manually and run 'docker -b docker0'
[40a2dcc2] -job init_networkdriver() = ERR (1)
2014/11/05 21:10:56 Could not find a free IP address range for interface 'docker0'. Please configure its address manually and run 'docker -b docker0'
提示我们没有空余 ip 分配给 docker0 了。

那我们就使用 --bip 参数来手工分配给 ip 地址。比如:

# docker --bip=192.168.100.1/24 -d &
[2] 2388
[root@iZ23pznlje4Z ~]# 2014/11/05 21:16:55 docker daemon: 1.2.0 fa7b24f/1.2.0; execdriver: native; graphdriver:
[dc6906e7] +job serveapi(unix:///var/run/docker.sock)
[info] Listening for HTTP on unix (/var/run/docker.sock)
[dc6906e7] +job init_networkdriver()
[dc6906e7] -job init_networkdriver() = OK (0)
2014/11/05 21:16:55 WARNING: Your kernel does not support cgroup swap limit.
[info] Loading containers:
[info] : done.
[dc6906e7] +job acceptconnections()
[dc6906e7] -job acceptconnections() = OK (0)
这里提示警告 Your kernel does not support cgroup swap limit.,我们可以使用 lxc-checkconfig 来检查。

# lxc-checkconfig
Kernel configuration not found at /proc/config.gz; searching...
Kernel configuration found at /boot/config-3.10.59-1.el6.elrepo.x86_64
--- Namespaces ---
Namespaces: enabled
Utsname namespace: enabled
Ipc namespace: enabled
Pid namespace: enabled
User namespace: missing
Network namespace: enabled
Multiple /dev/pts instances: enabled

--- Control groups ---
Cgroup: enabled
Cgroup clone_children flag: enabled
Cgroup device: enabled
Cgroup sched: enabled
Cgroup cpu account: enabled
Cgroup memory controller: enabled
Cgroup cpuset: enabled

--- Misc ---
Veth pair device: enabled
Macvlan: enabled
Vlan: enabled
File capabilities: enabled

Note : Before booting a new kernel, you can check its configuration
usage : CONFIG=/path/to/config /usr/bin/lxc-checkconfig
可以看到 Control groups 项目都是支持的,所以我们暂时忽略这个告警。

测试使用
由于 Aliyun 的网络直接 pull 官方镜像也不是很稳定,这里推荐使用linuxidc.com 官方网站的标准ubuntu镜像来测试。

下载镜像,重新标记镜像。

# docker pull dl.linuxidc.com.com:5000/ubuntu:14.04
# docker images
REPOSITORY                      TAG                IMAGE ID            CREATED            VIRTUAL SIZE
dl.linuxidc.com.com:5000/ubuntu  latest              5506de2b643b        12 days ago        197.8 MB
# docker tag 550 ubuntu
# docker rmi dl.linuxidc.com.com:5000/ubuntu
[dc6906e7] +job image_delete(dl.linuxidc.com.com:5000/ubuntu)
[dc6906e7] +job log(untag, 5506de2b643be1e6febbf3b8a240760c6843244c41e12aa2f60ccbb7153d17f5, )
[dc6906e7] -job log(untag, 5506de2b643be1e6febbf3b8a240760c6843244c41e12aa2f60ccbb7153d17f5, ) = OK (0)
[dc6906e7] -job image_delete(dl.linuxidc.com.com:5000/ubuntu) = OK (0)
Untagged: dl.linuxidc.com.com:5000/ubuntu:latest
启动容器,并测试网络。

# docker run -ti ubuntu
root@66ff9a55a4f5:/# ping
PING (xxx.xxx.xxx.xxx) 56(84) bytes of data.
^C64 bytes from 203.195.193.251: icmp_seq=1 ttl=47 time=31.4 ms

CentOS 6/7系列安装Docker

Docker的搭建Gitlab CI 全过程详解

Docker安装应用(CentOS 6.5_x64)

在 Docker 中使用 MySQL

在Ubuntu Trusty 14.04 (LTS) (64-bit)安装Docker

Docker安装应用(CentOS 6.5_x64)

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/76486a09e27ba37ab7ec8d3d6adbad6f.html