清理mac的docker desktop的容器日志
查看容器的日志位置docker inspect --format=’{{.LogPath}}’ logstash7.7.1logstash7.7.1为容器id得到位置’/var/lib/docker/containers/e9a256441db1ba08d9bdea7bbdac05bf099beec720739b5472ab9d19b898c3bc/e9a256441db1ba08d9bdea7b
可删除容器重新创建容器,在容器内的日志也会被删除
如果不删除容器,可以按照以下的方法清理日志
查看容器的日志位置
docker inspect --format=’{{.LogPath}}’ logstash7.7.1
logstash7.7.1为容器名字
得到位置
’/var/lib/docker/containers/1aedc07dd46d02a76836f899db32d797cd55c16f7cc71ff577c5242c6c6963c3/1aedc07dd46d02a76836f899db32d797cd55c16f7cc71ff577c5242c6c6963c3-json.log’
进入docker虚拟机
使用命令
screen ~/Library/Containers/com.docker.docker/Data/vms/0/tty
默认进入的页面是空白的,输入
exit;
进入页面
Welcome to LinuxKit
## .
## ## ## ==
## ## ## ## ## ===
/"""""""""""""""""__/ ===
{ / ===-
_____ O __/
__/
_________/
docker-desktop login: root (automatic login)
Welcome to LinuxKit!
NOTE: This system is namespaced.
The namespace you are currently in may not be the root.
System services are namespaced; to access, use `ctr -n services.linuxkit ...`
login[9792]: root login on 'ttyS0'
docker-desktop:~#
找到对应的容器目录
docker-desktop:~# pwd
/root
docker-desktop:~# cd /var/lib/docker/containers/
docker-desktop:/var/lib/docker/containers# ls
1aedc07dd46d02a76836f899db32d797cd55c16f7cc71ff577c5242c6c6963c3
58f13fb344f6ba66ba4acb5dc93cb5366b920941b9a9d389da30042a530a49a5
68c7b23b98b5e1696a7edda0050c8712908022b8d41cff9e26192c26795afe66
6bed113a74815535a78d4ebbfc3e3708178a7db53155ed62c628fa6e85f433e1
83a28c3a5b85c7377801612880bbd52f3d854eb035f439e6ce7635e6ca1bd55e
c59d913c95a4c40f2bb93db8ac6f2f3e4d701234145082134cca6de9d5d059eb
docker-desktop:/var/lib/docker/containers# cd 1aedc07dd46d02a76836f899db32d797cd
55c16f7cc71ff577c5242c6c6963c3
docker-desktop:/var/lib/docker/containers/1aedc07dd46d02a76836f899db32d797cd55c16f7cc71ff577c5242c6c6963c3# ls
1aedc07dd46d02a76836f899db32d797cd55c16f7cc71ff577c5242c6c6963c3-json.log
checkpoints
config.v2.json
hostconfig.json
hostname
hosts
mounts
resolv.conf
resolv.conf.hash
docker-desktop:/var/lib/docker/containers/1aedc07dd46d02a76836f899db32d797cd55c16f7cc71ff577c5242c6c6963c3# rm -r 1aedc07dd46d02a76836f899db32d797cd55c16f7cc71f
f577c5242c6c6963c3-json.log
删除后重新启动容器,就会生成新的日志文件。
rm -r 1aedc07dd46d02a76836f899db32d797cd55c16f7cc71f f577c5242c6c6963c3-json.log
ctrl+a 、ctrl+d退出,如果需要关闭当前的窗口,就ctrl+a 、ctrl+k
查看目前的列表
screen -ls
重新连接窗口
screen -r 窗口号
更多命令
screen --help
连接的socket放在以下位置:
/var/folders/xb/6c_3gglx7_v00110l6kvpmy80000gp/T/.screen
更多推荐
所有评论(0)