Thuta Learning
ရှာဖွေရန်
IntermediateDevOps & Toolsintermediate

Dockerfile Intro

စိတ်လျှော့ပါ။ ဒီခန်းကို စာအုပ်လိုမဟုတ်ဘဲ စကားပြောသလိုပဲ၊ နားလည်လွယ်အောင် ရှင်းပါမယ်။

Dockerfile သည် Docker image တစ်ခုကို ဘယ် base image ကနေစမလဲ၊ ဘာ file တွေကူးမလဲ၊ ဘာ command တွေ run မလဲ၊ container စတဲ့အခါ ဘာ command run မလဲဆိုတာကို instruction အနေနဲ့ရေးထားတဲ့ text file ဖြစ်ပါတယ်။ File name ကို extension မပါဘဲ Dockerfile လို့ရေးရပါတယ်။

dockerfile
# Create a file named Dockerfile
FROM nginx:alpine
WORKDIR /usr/share/nginx/html
COPY index.html .
EXPOSE 80

FROM က base image ကိုသတ်မှတ်ပါတယ်။ WORKDIR က container ထဲမှာအလုပ်လုပ်မယ့် folder ကိုရွေးပါတယ်။ COPY က local index.html ကို Nginx web root ထဲကူးပါတယ်။ EXPOSE က container က port 80 ကိုအသုံးပြုမယ်ဆိုတာ document လုပ်ပေးတာပါ။

You should see
ဒီ Dockerfile ကို build လုပ်ပြီး run လုပ်ပါက ကိုယ့် index.html ကို Nginx မှတစ်ဆင့် browser မှာပြနိုင်မည်။

Info

EXPOSE ရေးထားတာနဲ့ host computer ကနေ auto access ရတာမဟုတ်ပါ။ Browser ကနေဝင်ဖို့ docker run -p 8080:80 လို port mapping လုပ်ရပါမယ်။

ဒီနေရာမှာ လူအများမှားတတ်တယ်

  • Dockerfile နဲ့ index.html တူညီတဲ့ folder ထဲမှာမရှိရင် COPY index.html . မှာ file not found error ဖြစ်နိုင်ပါတယ်။
Dockerfile Intro | Thuta Learning