I want to run this command inside a container: java -jar bin/felix.jar > log.txt
If I manually do:
frog@gooseberry:~/path$ sudo docker run -it 5fe6598e0648 /bin/bash
root@9beabfb5e852:/path# java -jar bin/felix.jar > log.txt
[... program running ...]
Everything works, but if I try to launch it with:
frog@gooseberry:~/path$ sudo docker run -d 5fe6598e0648 "java -jar bin/felix.jar > log.txt"
I get the following error:
857bb5fcdbd7a315517bc9031d65b26abcaaad1fac7a29574e39a0289d0d77a3
2014/10/20 10:20:53 Error response from daemon: Cannot start container 857bb5fcdbd7a315517bc9031d65b26abcaaad1fac7a29574e39a0289d0d77a3: exec: "java -jar bin/felix.jar > log.txt": stat java -jar bin/felix.jar > log.txt: no such file or directory
I get the same error if I try to use the inverted commas ''
instead of the double commas ""
.
I want to use commas because of > log.txt
part, that otherwise would be interpreted by the terminal running on the host machine.
This answer suggest to use the -c
option of /bin/bash
. It bypasses the problem (and it works), but there is a solution provided by Docker to this problem? How command line arguments should be managed with the command docker run
?