Dockerfile ONBUILD

Pyro·2021년 8월 27일
0

Docker

목록 보기
6/7

ONBUILD 명령어를 통해, 만약 다른 사람이 내 이미지를 베이스로 해서 새로운 이미지를 빌드할 때, 새로운 이미지의 빌드시기에 특정 명령어를 강제할 수 있다.

Dockerfile.base

FROM ubuntu:18.04

ONBUILD RUN echo "Hello, World!"

# sudo docker build -t base -f Dockerfile.base .

Dockerfile

FROM base

docker build -t base -f Dockerfile.base .
docker build -t hello .

base 를 빌드한 이후에 hello 를 빌드하면 아래 이미지 처럼 Hello World 가 echo 된 것을 확인할 수 있다.

profile
dreams of chronic and sustained passion

0개의 댓글