1. 목적

Dockerfile을 만들 때 필요한 주요 옵션과 이들의 관계 파악

2. What is Dockerfile?

도커 이미지를 빌드할 때 사용할 파일(docs : Docker builds images by reading the instructions from a Dockerfile.) - What is 도커 이미지?

Dockerfile에 작성된 명령어를 통해 이미지를 빌드합니다.

3. Dockerfile 생성과 함께 보는 주요 명령어

python3.12 버전 이미지를 기반으로 /app의 실행 위치로 설정해 requirement.txt를 복사해서 설치해 jupyter를 실행하는 Dockerfile

FROM python:3.12

WORKDIR /app

COPY ./requirement.txt .

RUN pip install --upgrade pip
RUN pip install -r requirements.txt

EXPOSE 8888

CMD ["jupyter", "notebook"]

4. Dockerfile 빌드

# 같은 경로(명령어를 실행 할 디렉터리)에 Dockerfile이 있어야 한다.
$ docker buildx build -t [tag_name] .

# 만약 파일명이 Dockerfile이 아닌 다른 파일명(Dockerfile-ubuntu)인 경우
$ docker buildx build -t [tag_name] -f Dockerfile-ubuntu .