Dockerfile

スポンサーリンク

Dockerfile

Dockerfile is a blueprint of docker image.

To build this, we can create new docker image.

Steps

  • Prepare Dockerfile
  • Build dockerfile

To build dockerfile, run following

docker build .

. is current directly and docker context

Layer

One line has one Layer.

But too much

Especially, we need to install a lot of packages to prepare environments we want to use.

In this case, we can use && commands to combine commands

Example

FROM ubuntu:latest
RUN apt-get update && apt-get install nginx \
apt-get install curl \
apt-get install essential-build

Dockerfile description

DescriptionExplanationExample
FROMOriginal docker imageFROM ubuntu:latest
USERUse this userUSER vault
ARGAdd argumentsARG key=”value”
ENTRYPOINTExecute command(cannot override)ENTRYPOINT [“java”, “-jar”, “/app.jar”]
RUNExecute command(can override)RUN touch test
CMDRun command(not create layer)
Describe at the bottom of Dockerfile
CMD [“executable”, “param1”, “param2”]
CMD [“ls”]
COPYCopy folder, file

COPY <src> <dst>
COPY test.txt /newdir/
ADDCopy file (tar etc…)ADD compress.tar /
Server
スポンサーリンク
Professional Programmer2

コメント