本次升级设计 httpd 及 openssl ,修复目前市面上扫描出来的安全漏洞。
目的:
docker 中 httpd 从 2.4.6 升级至 2.4.39、openssl 从 1.0.2k-6 升级至 1.0.2k-19
1、基于 ius 源下载 httpd 2.4.39,基于红帽官网取的最新的 openssl
ius地址:https://mirrors.tuna.tsinghua.edu.cn/ius/ius-release-el7.rpm
2、拷贝安装包至 docker 容器
docker cp update-httpd-openssl.tar portal:/home
3、进入容器进行httpd安装升级
docker exec -it -u root portal bash cd /home tar -xvf update-httpd-openssl.tar cd update-httpd-openssl #注意:本次升级需要卸载之前的 httpd 才可以升级 yum remove -y httpd-tools-2.4.6-67.el7.centos.6.x86_64 yum install *
4、检查是否已升级成功
httpd -version
5、重启容器
附加:
升级失败容器回退方法:通过 kolla-docker-restart 脚本提取现有容器的启动方式,在 /tmp 下生成容器启动脚本,删掉现有容器,运行启动脚本重新生成镜像。
kolla-docker-restart portal
#!/usr/bin/env bash # kolla-docker-restart [[ $# -ne 1 ]] && echo "Usage: $0 <container_name_or_id>" && exit 1 container_name_or_id=$1 run_file="/tmp/start-$container_name_or_id" cat > /tmp/docker-run.tpl <<'EOF' docker run \ --name={{.Name}} \ {{range $e := .Config.Env}}--env={{printf "%q" $e}} \ {{end}}{{range $p, $conf := .NetworkSettings.Ports}}{{with $conf}}-p {{(index $conf 0).HostIp}}:{{(index $conf 0).HostPort}}:{{$p}} \ {{end}}{{end}}{{range $n, $conf := .NetworkSettings.Networks}}{{with $conf}}--network {{printf "%q" $n}} \ {{range $conf.Aliases}}--network-alias {{printf "%q" .}} {{end}} \ {{end}}{{end}}{{range $v := .HostConfig.VolumesFrom}}--volumes-from={{printf "%q" .}} \ {{end}}{{range $v := .HostConfig.Binds}}--volume={{printf "%q" .}} \ {{end}}{{range $l, $v := .Config.Labels}}--label {{printf "%q" $l}}={{printf "%q" $v}} \ {{end}}{{range $v := .HostConfig.CapAdd}}--cap-add {{printf "%q" .}} \ {{end}}{{range $v := .HostConfig.CapDrop}}--cap-drop {{printf "%q" .}} \ {{end}}{{range $d := .HostConfig.Devices}}--device={{printf "%q" (index $d).PathOnHost}}:{{printf "%q" (index $d).PathInContainer}}:{{(index $d).CgroupPermissions}} \ {{end}}{{range $v := .Config.Entrypoint}}--entrypoint={{printf "%q" .}} \ {{end}}{{with .HostConfig.LogConfig}}--log-driver={{printf "%q" .Type}} \ {{range $o, $v := .Config}}--log-opt {{$o}}={{printf "%q" $v}} \ {{end}}{{end}}{{with .HostConfig.RestartPolicy}}--restart="{{.Name}}{{if eq .Name "on-failure"}}{{.MaximumRetryCount}}{{end}}" \ {{end}}{{if .Config.Tty}}-t \ {{end}}{{if .Config.OpenStdin}}-i \ {{end}}{{if not (.Config.AttachStdout)}}--detach=true \ {{end}}{{if .HostConfig.Privileged}}--privileged \ {{end}}{{printf "%q" .Config.Image}} \ {{range .Config.Cmd}}{{printf "%q" .}} {{end}} EOF docker inspect --format "$(</tmp/docker-run.tpl)" "$container_name_or_id" > "$run_file" docker rm -f "$container_name_or_id" sh "$run_file" rm /tmp/docker-run.tpl "$run_file"