您好,登录后才能下订单哦!
本篇内容主要讲解“在CentOS 6.x上怎么安装docker”,感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习“在CentOS 6.x上怎么安装docker”吧!
1. 禁用selinux
# getenforce enforcing # setenforce 0 permissive # vi /etc/selinux/config selinux=disabled ...
2. 安装 fedora epel
epel-release-6-8.noarch.rpm包在发行版的介质里面已经自带了,可以从rpm安装。
# yum install epel-release-6-8.noarch.rpm //或 yum -y install http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
如果出现gpg key retrieval failed: [errno 14] could not open/read file:///etc/pki/rpm-gpg/rpm-gpg-key-epel-6问题,请在线安装epel,下载rpm-gpg-key-epel-6文件。
这一步执行之后,会在/etc/yum.repos.d/下生成epel.repo、epel-testing.repo两个文件,用于从fedora官网下载rpm包。
3. 检查内核版本
# uname -r 2.6.32-431.el6.x86_64 # cat /etc/redhat-release centos release 6.5 (final)
看到这个最低的内核版本,事实运行起来是没太大问题的,你也可以升级到3.10.x版本。
另外你也可以运行脚本check-config.sh,来检查内核模块符不符合(下面有些missing的,我的docker还是可以正常启动):
[root@sean ~]# ./check-config warning: /proc/config.gz does not exist, searching other paths for kernel config... info: reading kernel config from /boot/config-2.6.32-431.el6.x86_64 ... generally necessary: - cgroup hierarchy: properly mounted [/cgroup] - config_namespaces: enabled - config_net_ns: enabled - config_pid_ns: enabled - config_ipc_ns: enabled - config_uts_ns: enabled - config_devpts_multiple_instances: enabled - config_cgroups: enabled - config_cgroup_cpuacct: enabled - config_cgroup_device: enabled - config_cgroup_freezer: enabled - config_cgroup_sched: enabled - config_macvlan: enabled - config_veth: enabled - config_bridge: enabled - config_nf_nat_ipv4: missing - config_ip_nf_target_masquerade: enabled - config_netfilter_xt_match_addrtype: missing - config_netfilter_xt_match_conntrack: enabled - config_nf_nat: enabled - config_nf_nat_needed: enabled optional features: - config_memcg_swap: missing - config_resource_counters: enabled - config_cgroup_perf: enabled - storage drivers: - "aufs": - config_aufs_fs: missing - config_ext4_fs_posix_acl: enabled - config_ext4_fs_security: enabled - "btrfs": - config_btrfs_fs: enabled - "devicemapper": - config_blk_dev_dm: enabled - config_dm_thin_provisioning: enabled - config_ext4_fs: enabled - config_ext4_fs_posix_acl: enabled - config_ext4_fs_security: enabled
假如你是自己编译内核,请特别留意几个绝对不能缺少的:dm_thin_provisioning、ip_nf_target_masquerade、nf_nat。(aufs_fs没有对应选项,还不清楚怎么回事,但不是必须)
4. 安装 docker-io
# yum install docker-io dependencies resolved =========================================================================================== package arch version repository size =========================================================================================== installing: docker-io x86_64 1.1.2-1.el6 epel 4.5 m installing for dependencies: lua-alt-getopt noarch 0.7.0-1.el6 epel 6.9 k lua-filesystem x86_64 1.4.2-1.el6 epel 24 k lua-lxc x86_64 1.0.6-1.el6 epel 15 k lxc x86_64 1.0.6-1.el6 epel 120 k lxc-libs x86_64 1.0.6-1.el6 epel 248 k transaction summary =========================================================================================== install 6 package(s)
许多文档介绍到这里,下一步为挂载/cgroup文件系统,我的docker版本为1.1.2,没有修改/etc/fstab的步骤。
5. 启动试运行
# service docker start //或 # docker -d
6. 异常
在我的一次安装过程中,很不幸遇到下面的问题:
docker -d启动,或tail -f /var/log/docker查看日志
[f32e7d9f] +job initserver() [f32e7d9f.initserver()] creating server [f32e7d9f] +job serveapi(unix:///var/run/docker.sock) 2014/10/22 13:02:45 listening for http on unix (/var/run/docker.sock) error running devicecreate (createpool) dm_task_run failed [f32e7d9f] -job initserver() = err (1) 2014/10/22 13:02:45 error running devicecreate (createpool) dm_task_run failed \nwed oct 22 14:35:54 cst 2014\n
再或者是service docker restart
stopping docker: [ ok ] starting cgconfig service: error: cannot mount cpuset to /cgroup/cpuset: device or resource busy /sbin/cgconfigparser; error loading /etc/cgconfig.conf: cgroup mounting failed failed to parse /etc/cgconfig.conf [failed] starting docker: [ ok ]
unable to enable network bridge nat: iptables failed: iptables -i postrouting -t nat -s 172.17.42.1/16 ! -d 172.17.42.1/16 -j masquerade: iptables v1.4.7: can't initialize iptables table `nat': table does not exist (do you need to insmod?)
perhaps iptables or your kernel needs to be upgraded.
上面的三个异常都是由于内核模块的缺失导致的,这也是自己编译内核来升级带来的风险,于是就有了sciurus的kernel-ml-aufs的rpm包。
到此,相信大家对“在CentOS 6.x上怎么安装docker”有了更深的了解,不妨来实际操作一番吧!这里是亿速云网站,更多相关内容可以进入相关频道进行查询,关注我们,继续学习!
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。