简体   繁体   English

使用docker exec作为标签传递命令行参数

[英]Pass command line arguments with docker exec as a tag

I have a main.java function that uses command like arguments to run processes specific to the input. 我有一个main.java函数,该函数使用类似参数的命令来运行特定于输入的进程。 I am now running the java project through a docker container. 我现在正在通过Docker容器运行Java项目。 I would need the command be similar to 我需要命令类似于

docker exec -it container_id -argument1

How would I specify in dockerfile what "-argument1" is and to send it to the main.java for execution? 如何在dockerfile中指定“ -argument1”是什么并将其发送到main.java以便执行?

One way would be to pass your arguments as environment variables. 一种方法是将参数作为环境变量传递。 Ex: docker exec -it <container_id> -e "FOO=BAR" <command> 例如: docker exec -it <container_id> -e "FOO=BAR" <command>

Then use System.getenv("FOO"); 然后使用System.getenv("FOO"); to get the value. 获得价值。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM