0

我想问我如何使用 withCmd 方法如下:

commands = new String[]{"echo","test:111 | chpasswd"};
ExecCreateCmdResponse execCreateCmdResponse = dockerClient.execCreateCmd("b6b571d5469a")
       .withCmd(commands).withAttachStdout(true).withAttachStderr(true).exec();

我正在更改用户密码!但它实际上变成了输出字符串就像我 echo "test:111 | chpasswd"在linux下执行时我怎样才能让它执行命令echo test:111 | chpasswd

4

1 回答 1

0

为什么不尝试使用 shell 命令

.withCmd("sh", "-c", "echo 'test:111' | chpasswd")
于 2021-05-11T18:32:39.693 回答