gpt4 book ai didi

docker - Dockerfile RUN命令

转载 作者:行者123 更新时间:2023-12-02 21:18:04 25 4
gpt4 key购买 nike

我想在我的dockerfile中执行以下命令:

java -jar kafka-connect-cli-1.0.6-all.jar create cassandra-sink-orders < cassandra-sink-distributed-orders.properties

这是我尝试过的,但给我错误:

无法执行cassandra-sink-orders
CMD ["java", "-jar", "kafka-connect-cli-1.0.6-all.jar", "create", "cassandra-sink-orders", "<", "cassandra-sink-distributed-orders.properties"]

最佳答案

使用<的输出重定向是一个shell功能。当将JSON列表提供给CMD时,shell将不会执行该命令。

要使用 shell 功能,请使用以下形式之一:

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

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" ].

关于docker - Dockerfile RUN命令,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49015121/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com