准备:
1、查看系统版本:
cat /etc/redhat-release
2、查看内核版本
uname -r
不升级内核安装(rpm)
1、资源下载
libcgroup-0.40.rc1-24.el6_9.x86_64 RPMhttp://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 http://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/https://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