Windows 10和Docker容器日志/ Docker日志记录驱动程序 [英] Windows 10 and Docker container logs / Docker Logging driver
问题描述
我正在使用Windows 10和本地docker安装。
我正在寻找docker保存容器日志的位置。
在Linux中,Docker容器日志文件位于以下位置:
/var/lib/docker/containers/container-id/container-id-json.log
但是我在Windows 10中哪里可以找到它?
首先检查这些日志是否存在(如
您在此图中看到的命令基于 如何通过SSH进入Windows上的Docker VM(MobyLinuxVM)
从技术上讲,我们不会通过SSH进入虚拟机,我们将创建一个具有完全根访问权限的容器,然后从那里访问文件系统。
- 获取具有Docker Daemon访问权限的容器
- 运行具有完全root访问权限的容器
- 切换到主机文件系统
打开命令提示符并执行以下命令:
docker run --privileged -it -v /var/run/docker.sock:/var/run/docker.sock jongallant / ubuntu-docker-client
docker run --net = host --ipc = host --uts = host --pid = host -it --security-opt = seccomp = unconfined --privileged --rm- v /:/ host alpine / bin / sh
chroot / host
执行find命令在那里,您应该找到日志。
I'm using Windows 10 with native docker installation.
I'm looking for the location where docker save the containers logs.
In Linux, the Docker containers log files are in this location:
/var/lib/docker/containers/container-id/container-id-json.log
But where can I find it in windows 10 ?
Check first if those logs are in (as suggested here):
C:\ProgramData\docker\containers\[container_ID]\[container_ID]-json.log
The Docker C:\ProgramData\docker
is the Root Dir
reported by docker info
.
Regarding Docker Linux through Hyper-v, check if "How to Delete Docker Container Log Files (Windows or Linux) " can help (from Jon Gallant):
- Run docker inspect to find your Docker log file location
- Find the "Docker Root Dir" Value, mine is /var/lib/docker
Your docker log file path should be
/var/lib/docker
, but if it isn’t, then change it in the command below.
find /var/lib/docker/containers/ -type f -name "*.log"
The command you see in this image is based on "How to SSH into the Docker VM (MobyLinuxVM) on Windows"
We aren’t technically going to SSH into the VM, we’ll create a container that has full root access and then access the file system from there.
- Get container with access to Docker Daemon
- Run container with full root access
- Switch to host file system
Open a Command prompt and execute the following:
docker run --privileged -it -v /var/run/docker.sock:/var/run/docker.sock jongallant/ubuntu-docker-client
docker run --net=host --ipc=host --uts=host --pid=host -it --security-opt=seccomp=unconfined --privileged --rm -v /:/host alpine /bin/sh
chroot /host
Execute the find command there, and you should find the logs.
这篇关于Windows 10和Docker容器日志/ Docker日志记录驱动程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!