Red Hat Training

A Red Hat training course is available for OpenShift Container Platform

9.2.5. 컨테이너 외부에서 명령 실행

이미지의 ENTRYPOINT 를 무효화하여 컨테이너의 시작 동작을 수정하는 명령을 컨테이너에 추가할 수 있습니다. 이는 지정된 시간에 배포당 한 번만 실행할 수 있는 라이프사이클 후크 와 다릅니다.

배포 구성의 spec 필드에 command 매개변수를 추가합니다. 또한 command(command가 존재하지 않는 경우 ENTRYPOINT)를 수정하는 args 필드를 추가할 수 있습니다.

...
spec:
  containers:
    -
    name: <container_name>
    image: 'image'
    command:
      - '<command>'
    args:
      - '<argument_1>'
      - '<argument_2>'
      - '<argument_3>'
...

예를 들어 -jar/opt/app-root/springboots2idemo.jar 인수를 사용하여 java 명령을 실행하려면 다음을 실행합니다.

...
spec:
  containers:
    -
    name: example-spring-boot
    image: 'image'
    command:
      - java
    args:
      - '-jar'
      - /opt/app-root/springboots2idemo.jar
...