Reputation: 2920
I want to execute the following command in my dockerfile:
java -jar kafka-connect-cli-1.0.6-all.jar create cassandra-sink-orders < cassandra-sink-distributed-orders.properties
This is what I have tried but it gives me error:
Cannot execute cassandra-sink-orders < cassandra-sink-distributed-orders.properties
CMD ["java", "-jar", "kafka-connect-cli-1.0.6-all.jar", "create", "cassandra-sink-orders", "<", "cassandra-sink-distributed-orders.properties"]
Upvotes: 0
Views: 129
Reputation: 5389
You can also run it in this way :
CMD "java -jar kafka-connect-cli-1.0.6-all.jar create cassandra-sink-orders < cassandra-sink-distributed-orders.properties"
Upvotes: 0
Reputation: 38024
Output redirection using <
is a shell feature. When supplying a JSON list to CMD
, the command will not be executed by a shell.
To use shell feature, use one of the following forms:
CMD ["sh", "-c", "java -jar kafka-connect-cli-1.0.6-all.jar create cassandra-sink-orders < cassandra-sink-distributed-orders.properties"]
CMD java -jar kafka-connect-cli-1.0.6-all.jar create cassandra-sink-orders < cassandra-sink-distributed-orders.properties
From the documentation:
The CMD instruction has three forms:
CMD ["executable","param1","param2"]
(exec form, this is the preferred form)CMD ["param1","param2"]
(as default parameters to ENTRYPOINT)CMD command param1 param2
(shell form)[...]
Note: Unlike the shell form, the exec form does not invoke a command shell. This means that normal shell processing does not happen. For example,
CMD [ "echo", "$HOME" ]
will not do variable substitution on$HOME
. If you want shell processing then either use the shell form or execute a shell directly, for example:CMD [ "sh", "-c", "echo $HOME" ]
.
Upvotes: 2