I'm trying to run this command in docker trough java, but i don't know why it only works when i execute the command in the host machine and not trough java (when execute on java it doesn't add or say nothing). i'm 99% sure problem are the ">>" of the echo but i don't know how to fix it.
private void doCommand(){
String command = "docker exec -i -t vsftpd bash -c 'echo -e \"myuser5\\nmypass\" >> /etc/vsftpd/virtual_users.txt'";
try {
ProcessBuilder pb = new ProcessBuilder(command);
Process process = pb.start();
InputStream inputStream = process.getInputStream();
BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
String line = null;
while ((line = reader.readLine()) != null) {
System.out.println(line);
}
}catch (Exception e){
e.printStackTrace();
}
}
Error has been resolved, fixed by using https://github.com/docker-java/docker-java