Windows 10 和 Docker 容器日志/Docker Logging 驱动程序 [英] Windows 10 and Docker container logs / Docker Logging driver

查看:81
本文介绍了Windows 10 和 Docker 容器日志/Docker Logging 驱动程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用带有本机 docker 安装的 Windows 10.

我正在寻找 docker 保存容器日志的位置.
在 Linux 中,Docker 容器日志文件位于以下位置:

/var/lib/docker/containers/container-id/container-id-json.log

但是在 Windows 10 中哪里可以找到它?

解决方案

首先检查这些日志是否在(如

您在此图中看到的命令基于如何在 Windows 上通过 SSH 连接到 Docker VM (MobyLinuxVM)"

<块引用>

从技术上讲,我们不会通过 SSH 进入 VM,我们将创建一个具有完全 root 访问权限的容器,然后从那里访问文件系统.

  • 获取可以访问 Docker 守护进程的容器
  • 以完全 root 访问权限运行容器
  • 切换到主机文件系统

打开命令提示符并执行以下命令:

docker run --privileged -it -v/var/run/docker.sock:/var/run/docker.sock jongallant/ubuntu-docker-clientdocker run --net=host --ipc=host --uts=host --pid=host -it --security-opt=seccomp=unconfined --privileged --rm -v/:/host alpine/bin/shchroot/主机

在那里执行 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:ProgramDatadockercontainers[container_ID][container_ID]-json.log

The Docker C:ProgramDatadocker 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):

  1. Run docker inspect to find your Docker log file location
  2. 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 Logging 驱动程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