撰寫 compose.yaml 檔案
你想用 Docker Compose 來部署你的應用程式。首先,你要先建立一個只包含單一資源的 Docker Compose 應用程式,之後再逐步擴充。
目前你的應用程式使用名為 test_app:latest 的容器映像。它需要將主機的 8000 埠轉送(redirect)到容器內的 8000 埠。
本練習屬於課程
Docker 中級
練習說明
- 建立一個名為
primary的新資源。 - 指定容器名稱為
webapp。 - 使用正確的映像資訊。
- 在正確的子區段中指定埠轉送設定。
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
services:
# Specify the resource name
____
# Define a container name
____: webapp
# Use the proper image
____
# Define the correct entries to forward ports
ports:
- "____"