July 31, 2020

[Docker] วิธีการใช้ Docker เบื้องต้น

Docker เป็น platform ที่สามารถรันโปรแกรมให้แยกจากกันได้โดยใช้ container ซึ่งจะคล้ายๆกับ VM แต่จะแตกต่างตรงที่ VM Container ใช้ os ชุดเดียวกันเลยแต่ VM สามารถใช้ที่แตกต่างได้ ดังนั้น overhead จะน้อยกว่าการใช้ VM

 

ข้อแตกต่างหลักระหว่าง Container กับ VM

Docker --> ใช้ Host OS เดียวกัน

VM --> ใช้ Guest OS ของใครของมัน

ภาพจาก Docker

 

Image VS Container

Image ตัวต้นแบบของ Container ซึ่งข้างในจะประกอบไปด้วย application ต่างๆ  โดยอ้างอิงด้วยชื่อ Repository กับ tag ซึ่งสามารถโหลดได้จาก Registry โดย default จะเป็น docker hub

Container เป็นกล่อง ที่นำ image มาใส่ และทำการ config เช่น cpu ram disk network หรือ Config ของ application ต่างๆให้พร้อมใช้งาน

 

 

เช็ค Version

docker --version

docker -v

 

Pull Image

การดึง Image จาก repository

docker pull <repository>:<tag>

docker history <repository>:<tag> ดู Image สร้างมาจากอะไรบ้าง

 

Create Container & Run

docker run  --name <Container Name> -d -p <Host port>:<Container port> -v <Host path>:<Container path> <repository>:<tag>

 

ดู Process ที่ Run อยู่

docker ps --> ดู Container ที่ Run อยู่

 

Stop Container

docker stop <id>

docker stop <container name>

 

Delete Container

docker rm <container id>

docker rm <container name>

docker rm -v $(docker ps -aq -f status=exited) ลบ container ที่ stop อยู่

 

ดู Image ทั้งหมด

docker image --> ดู Image ทั้งหมด

 

ลบ Image

docker rmi <image id>

docker rmi <anme>:<version>

April 2024
S M T W T F S
 123456
78910111213
14151617181920
21222324252627
282930  

Who We Are

Wealth Management System Limited (WMSL) is a leading financial software company in Thailand. We provide reliable, trusted solutions to financial institutions in asset, treasury and risk management. With our innovative software systems and value added consulting services, we help our customers significantly improve their operational efficiency, reduce costs and minimize risks.

Contact Info

Chin Pong Building, 383 Ladya Road, Klongsan, Bangkok 10600 Thailand

Phone: +66(0) 2-861-4820 Ext. 5620-5622, 5628, 5629
Fax: +66 (0) 2-861-4400
Email: marketing@wealth.co.th

Weekdays: 8:00 am - 5:00 pm
Saturday & Sunday: Closed

Copyright © 2022 WMSL. All Rights Reserved