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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值