关于docker:Docker容器清理记录

41次阅读

共计 1112 个字符,预计需要花费 3 分钟才能阅读完成。

查看磁盘空间

df -h

/ 目录占用达到 100%, 剖析可能是 docker 容器数据占用了空间

去 container 目录查看占用状况

cd /var/lib/docker/containers
du -sh {目录} 查看哪个目录有占用空间异样,删除对应文件即可

如我这里是 Gitlab 日志文件占用了 27G:

# 删除 Gitlab 日志文件并重启 Gitlab 容器即可
"LogPath": "/var/lib/docker/containers/f16aa2f0c73a6093b482fc3694119a1b753773fde92f797e8b79e86326515ca3/f16aa2f0c73a6093b482fc3694119a1b753773fde92f797e8b79e86326515ca3-json.log"  

Tips: 查看容器详细信息命令

docker container inspect {容器名}
示例

docker container inspect gitlab
        "ResolvConfPath": "/var/lib/docker/containers/f16aa2f0c73a6093b482fc3694119a1b753773fde92f797e8b79e86326515ca3/resolv.conf",
        "HostnamePath": "/var/lib/docker/containers/f16aa2f0c73a6093b482fc3694119a1b753773fde92f797e8b79e86326515ca3/hostname",
        "HostsPath": "/var/lib/docker/containers/f16aa2f0c73a6093b482fc3694119a1b753773fde92f797e8b79e86326515ca3/hosts",
        "LogPath": "/var/lib/docker/containers/f16aa2f0c73a6093b482fc3694119a1b753773fde92f797e8b79e86326515ca3/f16aa2f0c73a6093b482fc3694119a1b753773fde92f797e8b79e86326515ca3-json.log",


"Binds": [
                "/disk2/data/gitlab/etc:/etc/gitlab",
                "/disk2/data/gitlab/log:/var/log/gitlab",
                "/disk2/data/gitlab/data:/var/opt/gitlab",
                "/etc/localtime:/etc/localtime:ro"
            ],

正文完
 0