도커 파일은 명령어 + 인자로 이루어진다
EX) FROM ubuntu
이런식으로 도커 파일이 작성된다.
도커 파일 관련 명령어에 대해 알아보자
FROM <image>
FROM <image>:<tag>
FROM ubuntu
FROM ubuntu:16.04
FROM python:3.8-alpine
WORKDIR <이동할 경로>
WORKDIR /usr/app
WORKDIR
RUN ["<커맨드>", "<파라미터1>", "<파라미터2>"]
RUN <전체 커맨드>
RUN apk add curl
RUN pip install -r requirements.txt
CMD [“executable”,”param1”,”param2”] (exec form, this is the preferred form)
CMD [“param1”,”param2”] (as default parameters to ENTRYPOINT)
CMD command param1 param2 (shell form)
FROM ubuntu
CMD echo "This is a test."
$ docker run -it --rm <image-name>
This is a test
$ docker run -it --rm <image-name> echo "Hello"
Hello
ENTRYPOINT ["touch"]
CMD{"/home/hello.txt"]
COPY <복사할 파일> <복사 위치>
COPY test.txt .
ADD <다운받은파일> <저장할 위치>
ADD https://example.com/big.tar.xz /usr/src/things/
FROM centos:7
COPY test.sh /root/mkdir/test.sh
ENV DIR=/root/mkdir/
RUN echo ${DIR}
CMD ${DIR}/test.sh
FROM centos:7
COPY test.sh /root/mkdir/test.sh
ARG DIR=/root/mkdir/
RUN echo ${DIR}
CMD ${DIR}/test.sh
LABEL title="webserver"
LABEL version="2.0"
VOLUME ["컨테이너 디렉터리1", "컨테이너 디렉터리2"]
USER <user명> <group명>
USER <UID> <GID>
EXPOSE 80/tcp
EXPOSE 80/udp