miken :
나는의 주요 방법으로 명령 행 인수를 전달하기 위해 노력하고있어 봄 부팅 A의 응용 프로그램 실행 도커 컨테이너 . 명령 줄에서 실행, 내가 이런 짓을 할 것이다 :
$ mvn spring-boot:run -Dspring-boot.run.arguments=--greeting=Hello,--recipient=World
응용의 요구는 이러한 인수를 선택하고 그들과 함께 몇 가지 처리해야 할 일 :
public static void main(String[] args) {
Options options = new Options();
Option greeting = new Option("-g", "greeting", true, "Greeting");
greeting.setRequired(true);
greeting.addOption(greeting);
Option recipient = new Option("-r", "recipient", true, "Recipient");
recipient.setRequired(true);
recipient.addOption(recipient);
try {
cmd = parser.parse(options, args);
} catch (ParseException e) {
System.out.println(e.getMessage());
formatter.printHelp("utility-name", options);
System.exit(1);
}
// Do some processing using these args ...
// Run the Spring Boot app
SpringApplication.run(SpringBootApp.class, args);
}
나는 단순히 사용하여 그들을 통과 시도 -e
플래그 :
docker run -p 8080:8080 -d -e "greeting=Hello" -e "recipient=World" test-image
내 Dockerfile
다음과 같다 :
FROM openjdk:8-jdk-alpine
VOLUME /tmp
COPY ./target/spring-boot-app-0.0.1-SNAPSHOT.jar app.jar
ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/app.jar"]
옵션 (인수)가 필요하기 때문에, 나는 오류 메시지 및 응용 프로그램 종료를받는 유지.
에브 게니 Strepetov :
당신은 당신의 고정 표시기 이미지의 이름 다음에 모든 명령 줄 인수를 제공 할 수있는 run
명령.
예:
docker run -p 8080:8080 test-image --recipient="World"--greeting="Hello"