您好,登錄后才能下訂單哦!
本篇內容主要講解“在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進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。