도커파일을 활용해 도커 이미지를 생성하는 방법에 대해 정리해보고자 한다.
# 도커파일을 저장할 디렉토리에 생성한다.
$ vim Dockerfile
FROM ubuntu:20.04
# apt 패키지 설치 시 사용자 상호작용을 방지하도록 설정한다.
ARG DEBIAN_FRONTEND=noniteractive
# 도커 컨테이너 환경설정
ENV TZ Asia/Seoul # TZ: Timezone
ENV PYTHONIOENCODING UTF-8
ENV LC_CTYPE C.UTF-8 # LC: locale, LC_CTYE: 대/소문자 변환형식
WORKDIR /root
RUN apt update
# docker build -t 이미지이름:태그 디렉토리
$ docker build -t yoonsy_ubuntu:20.04 ./Documents/Docker/
# vim 도커파일명.Dockerfile
$ vim test.Dockerfile
# docker build -t 이미지이름:태그 디렉토리 **-f 파일디렉토리**
$ docker build -t test_ubuntu:18.06 ./Document/Docker -f ./Document/Docker/test.Dockerfile