master
root 1 month ago
parent 66d537c6f4
commit dd046aa9a1

@ -1 +1 @@
0 2 * * 0 /root/docker/autobackup.sh >> /var/log/docker_backup.log 2>&1
0 2 * * 0 /root/mydocker/autobackup.sh >> /var/log/docker_backup.log 2>&1

@ -82577,3 +82577,62 @@
2026-05-09T00:50:59.027Z INFO request {"time": "2026-05-09T00:50:59Z", "method": "GET", "ip": "184.105.139.70", "user-agent": "Mozilla/5.0 (X11; Linux i686) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36", "path": "/./favicon.ico", "status": 404, "latency": 0.000014588}
2026-05-09T00:51:29.424Z INFO request {"time": "2026-05-09T00:51:29Z", "method": "GET", "ip": "184.105.139.94", "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36", "path": "/", "status": 200, "latency": 0.00027171}
2026-05-09T00:51:36.812Z INFO request {"time": "2026-05-09T00:51:36Z", "method": "CONNECT", "ip": "184.105.139.70", "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36", "path": "", "status": 404, "latency": 0.000016408}
2026-05-12T13:04:13.414Z INFO request {"time": "2026-05-12T13:04:13Z", "method": "GET", "ip": "5.61.209.102", "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.85 Safari/537.36 Edg/90.0.818.46", "path": "/SDK/webLanguage", "status": 404, "latency": 0.000288343}
2026-05-12T13:06:51.300Z INFO request {"time": "2026-05-12T13:06:51Z", "method": "GET", "ip": "79.124.40.174", "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36", "path": "/jars", "status": 404, "latency": 0.022875377}
2026-05-12T13:23:01.439Z INFO request {"time": "2026-05-12T13:23:01Z", "method": "POST", "ip": "79.124.40.174", "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36", "path": "/", "status": 404, "latency": 0.0003438}
2026-05-12T13:26:18.216Z INFO request {"time": "2026-05-12T13:26:18Z", "method": "GET", "ip": "79.127.175.104", "user-agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/137.0.0.0 Safari/537.36", "path": "/", "status": 200, "latency": 0.004739435}
2026-05-12T13:26:18.853Z INFO request {"time": "2026-05-12T13:26:18Z", "method": "GET", "ip": "79.127.175.104", "user-agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/136.0.0.0 Safari/537.36", "path": "/favicon.ico", "status": 404, "latency": 0.009234695}
2026-05-12T13:26:20.951Z INFO request {"time": "2026-05-12T13:26:20Z", "method": "GET", "ip": "64.227.70.2", "user-agent": "Mozilla/5.0 (l9scan/2.0.3393e24343e22363e2934313; +https://leakix.net)", "path": "/", "status": 200, "latency": 0.00015715}
2026-05-12T13:26:22.938Z INFO request {"time": "2026-05-12T13:26:22Z", "method": "GET", "ip": "64.227.70.2", "user-agent": "Mozilla/5.0 (l9scan/2.0.3393e24343e22363e2934313; +https://leakix.net)", "path": "/server", "status": 404, "latency": 0.000449743}
2026-05-12T13:26:23.933Z INFO request {"time": "2026-05-12T13:26:23Z", "method": "GET", "ip": "64.227.70.2", "user-agent": "Mozilla/5.0 (l9scan/2.0.3393e24343e22363e2934313; +https://leakix.net)", "path": "/server-status", "status": 404, "latency": 0.000404778}
2026-05-12T13:26:24.127Z INFO request {"time": "2026-05-12T13:26:24Z", "method": "GET", "ip": "196.196.53.26", "user-agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/137.0.0.0 Safari/537.36", "path": "/", "status": 200, "latency": 0.000188214}
2026-05-12T13:26:25.931Z INFO request {"time": "2026-05-12T13:26:25Z", "method": "GET", "ip": "64.227.70.2", "user-agent": "Mozilla/5.0 (l9scan/2.0.3393e24343e22363e2934313; +https://leakix.net)", "path": "/about", "status": 404, "latency": 0.000276186}
2026-05-12T13:26:26.912Z INFO request {"time": "2026-05-12T13:26:26Z", "method": "GET", "ip": "195.181.161.18", "user-agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/137.0.0.0 Safari/537.36", "path": "/", "status": 200, "latency": 0.00008509}
2026-05-12T13:26:27.086Z INFO request {"time": "2026-05-12T13:26:27Z", "method": "GET", "ip": "64.227.70.2", "user-agent": "Mozilla/5.0 (l9scan/2.0.3393e24343e22363e2934313; +https://leakix.net)", "path": "/login.action", "status": 404, "latency": 0.000293517}
2026-05-12T13:26:27.430Z INFO request {"time": "2026-05-12T13:26:27Z", "method": "GET", "ip": "195.181.161.18", "user-agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/136.0.0.0 Safari/537.36", "path": "/favicon.ico", "status": 404, "latency": 0.000250258}
2026-05-12T13:26:28.078Z INFO request {"time": "2026-05-12T13:26:28Z", "method": "GET", "ip": "64.227.70.2", "user-agent": "Mozilla/5.0 (l9scan/2.0.3393e24343e22363e2934313; +https://leakix.net)", "path": "/", "status": 200, "latency": 0.000108303}
2026-05-12T13:26:28.921Z INFO request {"time": "2026-05-12T13:26:28Z", "method": "GET", "ip": "64.227.70.2", "user-agent": "Mozilla/5.0 (l9scan/2.0.3393e24343e22363e2934313; +https://leakix.net)", "path": "/___proxy_subdomain_whm/login", "status": 404, "latency": 0.000011368}
2026-05-12T13:26:29.662Z INFO request {"time": "2026-05-12T13:26:29Z", "method": "GET", "ip": "64.227.70.2", "user-agent": "Mozilla/5.0 (l9scan/2.0.3393e24343e22363e2934313; +https://leakix.net)", "path": "/___proxy_subdomain_cpanel", "status": 404, "latency": 0.000275982}
2026-05-12T13:26:30.405Z INFO request {"time": "2026-05-12T13:26:30Z", "method": "GET", "ip": "64.227.70.2", "user-agent": "Mozilla/5.0 (l9scan/2.0.3393e24343e22363e2934313; +https://leakix.net)", "path": "/v2/_catalog", "status": 404, "latency": 0.000010035}
2026-05-12T13:26:31.407Z INFO request {"time": "2026-05-12T13:26:31Z", "method": "GET", "ip": "64.227.70.2", "user-agent": "Mozilla/5.0 (l9scan/2.0.3393e24343e22363e2934313; +https://leakix.net)", "path": "/.DS_Store", "status": 404, "latency": 0.000787072}
2026-05-12T13:26:34.410Z INFO request {"time": "2026-05-12T13:26:34Z", "method": "GET", "ip": "64.227.70.2", "user-agent": "Mozilla/5.0 (l9scan/2.0.3393e24343e22363e2934313; +https://leakix.net)", "path": "/ecp/Current/exporttool/microsoft.exchange.ediscovery.exporttool.application", "status": 404, "latency": 0.000010211}
2026-05-12T13:26:37.403Z INFO request {"time": "2026-05-12T13:26:37Z", "method": "POST", "ip": "64.227.70.2", "user-agent": "Mozilla/5.0 (l9scan/2.0.3393e24343e22363e2934313; +https://leakix.net)", "path": "/graphql", "status": 404, "latency": 0.00003681}
2026-05-12T13:26:38.391Z INFO request {"time": "2026-05-12T13:26:38Z", "method": "POST", "ip": "64.227.70.2", "user-agent": "Mozilla/5.0 (l9scan/2.0.3393e24343e22363e2934313; +https://leakix.net)", "path": "/api", "status": 404, "latency": 0.0000112}
2026-05-12T13:26:39.149Z INFO request {"time": "2026-05-12T13:26:39Z", "method": "POST", "ip": "64.227.70.2", "user-agent": "Mozilla/5.0 (l9scan/2.0.3393e24343e22363e2934313; +https://leakix.net)", "path": "/api/graphql", "status": 404, "latency": 0.00001078}
2026-05-12T13:26:39.962Z INFO request {"time": "2026-05-12T13:26:39Z", "method": "POST", "ip": "64.227.70.2", "user-agent": "Mozilla/5.0 (l9scan/2.0.3393e24343e22363e2934313; +https://leakix.net)", "path": "/graphql/api", "status": 404, "latency": 0.000010063}
2026-05-12T13:26:40.182Z INFO request {"time": "2026-05-12T13:26:40Z", "method": "GET", "ip": "103.4.250.129", "user-agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36", "path": "/", "status": 200, "latency": 0.000120907}
2026-05-12T13:26:40.204Z INFO request {"time": "2026-05-12T13:26:40Z", "method": "GET", "ip": "103.4.251.100", "user-agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/117.0.0.0 Safari/537.36", "path": "/", "status": 200, "latency": 0.000198219}
2026-05-12T13:26:40.703Z INFO request {"time": "2026-05-12T13:26:40Z", "method": "POST", "ip": "64.227.70.2", "user-agent": "Mozilla/5.0 (l9scan/2.0.3393e24343e22363e2934313; +https://leakix.net)", "path": "/api/gql", "status": 404, "latency": 0.000006799}
2026-05-12T13:26:41.442Z INFO request {"time": "2026-05-12T13:26:41Z", "method": "GET", "ip": "64.227.70.2", "user-agent": "Mozilla/5.0 (l9scan/2.0.3393e24343e22363e2934313; +https://leakix.net)", "path": "/s/3393e24343e22363e2934313/_/;/META-INF/maven/com.atlassian.jira/jira-webapp-dist/pom.properties", "status": 404, "latency": 0.000010294}
2026-05-12T13:26:42.452Z INFO request {"time": "2026-05-12T13:26:42Z", "method": "GET", "ip": "64.227.70.2", "user-agent": "Mozilla/5.0 (l9scan/2.0.3393e24343e22363e2934313; +https://leakix.net)", "path": "/config.json", "status": 404, "latency": 0.000538582}
2026-05-12T13:26:44.452Z INFO request {"time": "2026-05-12T13:26:44Z", "method": "GET", "ip": "64.227.70.2", "user-agent": "Mozilla/5.0 (l9scan/2.0.3393e24343e22363e2934313; +https://leakix.net)", "path": "/telescope/requests", "status": 404, "latency": 0.000008417}
2026-05-12T13:26:45.427Z INFO request {"time": "2026-05-12T13:26:45Z", "method": "GET", "ip": "64.227.70.2", "user-agent": "Mozilla/5.0 (l9scan/2.0.3393e24343e22363e2934313; +https://leakix.net)", "path": "/info.php", "status": 404, "latency": 0.000284411}
2026-05-12T13:26:47.307Z INFO request {"time": "2026-05-12T13:26:47Z", "method": "GET", "ip": "64.227.70.2", "user-agent": "Mozilla/5.0 (l9scan/2.0.3393e24343e22363e2934313; +https://leakix.net)", "path": "/actuator/env", "status": 404, "latency": 0.000011169}
2026-05-12T13:26:49.307Z INFO request {"time": "2026-05-12T13:26:49Z", "method": "GET", "ip": "64.227.70.2", "user-agent": "Mozilla/5.0 (l9scan/2.0.3393e24343e22363e2934313; +https://leakix.net)", "path": "/swagger-ui.html", "status": 404, "latency": 0.000300719}
2026-05-12T13:26:50.295Z INFO request {"time": "2026-05-12T13:26:50Z", "method": "GET", "ip": "64.227.70.2", "user-agent": "Mozilla/5.0 (l9scan/2.0.3393e24343e22363e2934313; +https://leakix.net)", "path": "/swagger/index.html", "status": 404, "latency": 0.000011098}
2026-05-12T13:26:51.292Z INFO request {"time": "2026-05-12T13:26:51Z", "method": "GET", "ip": "64.227.70.2", "user-agent": "Mozilla/5.0 (l9scan/2.0.3393e24343e22363e2934313; +https://leakix.net)", "path": "/swagger/swagger-ui.html", "status": 404, "latency": 0.000010815}
2026-05-12T13:26:52.294Z INFO request {"time": "2026-05-12T13:26:52Z", "method": "GET", "ip": "64.227.70.2", "user-agent": "Mozilla/5.0 (l9scan/2.0.3393e24343e22363e2934313; +https://leakix.net)", "path": "/webjars/swagger-ui/index.html", "status": 404, "latency": 0.000010884}
2026-05-12T13:26:53.297Z INFO request {"time": "2026-05-12T13:26:53Z", "method": "GET", "ip": "64.227.70.2", "user-agent": "Mozilla/5.0 (l9scan/2.0.3393e24343e22363e2934313; +https://leakix.net)", "path": "/swagger.json", "status": 404, "latency": 0.000312664}
2026-05-12T13:26:54.402Z INFO request {"time": "2026-05-12T13:26:54Z", "method": "GET", "ip": "64.227.70.2", "user-agent": "Mozilla/5.0 (l9scan/2.0.3393e24343e22363e2934313; +https://leakix.net)", "path": "/swagger/v1/swagger.json", "status": 404, "latency": 0.000009187}
2026-05-12T13:26:55.297Z INFO request {"time": "2026-05-12T13:26:55Z", "method": "GET", "ip": "64.227.70.2", "user-agent": "Mozilla/5.0 (l9scan/2.0.3393e24343e22363e2934313; +https://leakix.net)", "path": "/v2/api-docs", "status": 404, "latency": 0.000009117}
2026-05-12T13:26:56.301Z INFO request {"time": "2026-05-12T13:26:56Z", "method": "GET", "ip": "64.227.70.2", "user-agent": "Mozilla/5.0 (l9scan/2.0.3393e24343e22363e2934313; +https://leakix.net)", "path": "/v3/api-docs", "status": 404, "latency": 0.000007559}
2026-05-12T13:26:57.302Z INFO request {"time": "2026-05-12T13:26:57Z", "method": "GET", "ip": "64.227.70.2", "user-agent": "Mozilla/5.0 (l9scan/2.0.3393e24343e22363e2934313; +https://leakix.net)", "path": "/api-docs/swagger.json", "status": 404, "latency": 0.000008606}
2026-05-12T13:26:58.303Z INFO request {"time": "2026-05-12T13:26:58Z", "method": "GET", "ip": "64.227.70.2", "user-agent": "Mozilla/5.0 (l9scan/2.0.3393e24343e22363e2934313; +https://leakix.net)", "path": "/api/swagger.json", "status": 404, "latency": 0.000010721}
2026-05-12T13:26:59.318Z INFO request {"time": "2026-05-12T13:26:59Z", "method": "GET", "ip": "64.227.70.2", "user-agent": "Mozilla/5.0 (l9scan/2.0.3393e24343e22363e2934313; +https://leakix.net)", "path": "/trace.axd", "status": 404, "latency": 0.000348286}
2026-05-12T13:27:00.303Z INFO request {"time": "2026-05-12T13:27:00Z", "method": "GET", "ip": "64.227.70.2", "user-agent": "Mozilla/5.0 (l9scan/2.0.3393e24343e22363e2934313; +https://leakix.net)", "path": "/@vite/env", "status": 404, "latency": 0.000007613}
2026-05-12T13:27:01.303Z INFO request {"time": "2026-05-12T13:27:01Z", "method": "GET", "ip": "64.227.70.2", "user-agent": "Mozilla/5.0 (l9scan/2.0.3393e24343e22363e2934313; +https://leakix.net)", "path": "/.vscode/sftp.json", "status": 404, "latency": 0.000007697}
2026-05-12T13:27:02.491Z INFO request {"time": "2026-05-12T13:27:02Z", "method": "OPTIONS", "ip": "64.227.70.2", "user-agent": "Mozilla/5.0 (l9scan/2.0.3393e24343e22363e2934313; +https://leakix.net)", "path": "/", "status": 404, "latency": 0.000009754}
2026-05-12T13:27:03.306Z INFO request {"time": "2026-05-12T13:27:03Z", "method": "GET", "ip": "64.227.70.2", "user-agent": "Mozilla/5.0 (l9scan/2.0.3393e24343e22363e2934313; +https://leakix.net)", "path": "/", "status": 200, "latency": 0.000102541}
2026-05-12T13:27:03.552Z INFO request {"time": "2026-05-12T13:27:03Z", "method": "GET", "ip": "172.69.68.126", "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0 Safari/537.36", "path": "/_rNd9xZ7kL3", "status": 404, "latency": 0.000358774}
2026-05-12T13:27:04.319Z INFO request {"time": "2026-05-12T13:27:04Z", "method": "GET", "ip": "64.227.70.2", "user-agent": "Mozilla/5.0 (l9scan/2.0.3393e24343e22363e2934313; +https://leakix.net)", "path": "/debug/default/view", "status": 404, "latency": 0.000007761}
2026-05-12T13:27:16.772Z INFO request {"time": "2026-05-12T13:27:16Z", "method": "GET", "ip": "23.180.120.134", "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36", "path": "/wp-json/gravitysmtp/v1/tests/mock-data", "status": 404, "latency": 0.000014278}
2026-05-12T13:27:50.421Z INFO request {"time": "2026-05-12T13:27:50Z", "method": "GET", "ip": "23.180.120.134", "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36", "path": "/wp-json/gravitysmtp/v1/tests/mock-data", "status": 404, "latency": 0.000014786}
2026-05-12T13:27:56.430Z INFO request {"time": "2026-05-12T13:27:56Z", "method": "GET", "ip": "165.231.182.154", "user-agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/137.0.0.0 Safari/537.36", "path": "/", "status": 200, "latency": 0.000774662}
2026-05-12T13:27:57.030Z INFO request {"time": "2026-05-12T13:27:57Z", "method": "GET", "ip": "165.231.182.154", "user-agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/136.0.0.0 Safari/537.36", "path": "/favicon.ico", "status": 404, "latency": 0.000829975}
2026-05-12T13:27:57.564Z INFO request {"time": "2026-05-12T13:27:57Z", "method": "GET", "ip": "185.225.28.4", "user-agent": "Go-http-client/1.1", "path": "/favicon.ico", "status": 404, "latency": 0.000270651}
2026-05-12T13:27:57.855Z INFO request {"time": "2026-05-12T13:27:57Z", "method": "GET", "ip": "156.146.37.111", "user-agent": "Go-http-client/1.1", "path": "/favicon.ico", "status": 404, "latency": 0.000305837}
2026-05-12T13:28:54.994Z INFO request {"time": "2026-05-12T13:28:54Z", "method": "GET", "ip": "86.57.172.107", "user-agent": "monitor-telegram-clone-realtime/1.0", "path": "/", "status": 200, "latency": 0.000152732}
2026-05-12T13:29:52.888Z INFO request {"time": "2026-05-12T13:29:52Z", "method": "GET", "ip": "188.241.177.119", "user-agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/137.0.0.0 Safari/537.36", "path": "/", "status": 200, "latency": 0.000752463}
2026-05-12T13:29:53.396Z INFO request {"time": "2026-05-12T13:29:53Z", "method": "GET", "ip": "188.241.177.119", "user-agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/136.0.0.0 Safari/537.36", "path": "/favicon.ico", "status": 404, "latency": 0.002784717}
2026-05-12T13:29:53.868Z INFO request {"time": "2026-05-12T13:29:53Z", "method": "GET", "ip": "173.244.42.149", "user-agent": "Go-http-client/1.1", "path": "/favicon.ico", "status": 404, "latency": 0.0003731}
2026-05-12T13:29:54.099Z INFO request {"time": "2026-05-12T13:29:54Z", "method": "GET", "ip": "173.244.42.149", "user-agent": "Go-http-client/1.1", "path": "/favicon.ico", "status": 404, "latency": 0.000362191}

