我想搜索命令docker
输出的一些文本,但似乎不适用于管道。
我的预期结果docker > a
应该将终端中的所有输出写入文件a。并且docker | grep info
的预期结果应该打印出包含info Display system-wide information
的内容。
我将自己添加到了组docker。 以下是测试案例。
lala@ubu:~/projects/docker 14:19:42 $ grep docker /etc/group docker:x:999:lala lala@ubu:~/projects/docker 14:19:47 $ ls -al 总用量 8 drwxr-xr-x 2 lala lala 4096 1月 10 14:15 . drwxr-xr-x 10 lala lala 4096 1月 10 10:21 .. lala@ubu:~/projects/docker 14:19:57 $ ls -al | grep x drwxr-xr-x 2 lala lala 4096 1月 10 14:15 . drwxr-xr-x 10 lala lala 4096 1月 10 10:21 .. lala@ubu:~/projects/docker 14:20:01 $ docker Usage: docker [OPTIONS] COMMAND A self-sufficient runtime for containers Options: ...... unnecessary output Run 'docker COMMAND --help' for more information on a command. lala@ubu:~/projects/docker 14:20:03 $ docker | grep x Usage: docker [OPTIONS] COMMAND A self-sufficient runtime for containers Options: ...... the same as above. unnecessary output Run 'docker COMMAND --help' for more information on a command. lala@ubu:~/projects/docker 14:20:15 $ docker > a Usage: docker [OPTIONS] COMMAND A self-sufficient runtime for containers Options: ...... the same as above again. unnecessary output Run 'docker COMMAND --help' for more information on a command. lala@ubu:~/projects/docker 14:21:26 $ cat a lala@ubu:~/projects/docker 14:21:28 $ file a a: empty lala@ubu:~/projects/docker 14:21:30 $
docker >> a
也不起作用。
答案 0 :(得分:0)
这是因为docker命令需要一些参数来重现错误,您可以使用以下命令:
docker 2>&1| grep info
输出:
-l, --log-level string Set the logging level ("debug"|"info"|"warn"|"error"|"fatal") (default "info")
-v, --version Print version information and quit
info Display system-wide information
inspect Return low-level information on Docker objects
version Show the Docker version information
Run 'docker COMMAND --help' for more information on a command.
无论如何,正确的方法是键入:
docker info --help
输出:
Usage: docker info [OPTIONS]
Display system-wide information
Options:
-f, --format string Format the output using the given Go template