命令 `docker` 不能与管道一起使用。不要使用`|`、`>`、`>>`
Command `docker` can not work with pipeline. Do not work with `|`, `>`, `>>`
我想通过命令 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
也没用。
那是因为,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
我想通过命令 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
也没用。
那是因为,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