滚动 docker 中的 nginx 日志

$ docker run --p :-v $()/logs/nginx:/var/log/--restart=--name=.

#!/bin/<span style="color: #0000ff">for ((i=<span style="color: #800080">1;i<=<span style="color: #800080">100000;i++<span style="color: #000000">))
<span style="color: #0000ff">do<span style="color: #000000">
curl http:<span style="color: #008000">//<span style="color: #008000">localhost > /dev/null
<span style="color: #0000ff">sleep <span style="color: #800080">1
<span style="color: #0000ff">done

#!/bin/getdatestring()
{
TZ
=<span style="color: #800000">'<span style="color: #800000">Asia/Chongqing<span style="color: #800000">' <span style="color: #0000ff">date <span style="color: #800000">"<span style="color: #800000">+%Y%m%d%H%M<span style="color: #800000">"<span style="color: #000000">
}
datestring=<span style="color: #000000">$(getdatestring)

<span style="color: #0000ff">mv /var/log/nginx/access.log /var/log/nginx/<span style="color: #000000">access.${datestring}.log
<span style="color: #0000ff">mv /var/log/nginx/error.log /var/log/nginx/<span style="color: #000000">error.${datestring}.log
<span style="color: #0000ff">kill -USR1 <span style="color: #0000ff"&gt;cat</span> /var/run/nginx.pid

$ +x rotatelog. rotatelog. $()/logs/nginx

$ docker exec mynginx bash /var/log/nginx/rotatelog.

* * * * docker exec mynginx bash /var/log/nginx/rotatelog.

》一文中介绍了容器中信号的捕获问题,感兴趣的朋友可以去看看。在那篇文章中我们介绍了 docker 向容器中进程发送信号的 kill 命令。我们可以通过命令:

$ docker container mynginx -s USR1

相关文章

Docker是什么Docker是 Docker.Inc 公司开源的一个基于 LXC技...
本文为原创,原始地址为:http://www.cnblogs.com/fengzheng...
镜像操作列出镜像:$ sudo docker imagesREPOSITORY TAG IMA...
本文原创,原文地址为:http://www.cnblogs.com/fengzheng/p...
在 Docker 中,如果你修改了一个容器的内容并希望将这些更改...
在Docker中,--privileged 参数给予容器内的进程几乎相同的权...