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 แล้วใช่เปล่าครับ; สงสัยต้องเริ่มใช้บ้างแล้ว

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more