Intoduction to the Dockerfile

Intoduction to the Dockerfile for beginner

source image : deploybot.com

Docker can build images automatically by reading the instructions from a . A is a text document that contains all the commands a user could call on the command line to assemble an image. source: Dockerfile

create Dockerfile

vim Dockerfile

The content Dockerfile

FROM docker/whalesay:latestRUN apt -y update && apt install -y fortunesCMD /usr/games/fortune -a | cowsay

The instruction initializes a new build stage and sets the Base Image for subsequent instructions. As such, a valid must start with a instruction. The image can be any valid image – it is especially easy to start by pulling an image from the Public Repositories.

RUN has 2 forms:

  • (shell form, the command is run in a shell, which by default is on Linux or on Windows)
  • (exec form)

The instruction will execute any commands in a new layer on top of the current image and commit the results. The resulting committed image will be used for the next step in the .

The instruction has three forms:

  • (exec form, this is the preferred form)
  • (as default parameters to ENTRYPOINT)
  • (shell form)

There can only be one instruction in a . If you list more than one then only the last will take effect.

Build the Dockerfile

sudo docker build -t docker-whale .

see docker image

sudo docker image ls
docker images

Then run image docker-whale

sudo docker run docker-whale
run image docker-whale

Reference : https://docs.docker.com/engine/reference/builder/

This is my little notes based my experiment and my learning. Keep learning and keep calm.

This is my little notes based my experiment and my learning. Keep learning and keep calm.