docker run သည် image တစ်ခုကိုအခြေခံပြီး container အသစ်တစ်ခု create + start လုပ်ပေးတဲ့ command ဖြစ်ပါတယ်။ Docker ကိုနေ့စဉ်သုံးရင် အများဆုံးတွေ့ရမယ့် command လည်းဖြစ်ပါတယ်။
အသုံးများသော options
• -d — background မှာ run
• -p — host port နဲ့ container port ချိတ်
• --name — container ကိုနာမည်ပေး
• -e — environment variable ထည့်
• --rm — container ပြီးသွားတာနဲ့ auto remove
# Run Alpine Linux and print a message
# --rm removes the container after the command finishes
docker run --rm alpine echo "hello from docker"
# Run Nginx in the background with a name
docker run --name web-demo -d -p 8080:80 nginxပထမ command က Alpine Linux image ကိုသုံးပြီး message တစ်ကြောင်း print လုပ်ပါတယ်။ Task ပြီးတာနဲ့ --rm ကြောင့် container ကိုဖျက်သွားပါမယ်။ ဒုတိယ command က Nginx web server ကို background မှာ run လုပ်ပြီး web-demo ဆိုတဲ့ name ပေးပါတယ်။
Terminal တွင် hello from docker ပေါ်လာမည်။ Nginx command အတွက် browser မှာ localhost:8080 ဖွင့်နိုင်မည်။Info
Container name ကိုပေးထားရင် နောက်ပိုင်း docker stop web-demo လို command တွေမှာ container ID အရှည်ကြီးမရေးရတော့ပါ။