歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux基礎 >> Linux教程 >> 在RedHat/CentOS下安裝Docker(不升級內核)

在RedHat/CentOS下安裝Docker(不升級內核)

日期:2017/2/28 14:36:51   编辑:Linux教程

背景

由於內核版本問題,最初僅Ubuntu可以較好的支持Docker。不過,由於RedHat系列OS(REHL、CentOS)是目前主流的Linux服務器操作系統,所以令RedHat系列OS支持Docker很有必要。目前Docker和RedHat已經展開深入合作,並在2013年年底推出了可以在RedHat系列OS上運行的Docker0.7。

目前有一些博客介紹了如何在CentOS上安裝Docker,例如http://www.linuxidc.com/Linux/2014-01/95512.htm 。但是這些博客都是針對老版本的Docker,安裝方法是在升級操作系統內核版本的基礎上完成。問題是,我們不可以隨意升級生產環境的操作系統內核版本,而且Docker0.7的主旨就是:Docker使用者可以在不升級內核的前提下,在RedHat環境這使用Docker。因此,這裡撰寫一篇博客,介紹如何在RedHat/CentOS環境下,安裝新版本的Docker。

一、禁用selinux
由於Selinux和LXC有沖突,所以需要禁用selinux。編輯/etc/selinux/config,設置兩個關鍵變量。
SELINUX=disabled
SELINUXTYPE=targeted

二、配置Fedora EPEL源
1 sudo yum install http://ftp.riken.jp/Linux/fedora/epel/6/x86_64/epel-release-6-8.noarch.rpm

三、添加hop5.repo源

cd /etc/yum.repos.d
sudo wget http://www.hop5.in/yum/el6/hop5.repo

四、安裝Docker
sudo yum install docker-io

圖1是yum安裝過程中的截圖,可以發現安裝的軟件只有docker和lxc相關包,沒有內核包,例如kernel-ml-aufs。

圖1 yum install docker-io輸出截圖


五、初步驗證docker
輸入docker -h,如果有如下輸出,就證明docker在形式上已經安裝成功。

# docker -h
Usage of docker:
-D=false: Enable debug mode
-H=[]: Multiple tcp://host:port or unix://path/to/socket to bind in daemon mode, single connection otherwise
-api-enable-cors=false: Enable CORS headers in the remote API
-b="": Attach containers to a pre-existing network bridge; use 'none' to disable container networking
-bip="": Use this CIDR notation address for the network bridge's IP, not compatible with -b
-d=false: Enable daemon mode
-dns=[]: Force docker to use specific DNS servers
-g="/var/lib/docker": Path to use as the root of the docker runtime
-icc=true: Enable inter-container communication
-ip="0.0.0.0": Default IP address to use when binding container ports
-iptables=true: Disable docker's addition of iptables rules
-p="/var/run/docker.pid": Path to use for daemon PID file
-r=true: Restart previously running containers
-s="": Force the docker runtime to use a specific storage driver
-v=false: Print version information and quit

Docker 的詳細介紹:請點這裡
Docker 的下載地址:請點這裡

開源項目Docker,Red Hat新的虛擬化選擇 http://www.linuxidc.com/Linux/2013-10/91051.htm

dockerlite: 輕量級 Linux 虛擬化 http://www.linuxidc.com/Linux/2013-07/87093.htm

Docker的搭建Gitlab CI 全過程詳解 http://www.linuxidc.com/Linux/2013-12/93537.htm

Docker 和一個正常的虛擬機有何區別? http://www.linuxidc.com/Linux/2013-12/93740.htm

Docker 將改變所有事情 http://www.linuxidc.com/Linux/2013-12/93998.htm

Copyright © Linux教程網 All Rights Reserved