查看內核版本: html
uname -r 2.6.32-573.8.1.el6.x86_64
導入elrepo的key:linux
rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org
curl 報ssl錯誤,解決辦法:git
yum update -y nss curl libcurl openssh
安裝elrepo.repo: github
rpm -Uvh https://www.elrepo.org/elrepo-release-6-8.el6.elrepo.noarch.rpm
安裝內核:golang
(安裝最新版內核)yum --enablerepo=elrepo-kernel -y install kernel-ml (安裝長期穩定版內核)yum --enablerepo=elrepo-kernel -y install kernel-lt
修改grub.conf文件:docker
vim /etc/grub.conf --> default=0
重啓服務器查看內核:vim
reboot uname -r 4.4.162-1.el6.elrepo.x86_64
對於centos6好像是沒有yum最新版,只能經過升級方式了。centos
方法一:centos6下安裝epel源,個人服務器好像不行。bash
wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm sudo rpm -Uvh epel-release-6*.rpm yum install docker-io
方法二:生成docker.repo服務器
tee /etc/yum.repos.d/docker.repo <<-'EOF' [dockerrepo] name=Docker Repository baseurl=https://yum.dockerproject.org/repo/main/centos/$releasever/ enabled=1 gpgcheck=1 gpgkey=https://yum.dockerproject.org/gpg EOF yum update yum install docker-engine
測試docker:
docker --version service docker status
源碼編譯docker(須要服務器有老版本的docker):
升級git:
1.安裝環境
yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel asciidoc -y yum install gcc perl-ExtUtils-MakeMaker -y wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz tar zxvf libiconv-1.14.tar.gz cd libiconv-1.14 ./configure --prefix=/usr/local/libiconv make && make install yum install xmlto -y
2.安裝配置
yum remove git wget https://github.com/git/git/archive/v2.2.1.tar.gz tar zxvf v2.2.1.tar.gz cd git-2.2.1 make configure ./configure --prefix=/usr/local/git --with-iconv=/usr/local/libiconv make all doc make install install-doc install-html echo "export PATH=$PATH:/usr/local/git/bin" >> /etc/bashrc source /etc/bashrc
安裝golang
#Docker使用Golang開發
wget https://dl.google.com/go/go1.10.linux-amd64.tar.gz tar xzf go1.10.linux-amd64.tar.gz -C /usr/local mkdir /usr/local/gopackage 加入環境變量 vi /etc/profile GOROOT=/usr/local/go GOPATH=/usr/local/gopackage PATH=$PATH:$GOROOT/bin:$GOPATH/bin export GOROOT GOPATH PATH source /etc/profile
下載源碼並編譯:
#docker更名爲moby,不用糾結
git clone https://github.com/moby/moby cd moby
#要啥版本你本身看着切換,咱們選擇比較穩定的最新版本17.03.2
git checkout v17.03.2-ce make build
#編譯源碼:
下載1.9.1而後替換 curl -sSL -O https://get.docker.com/builds/Linux/x86_64/docker-1.9.1 chmod +x docker-1.9.1 sudo mv docker-1.9.1 /usr/bin/docker service docker restart 編譯源碼 make binary make instal
卸載並更新:
#卸載舊的docker yum remove docker-io -y #清理下遺留的文件 rm -rf /var/lib/docker/* #docker 配置文件 wget https://raw.githubusercontent.com/moby/moby/master/contrib/init/sysvinit-redhat/docker.sysconfig -O /etc/sysconfig/docker #docker init啓動文件 wget https://raw.githubusercontent.com/moby/moby/master/contrib/init/sysvinit-redhat/docker -O /etc/init.d/docker #修改啓動文件中dockerd的位置 sed -i "27s#usr/bin#usr/local/bin#g" /etc/init.d/docker #修改環境變量,覆蓋functions腳本中的PATH,防止沒法找到docker-container等程序 sed -i "23s#functions#functions\nexport PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/bin#g" /etc/init.d/docker #啓動 service docker restart #查看版本 docker version