Centos6.9/Redhat6.9 离线安装docker

准备:

1、查看系统版本:

cat /etc/redhat-release

2、查看内核版本

uname -r


不升级内核安装(rpm)

1、资源下载

https://get.docker.com/rpm/1.7.1/centos-6/RPMS/x86_64/docker-engine-1.7.1-1.el6.x86_64.rpmicon-default.png?t=LBL2https://get.docker.com/rpm/1.7.1/centos-6/RPMS/x86_64/docker-engine-1.7.1-1.el6.x86_64.rpm

libcgroup-0.40.rc1-24.el6_9.x86_64 RPMicon-default.png?t=LBL2http://rpm-find.net/linux/RPM/vault.centos.org/6.9/updates/x86_64/Packages/libcgroup-0.40.rc1-24.el6_9.x86_64.html2、rpm -ivh libcgroup-0.40.rc1-24.el6_9.x86_64.rpm

3、rpm -ivh docker-engine-1.7.1-1.el6.x86_64.rpm

4、查看docker版本

 docker -v

安装成功~~~ 

 其他:

1、查看docker状态

service docker status

2、启动/重启docker

service docker start/restart

3、停止docker

service docker stop

4、设置开机自启动

chkconfig docker on

5、查看chkconfig列表

chkconfig --list | grep docker

 如上图所示:docker开机自启动设置成功


升级内核安装(tgz)

1、资源下载Coreix Mirrors icon-default.png?t=LBL2http://mirrors.coreix.net/elrepo-archive-archive/kernel/el6/x86_64/RPMS/      kernel-lt-3.10.104-1.el6.elrepo.x86_64.rpm

Index of linux/static/stable/x86_64/icon-default.png?t=LBL2https://download.docker.com/linux/static/stable/x86_64/      docker-17.03.1-ce.tgz

 2、升级内核

        1)、rpm -ivh kernel-lt-3.10.104-1.el6.elrepo.x86_64.rpm

        2)、vi /etc/grub.conf

                将 default=1 改为 default=0

        3)、reboot 重启

3、tar -zxvf docker-17.03.1-ce.tgz

