簡體   English   中英

關於docker-java的withCmd命令

[英]About the withCmd command of docker-java

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

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

我正在更改用戶密碼! 但它實際上變成了 output 字符串就像我在 linux 下執行echo "test:111 | chpasswd"時我怎樣才能讓它執行命令echo test:111 | chpasswd echo test:111 | chpasswd

為什么不嘗試使用 shell 命令

.withCmd("sh", "-c", "echo 'test:111' | chpasswd")

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM