Thuta Learning
Docker
IntermediateDevOps & Toolsအလယ်အလတ်

Dockerfile Intro

Dockerသင်ခန်းစာ 10

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 ဖြစ်နိုင်ပါတယ်။

နောက်ဆုံးပြင်ဆင်ရက်

Progress ကို ဤ browser (ဤစက်) တွင်သာ သိမ်းထားပါသည်။ အခြားစက်များနှင့် sync မလုပ်ပါ။

ဤသင်ခန်းစာတွင် အမှားတွေ့ပါက အကြောင်းကြားရန်သင့် email app ကို ဤသင်ခန်းစာလိပ်စာ ဖြည့်ပြီးသားဖြင့် ဖွင့်ပေးပါမည် — သင်ကိုယ်တိုင် ပို့မှသာ ပို့မည်ဖြစ်သည်။

Dockerfile Intro | Thuta Learning