Part 2 : Basic Docker OS and Linux CLI
ทำการศึกษาและใช้งาน Docker container
Part 2-1 : Pull & start the container
ทำการตรวจสอบการทำงาน docker container ด้วยคำสั่ง docker ps
$ docker ps
2. ทำการทดสอบ pull image centos มาทดสอบ
$ docker pull centos3. ทำการตรวจสอบด้วยคำสั่ง docker images
$ docker images4. ทำการรัน container ด้วยคำสั่ง
$ docker run -d -t --name <name of docker container> centos 5. ทำการตรวจสอบ container ด้วย docker ps อีกครั้ง
$ docker ps6. เข้าไปใน container เพื่อใช้งาน CentosOS
$ docker exec -it <name of docker container> bash7. ทำการทดสอบการดึง package ดู
$ yum update8. เนื่องจากไม่สามารถติดต่อผ่าน centos server ได้จึงต้องทำการชี้ที่อยู่ไป centos server ที่ออนไลน์
$ cd /etc/yum.repos.d/
$ sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-*
$ sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' /etc/yum.repos.d/CentOS-*9. ทำการทดสอบ update อีกครั้ง
$ yum update -y10. ทำการติดตั้ง package tree แล้วลองใช้งาน
$ yum install tree && treePart 2-2 : Management container
Stop docker container
ออกจาก docker container แล้วพิมคำสั่งหยุดการทำงานของ CentosOS ด้วยคำสั่ง
$ exit$ docker stop <name of docker container>2. ตรวจสอบการทำงานของ docker ด้วยคำสั่ง
$ docker psStart docker container
ทำการ start แล้วเข้าไปยัง docker อีกครั้ง
$ docker start <name of docker container>
$ docker exec -it <name of docker container> bash2. ทดสอบคำสั่งที่เคยติดตั้งไปก่อนหน้า
$ tree /homeSave docker container
เปิด WSL Ubuntu version ที่พึ่งใช้งานไปมาอีกหน้าต่างหนึ่ง แล้วพิมคำสั่งตรวจสอบการทำงานของ docker container
$ docker ps2. ทำการบันทึกการเปลี่ยนแปลงด้วยคำสั่ง
$ sudo docker commit -m "Install tree" <Container ID> <Image>Last updated
Was this helpful?