docker使用
1. docker ps 查看運行中的容器
2. docker images 查看docker鏡像
3. docker rm id(容器id) 刪除容器(容器id可以通過docker ps查看,容器必須停止后才能刪除)
3.1 刪除全部的容器 docker rm `docker ps -a -q`
4. docker stop id(容器id) 停止容器運行
5. docker rmi id(鏡像id) 刪除鏡像
6. docker pull ubuntu:16.04(鏡像名稱:版本號) 下載鏡像
7. docker run -it ubuntu:16.04 創建并運行容器容器
-t 表示在新容器內指定一個偽終端或終端
-i 表示允許我們對容器內的 (STDIN) 進行交互
-p 指定映射端口
-d 在后臺運行容器并打印容器ID
7.1 docker run -dit ubuntu:16.04 創建并后臺運行容器
7.2 docker run -ditp 8080:8080(主機端口:容器端口) ubuntu:16.04 創建并后臺運行容器且映射容器的端口
8. docker attach id(容器id) 進入正在運行中的容器環境
9. 退出容器
9.1 exit 直接退出容器并終止容器運行
9.2 [ctrl+p]+[ctrl+q](快捷鍵) 退出容器,但是不會終止容器運行
10. docker commit -m'版本標識' id(容器id) ubuntu:16.04(鏡像與版本號) 提交鏡像且生成鏡像(可以通過該命令把搭建好的容器打包成一個新的鏡像或者覆蓋原鏡像(即是修改原鏡像內容,生成的鏡像名與版本號相同就可以直接覆蓋))
好了,大家了解了docker,下面是本文介紹的重點,一起看看吧。
Nginx 自己沒有處理日志的滾動問題,它把這個球踢給了使用者。一般情況下,你可以使用 logrotate 工具來完成這個任務,或者如果你愿意,你可以寫各式各樣的腳本完成同樣的任務。本文筆者介紹如何滾動運行在 docker 中的 nginx 日志文件(下圖來自互聯網)。
思路
Nginx 官方其實給出了如何滾動日志的說明:
Rotating Log-files
In order to rotate log files, they need to be renamed first. After that USR1 signal should be sent to the master process. The master process will then re-open all currently open log files and assign them an unprivileged user under which the worker processes are running, as an owner. After successful re-opening, the master process closes all open files and sends the message to worker process to ask them to re-open files. Worker processes also open new files and close old files right away. As a result, old files are almost immediately available for post processing, such as compression.
這段說明的大意是:
•先把舊的日志文件重命名
•然后給 nginx master 進程發送 USR1 信號
新聞熱點
疑難解答