DEV Community

MrChoke
MrChoke

Posted on • Originally published at Medium on

4 2

docker compose not docker-compose

docker-compose กำลังจะถูก deprecate แล้วใช้ docker compose แทน มาดูว่าใช้ยังไงกัน

สืบเนื่องมาจาก blog ของ คุณปุ๋ย

https://www.somkiat.cc/docker-compose-to-docker-compose/

ทำให้เกิดอยากลองใช้บ้างซึ่งพบว่า

บน Docker Desktop macOS สามารถใช้คำสั่งนี้ได้เลย (ลองบน M1) เลยลองบน Ubuntu บ้างพบว่ายังใช้ไม่ได้ เลยตามไปสืบค้นดูพบว่า Project คือ

docker/compose-cli

ทำมานานพอสมควรถ้าอ้างตามเอกสารนี้

docker/compose-cli

Docker Desktop macOS และ Windows จะถูก built-in ไปแล้วเลยใช้ได้ทันทีเหมือน buildx เลย

Installation

ตาม link ด้านบนวิธีการติดตั้ง (ผมติดตั้งบน Ubuntu)

curl -L https://raw.githubusercontent.com/docker/compose-cli/main/scripts/install/install_linux.sh | sh
Enter fullscreen mode Exit fullscreen mode

เมื่อติดตั้งสำเร็จจะมีคำสั่ง docker เพิ่มขึ้นมาใน path

/usr/local/bin/docker
Enter fullscreen mode Exit fullscreen mode

ลองทดสอบดูว่าตอนนี้คำสั่ง docker ถูกเรียกจาก path ไหน

type docker
Enter fullscreen mode Exit fullscreen mode

หรือ

which docker
Enter fullscreen mode Exit fullscreen mode

ถ้ายังเรียกไปที่

/usr/bin/docker
Enter fullscreen mode Exit fullscreen mode

ก็ให้ปิด shell แล้วเปิดใหม่ อ้อ!! ดูลำดับ path ของ PATH ด้วยนะครับว่า /usr/local/bin ต้องอยู่ก่อน /usr/bin

คราวนี้เราก็สามารถใช้คำสั่ง

docker compose
Enter fullscreen mode Exit fullscreen mode

ได้แล้วจ้า….

docker compose


Heroku

Build apps, not infrastructure.

Dealing with servers, hardware, and infrastructure can take up your valuable time. Discover the benefits of Heroku, the PaaS of choice for developers since 2007.

Visit Site

Top comments (1)

Collapse
 
veer66 profile image
Vee Satayamas

ใน docker รุ่นต่อไปเขาจะไม่ต้องลง docker-compose แล้วใช่เปล่าครับ; สงสัยต้องเริ่มใช้บ้างแล้ว

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs