도커파일 Dockerfile

(Dockerfile에서 넘어옴)

1 개요[ | ]

Dockerfile
도커파일
  • 빌드 방법, 명령어를 써놓은 텍스트 문서
  • 도커는 Dockerfile 에 담긴 명령들을 읽어 들임으로 자동으로 이미지를 생성 할 수 있음

2 주요 지시어(instructions)[ | ]

3 예시 1[ | ]

FROM alpine
RUN apk update && apk add nodejs
COPY . /app
WORKDIR /app
CMD ["node","index.js"]

4 예시 2[ | ]

FROM golang:1.9.2-alpine3.6 AS build

# Install tools required to build the project
# We need to run `docker build --no-cache .` to update those dependencies
RUN apk add --no-cache git
RUN go get github.com/golang/dep/cmd/dep

# Gopkg.toml and Gopkg.lock lists project dependencies
# These layers are only re-built when Gopkg files are updated
COPY Gopkg.lock Gopkg.toml /go/src/project/
WORKDIR /go/src/project/
# Install library dependencies
RUN dep ensure -vendor-only

# Copy all project and build it
# This layer is rebuilt when ever a file has changed in the project directory
COPY . /go/src/project/
RUN go build -o /bin/project

# This results in a single layer image
FROM scratch
COPY --from=build /bin/project /bin/project
ENTRYPOINT ["/bin/project"]
CMD ["--help"]

5 예시 3[ | ]

# Use an official Python runtime as a parent image
FROM python:2.7-slim

# Set the working directory to /app
WORKDIR /app

# Copy the current directory contents into the container at /app
COPY . /app

# Install any needed packages specified in requirements.txt
RUN pip install --trusted-host pypi.python.org -r requirements.txt

# Make port 80 available to the world outside this container
EXPOSE 80

# Define environment variable
ENV NAME World

# Run app.py when the container launches
CMD ["python", "app.py"]

6 같이 보기[ | ]

7 참고[ | ]

  1. deprecated
문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}