Skip to content

Docker

Build, run, inspect, and manage Docker containers.

6 modules

ModuleDescription
สร้าง Docker Imageสร้าง Docker image จาก Dockerfile
ตรวจสอบ Docker Containerรับข้อมูลรายละเอียดเกี่ยวกับ Docker container
รับบันทึกคอนเทนเนอร์รับบันทึกจากคอนเทนเนอร์ Docker
รายการคอนเทนเนอร์ Dockerรายการคอนเทนเนอร์ Docker
รัน Docker Containerรัน Docker container จาก image
หยุด Docker Containerหยุด Docker container ที่กำลังรัน

Modules

สร้าง Docker Image

docker.build

สร้าง Docker image จาก Dockerfile

Parameters:

NameTypeRequiredDefaultDescription
pathstringYes-เส้นทางไปยังไดเรกทอรีบริบทการสร้าง
tagstringYes-ตั้งชื่อและแท็กให้กับ image (เช่น myapp:latest)
dockerfilestringNo-เส้นทางไปยัง Dockerfile (สัมพันธ์กับบริบทการสร้าง)
build_argsobjectNo-ตัวแปรขณะสร้าง (เช่น {"NODE_ENV": "production"})
no_cachebooleanNoFalseไม่ใช้แคชเมื่อสร้าง image

Output:

FieldTypeDescription
image_idstringID ของ image ที่สร้าง
tagstringแท็กที่ใช้กับ image
sizestringขนาดของ image ที่สร้าง

Example: Build from current directory

yaml
path: .
tag: myapp:latest

Example: Build with custom Dockerfile and args

yaml
path: ./backend
tag: myapi:v1.0
dockerfile: Dockerfile.prod
build_args: {"NODE_ENV": "production"}
no_cache: true

ตรวจสอบ Docker Container

docker.inspect_container

รับข้อมูลรายละเอียดเกี่ยวกับ Docker container

Parameters:

NameTypeRequiredDefaultDescription
containerstringYes-ID หรือชื่อของ container ที่จะตรวจสอบ

Output:

FieldTypeDescription
idstringID สั้นของ container
namestringชื่อคอนเทนเนอร์
stateobjectสถานะของคอนเทนเนอร์ (สถานะ, กำลังทำงาน, pid, รหัสออก, ฯลฯ)
imagestringอิมเมจที่ใช้โดยคอนเทนเนอร์
network_settingsobjectการตั้งค่าเครือข่าย (IP, พอร์ต, เครือข่าย)
mountsarrayการติดตั้งโวลุ่มและการเชื่อมโยง
configobjectการตั้งค่าคอนเทนเนอร์ (env, cmd, labels, ฯลฯ)

Example: Inspect a container by name

yaml
container: my-nginx

Example: Inspect a container by ID

yaml
container: a1b2c3d4e5f6

รับบันทึกคอนเทนเนอร์

docker.logs

รับบันทึกจากคอนเทนเนอร์ Docker

Parameters:

NameTypeRequiredDefaultDescription
containerstringYes-ID หรือชื่อคอนเทนเนอร์
tailnumberNo100จำนวนบรรทัดที่จะแสดงจากท้ายบันทึก
followbooleanNoFalseติดตามผลบันทึก (สตรีมจนกว่าจะหมดเวลา)
timestampsbooleanNoFalseแสดงเวลาประทับในผลบันทึก

Output:

FieldTypeDescription
logsstringผลบันทึกของคอนเทนเนอร์
linesnumberจำนวนบรรทัดบันทึกที่คืนค่า

Example: Get last 50 lines

yaml
container: my-nginx
tail: 50

Example: Get logs with timestamps

yaml
container: my-app
tail: 100
timestamps: true

รายการคอนเทนเนอร์ Docker

docker.ps

รายการคอนเทนเนอร์ Docker

Parameters:

NameTypeRequiredDefaultDescription
allbooleanNoFalseแสดงคอนเทนเนอร์ทั้งหมด (ค่าเริ่มต้นแสดงเฉพาะที่กำลังทำงาน)
filtersobjectNo-กรองคอนเทนเนอร์ (เช่น {"name": "my-app", "status": "running"})

Output:

FieldTypeDescription
containersarrayรายการคอนเทนเนอร์พร้อม id, ชื่อ, อิมเมจ, สถานะ, พอร์ต
countnumberจำนวนคอนเทนเนอร์ที่พบ

Example: List running containers

yaml

Example: List all containers

yaml
all: true

Example: Filter by name

yaml
filters: {"name": "nginx"}

รัน Docker Container

docker.run

รัน Docker container จาก image

Parameters:

NameTypeRequiredDefaultDescription
imagestringYes-Docker image ที่จะรัน (เช่น nginx:latest)
commandstringNo-คำสั่งที่จะรันใน container
namestringNo-ตั้งชื่อให้กับ container
portsobjectNo-การแมปพอร์ตเป็น host:container (เช่น {"8080": "80"})
volumesobjectNo-การแมปโวลุ่มเป็น host_path:container_path
envobjectNo-ตัวแปรสภาพแวดล้อมที่จะตั้งค่าใน container
detachbooleanNoTrueรัน container ในพื้นหลัง
removebooleanNoFalseลบ container อัตโนมัติเมื่อสิ้นสุดการทำงาน
networkstringNo-เชื่อมต่อ container เข้ากับเครือข่าย

Output:

FieldTypeDescription
container_idstringID ของ container ที่สร้าง
statusstringสถานะของ container หลังจากรัน

Example: Run Nginx web server

yaml
image: nginx:latest
name: my-nginx
ports: {"8080": "80"}
detach: true

Example: Run a one-off command

yaml
image: alpine:latest
command: echo hello world
remove: true
detach: false

หยุด Docker Container

docker.stop

หยุด Docker container ที่กำลังรัน

Parameters:

NameTypeRequiredDefaultDescription
containerstringYes-ID หรือชื่อของ container ที่จะหยุด
timeoutnumberNo10จำนวนวินาทีที่จะรอก่อนหยุด container

Output:

FieldTypeDescription
container_idstringID หรือชื่อของ container ที่หยุด
stoppedbooleancontainer หยุดสำเร็จหรือไม่

Example: Stop a container by name

yaml
container: my-nginx

Example: Stop with custom timeout

yaml
container: my-app
timeout: 30

Released under the Apache 2.0 License.