Binary file not shown.

@ -1,22 +1,87 @@
#!/bin/bash
set -e # 出错即退出
set -e
IMAGE_NAME="chunlinwang/myubuntu"
TAG="latest"
CONTAINER_NAME="myubuntu"
TMP_FILE="myubuntu_flat.tar"
DATE=$(date +%Y%m%d_%H%M)
echo "[+] 导出容器文件系统..."
echo "========== 开始重打包 myubuntu (单层干净版) =========="
# 1. 确保容器存在并启动
if ! docker ps -a | grep -q "$CONTAINER_NAME"; then
echo "❌ 容器 $CONTAINER_NAME 不存在!"
exit 1
fi
echo "[+] 启动容器..."
docker start "$CONTAINER_NAME"
echo "[+] 等待容器就绪..."
sleep 3
# 2. 在容器内执行深度清理
echo "[+] 开始在容器内执行清理..."
docker exec "$CONTAINER_NAME" bash -c '
echo "→ 清理宝塔日志和备份..."
rm -rf /www/wwwlogs/*
echo "日志已清理" > /www/wwwlogs/cleaned.log
rm -rf /www/backup/*
echo "→ 清理面板缓存..."
rm -rf /www/server/panel/logs/*
rm -rf /www/server/panel/data/tmp/*
echo "→ 清理 MySQL binlog..."
rm -f /www/server/data/mysql-bin.* /www/server/data/relay-log.* 2>/dev/null
echo "→ 清理 PHP sessions 和临时文件..."
rm -rf /www/server/php/*/var/sessions/* 2>/dev/null
rm -rf /tmp/* /var/log/* /var/tmp/* /root/.cache/* 2>/dev/null
echo "→ 清理 apt 缓存..."
apt-get clean >/dev/null 2>&1
rm -rf /var/lib/apt/lists/*
echo "→ 清理其他大日志..."
find /www -name "*.log" -type f -size +5M -delete 2>/dev/null
echo "清理完成,当前占用情况:"
df -h
du -sh /www/* 2>/dev/null | sort -hr
'
# 3. 停止容器准备导出
echo "[+] 停止容器..."
docker stop "$CONTAINER_NAME"
# 4. 备份旧镜像
echo "[+] 备份旧 latest 为 ${DATE}-old..."
if docker image inspect "${IMAGE_NAME}:${TAG}" >/dev/null 2>&1; then
docker tag "${IMAGE_NAME}:${TAG}" "${IMAGE_NAME}:${DATE}-old"
echo "旧镜像已备份为 ${IMAGE_NAME}:${DATE}-old"
fi
# 5. 导出 + 导入为单层新镜像
echo "[+] 导出容器为单层 tar..."
docker export "$CONTAINER_NAME" -o "$TMP_FILE"
echo "[+] 重新导入镜像(覆盖 $IMAGE_NAME:$TAG..."
echo "[+] 导入为新单层 latest 镜像..."
docker import \
-c 'ENTRYPOINT ["/entrypoint.sh"]' \
"$TMP_FILE" "$IMAGE_NAME:$TAG"
-c 'CMD []' \
"$TMP_FILE" "${IMAGE_NAME}:${TAG}"
echo "[+] 删除临时文件..."
# 6. 清理临时文件
rm -f "$TMP_FILE"
echo "[+] 镜像重打包完成,当前镜像信息:"
docker images | grep "$IMAGE_NAME"
# 7. 完成信息
echo "========== 重打包完成!=========="
echo "新镜像:"
docker images "${IMAGE_NAME}" --format "table {{.Repository}}:{{.Tag}}\t{{.Size}}\t{{.ID}}"
echo "当前磁盘占用:"
df -h
echo "提示:旧镜像已备份为 ${IMAGE_NAME}:${DATE}-old可随时回滚。"

Loading…
Cancel
Save