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

docker build

Dockerသင်ခန်းစာ 11

docker build သည် Dockerfile ကိုဖတ်ပြီး image အသစ်တစ်ခုတည်ဆောက်ပေးပါတယ်။ ဒီအဆင့်က ကိုယ်ရေးထားတဲ့ app ကို reusable image အဖြစ်ပြောင်းတဲ့အဆင့်ပါ။

dockerfile
# In the same directory as your Dockerfile
docker build -t my-custom-nginx:1.0 .

# Run the image as a container
docker run --name my-site -d -p 8080:80 my-custom-nginx:1.0

# Open http://localhost:8080 in your browser

-t my-custom-nginx:1.0 က image ကို name နဲ့ tag ပေးတာပါ။ နောက်ဆုံးက . က build context ဖြစ်ပြီး လက်ရှိ folder ထဲက Dockerfile နဲ့လိုအပ်တဲ့ files တွေကို Docker build process ထဲပို့ပေးပါတယ်။

You should see
Build steps များပြီးဆုံးပါက my-custom-nginx:1.0 image ထွက်လာပြီး browser မှာ site ကိုကြည့်နိုင်ပါမယ်။

Info

Build context ထဲမှာမလိုတဲ့ large files တွေများရင် build နှေးနိုင်ပါတယ်။ Real project မှာ .dockerignore file ထည့်ပြီး node_modules, logs, cache files များကို exclude လုပ်သင့်ပါတယ်။

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

  • . မထည့်မိရင် docker build က context မသိလို့ error ဖြစ်ပါမယ်။ Command အဆုံးက dot လေးက သေးပေမယ့် အရေးကြီးပါတယ်။

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

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

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

docker build | Thuta Learning