如何在没有日志的情况下在后台运行dockerd

时间:2019-02-24 13:45:58

标签: docker containers docker-dind

我正在使用franela/dind图片进行重击:
docker run --rm --privileged -it franela/dind bash

*确保在运行/etc/docker/daemon.json之前先删除dockerd

在其中运行dockerd,它开始打印大量日志:

WARN[2019-02-24T13:40:16.902536038Z] could not change group /var/run/docker.sock to docker: group docker not found 
INFO[2019-02-24T13:40:16.922239343Z] libcontainerd: started new docker-containerd process  pid=880
INFO[2019-02-24T13:40:16.922290278Z] parsed scheme: "unix"                         module=grpc
INFO[2019-02-24T13:40:16.922302876Z] scheme "unix" not registered, fallback to default scheme  module=grpc
INFO[2019-02-24T13:40:16.922360290Z] ccResolverWrapper: sending new addresses to cc: [{unix:///var/run/docker/containerd/docker-containerd.sock 0  <nil>}]  module=grpc
INFO[2019-02-24T13:40:16.922373417Z] ClientConn switching balancer to "pick_first"  module=grpc
INFO[2019-02-24T13:40:16.922423556Z] pickfirstBalancer: HandleSubConnStateChange: 0xc4203c96e0, CONNECTING  module=grpc
INFO[0000] starting containerd                           revision=468a545b9edcd5932818eb9de8e72413e616e86e version=v1.1.2
INFO[0000] loading plugin "io.containerd.content.v1.content"...  type=io.containerd.content.v1
INFO[0000] loading plugin "io.containerd.snapshotter.v1.btrfs"...  type=io.containerd.snapshotter.v1

我尝试在没有日志的情况下运行它,但是我尝试的所有操作都无济于事:

# run as a background process
dockerd &  
# redirect the output to /dev/null
dockerd > /dev/null
# try to remove the logs with the --log-level switch
dockerd --log-level error  

如何在没有所有这些日志的情况下运行dockerd服务?使它处于完全模式。

1 个答案:

答案 0 :(得分:2)

来自dockerd的日志将打印到stderr。您可以将其重定向到文件并在后台运行,如下所示:

sudo docker run --privileged --rm -ti --entrypoint sh docker:18-dind
dockerd &> dockerd-logfile &

# check out the log stream, to cancel use ctrl+c
tail dockerd-logfile

# just to see it's still running
ps -ef

当然,您也可以丢弃所有与尝试过的日志类似的日志:dockerd &> /dev/null &