4、cp ./docker/* /usr/bin

5、dockerd &

6、查询docker info

安装完成~

但是你会发现service docker start/status 等命令不能用

解决

1、下载资源

libcgroup-0.40.rc1-24.el6_9.x86_64 RPM

2、rpm -ivh libcgroup-0.40.rc1-24.el6_9.x86_64.rpm

3、vi /etc/sysconfig/docker 将下面内容copy进去

# /etc/sysconfig/docker

#

# Other arguments to pass to the docker daemon process

# These will be parsed by the sysv initscript and appended

# to the arguments list passed to docker -d

other_args=""

4、vi /etc/init.d/docker

#!/bin/sh

#

#       /etc/rc.d/init.d/docker

#

#       Daemon for docker.com

#

# chkconfig:   2345 95 95

# description: Daemon for docker.com

### BEGIN INIT INFO

# Provides:       docker

# Required-Start: $network cgconfig

# Required-Stop:

# Should-Start:

# Should-Stop:

# Default-Start: 2 3 4 5

# Default-Stop:  0 1 6

# Short-Description: start and stop docker

# Description: Daemon for docker.com

### END INIT INFO

# Source function library.

. /etc/rc.d/init.d/functions

prog="docker"

unshare=/usr/bin/unshare

exec="/usr/bin/$prog"

pidfile="/var/run/$prog.pid"

lockfile="/var/lock/subsys/$prog"

logfile="/var/log/$prog"

[ -e /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog

prestart() {

    service cgconfig status > /dev/null

    if [[ $? != 0 ]]; then

        service cgconfig start

    fi

}

start() {

    [ -x $exec ] || exit 5

    check_for_cleanup

    if ! [ -f $pidfile ]; then

        prestart

        printf "Starting $prog:\t"

        echo "\n$(date)\n" >> $logfile

        "$unshare" -m -- $exec daemon $other_args &>> $logfile &

        pid=$!

        touch $lockfile

        # wait up to 10 seconds for the pidfile to exist.  see

        # https://github.com/docker/docker/issues/5359

        tries=0

        while [ ! -f $pidfile -a $tries -lt 10 ]; do

            sleep 1

            tries=$((tries + 1))

        done

        success

        echo

    else

        failure

        echo

        printf "$pidfile still exists...\n"

        exit 7

    fi

}

stop() {

    echo -n $"Stopping $prog: "

    killproc -p $pidfile -d 300 $prog

    retval=$?

    echo

    [ $retval -eq 0 ] && rm -f $lockfile

    return $retval

}

restart() {

    stop

    start

}

reload() {

    restart

}

force_reload() {

    restart

}

rh_status() {

    status -p $pidfile $prog

}

rh_status_q() {

    rh_status >/dev/null 2>&1

}

check_for_cleanup() {

    if [ -f ${pidfile} ]; then

        /bin/ps -fp $(cat ${pidfile}) > /dev/null || rm ${pidfile}

    fi

}

case "$1" in

    start)

        rh_status_q && exit 0

        $1

        ;;

    stop)

        rh_status_q || exit 0

        $1

        ;;

    restart)

        $1

        ;;

    reload)

        rh_status_q || exit 7

        $1

        ;;

    force-reload)

        force_reload

        ;;

    status)

        rh_status

        ;;

    condrestart|try-restart)

        rh_status_q || exit 0

        restart

        ;;

    *)

        echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}"

        exit 2

esac

exit $?

5、chkconfig --add docker

6、chkconfig docker on

7、service docker status

  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
相信好多人都在用yum时候,安装不好用,不是mirror找不到文件,就是rpm命令乱套。所以研究了离线安装。 准备: 1、已安装的linux (以centos7为例) 2、离线安装包: ①、docker-engine-1.7.1-1.el7.centos.x86_64.rpm(可从以下链接下载http://www.oschina.net/news/64267/docker-1-7-1-final,centos7对应下载链接: https://get.docker.com/rpm/1.7.1 ... 7.centos.x86_64.rpm) 2015-12-3更新rpm源:https://yum.dockerproject.org/repo/main/centos/7/Packages/ ②、依赖组件cgroup: libcgroup-0.41-8.el7.x86_64.rpm libcgroup-devel-0.41-8.el7.x86_64.rpm libcgroup-pam-0.41-8.el7.x86_64.rpm libcgroup-tools-0.41-8.el7.x86_64.rpm(可从以下链接下载,或参考附件http://mirrors.163.com/centos/7/os/x86_64/Packages/) 1、winscp以root用户登录linux主机,将docker及libcgroup复制到/tmp目录,下载资源里已经都提供好 2、Xshell登录linux主机,进入tmp目录,显示当前文件: $ cd /tmp/ $ ls docker-engine-1.7.1-1.el7.centos.x86_64.rpm libcgroup-0.41-8.el7.x86_64.rpm libcgroup-devel-0.41-8.el7.x86_64.rpm libcgroup-pam-0.41- 8.el7.x86_64.rpm libcgroup-tools-0.41-8.el7.x86_64.rpm 3、先安装组件依赖,临时切换root用户 $ su Password: # rpm -ivh libcgroup-* warning: libcgroup-0.41-8.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY Preparing... ################################# [100%] Updating / installing... 1:libcgroup-0.41-8.el7 ################################# [ 25%] 2:libcgroup-devel-0.41-8.el7 ################################# [ 50%] 3:libcgroup-pam-0.41-8.el7 ################################# [ 75%] 4:libcgroup-tools-0.41-8.el7 ################################# [100%] 如果提示key ID f4a80eb5: NOKEY,不让装,使用这个参数试试 --nodeps 4、安装docker主程序 # rpm -ivh docker-engine-1.7.1-1.el7.centos.x86_64.rpm Preparing... ################################# [100%] Updating / installing... 1:docker-engine-1.7.1-1.el7.centos ################################# [100%] 文件夹下还有:docker-engine-1.7.1-1.el6.x86_64.rpm 这个如果是centos6的时候用 5、启动docker服务并查看docker版本 # service docker start Starting docker (via systemctl): [ OK ] # docker -v Docker version 1.7.1, build

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值