-2

I have a docker container called pps-control. If I want to execute a script that lives inside the container which for this example takes 1 arg, I do from my linux terminal:

docker exec pps-control /bin/sh -c "./build/doControlStuff.sh 123456"

My question is: How do I achieve doing the same using java code? I know that there is something like:

package com.mypackage;
import static com.palantir.docker.compose.execution.DockerComposeExecArgument.arguments;
import static com.palantir.docker.compose.execution.DockerComposeExecOption.options;
import com.palantir.docker.compose.DockerComposeRule;

public class TestClass {
    public static DockerComposeRule docker;
    public static void testMethod() {
        docker.exec(options(), "pps-control", arguments("bash", "-c", "./build/doControlStuff.sh 123456"));
    }
}

But haven't been able to figure out how to use it (with correct syntax), any help would be appreciated with actual code example, thanks!

My Docker version is 18.03.0-ce, build 0520e24
Saffik
  • 689
  • 9
  • 28

1 Answers1

0

I think your last argument should be “\”build/doControlStuff.sh 123456\””.

Timir
  • 1,337
  • 8
  • 15