Dockerfile
- Dockerfile has instructions in the form of
INSTRUCTION <value>
-
Lets look at the instruction reference
-
In Docker hub we have 3 types of images
- official images are released by docker
- Verified publishers or sponsored oss
-
Docker image naming convention for official images
<application-name>:<version>
tomcat:9
mysql:8.10
- Docker image naming convention for Verified publishers or sponsored oss
<organization>/<application-name>:<version>
jenkins/jenkins:2.555.2-lts
<account-name>/<app>:<version>
shaikkhajaibrahim/openmrs:latest
- what we are referring as version above, docker calls it as tag, if you dont specify it considers latest as default tag
Most widely used instructions
FROM
-
We select the base image
-
Refer Here for official docs
-
Prompt
You are an expert in Docker
I'm learning how to write Dockerfile
Explain the purpose of instruction FROM
Give me few examples
After that once i read, ask few questions and help me understand instruction completely
- Sample Docker file FROM instructions
FROM nginx
FROM alpine:2
FROM python:3.12
FROM --platform=linux/arm/v7 alpine
FROM --platform=linux/amd64 alpine
Experiment 1
- Lets create a docker image with only FROM instruction
- Create a Dockerfile
FROM alpine
- Now lets build a image called as myalpine
docker image build -t myalpine .
- Now execute command
docker image ls
Learning docker command line
- Start with a cheatsheet
- use –help
- Prompt
Give me a docker command for building an image
Also explain arguments and give me widely used command line combinations
Next Instructions
- RUN -> Run a command used for installing or configuring
- ADD/COPY -> Copy files into image
- EXPOSE -> specify port on which your application works
- ENTRYPOINT/CMD -> Specify the command that starts your application.