快速入門:使用 Azure 入口網站部署容器執行個體

使用 Azure 容器執行個體在 Azure 中簡潔且快速地執行無伺服器 Docker 容器。 當您不需要像 Azure Kubernetes Service 的完整容器協調流程平台時,請視需要將應用程式部署至容器執行個體。

在本快速入門中,您會使用 Azure 入口網站來部署隔離的 Docker 容器,並使用完整網域名稱 (FQDN) 提供其應用程式。 進行幾個設定並部署容器之後,您可以瀏覽至執行中的應用程式:

App deployed using Azure Container Instances viewed in browser

登入 Azure

登入 Azure 入口網站

如尚未擁有 Azure 訂用帳戶,請在開始之前先建立免費帳戶

建立容器執行個體

從 Azure 入口網站首頁,選取 [建立資源]

Screenshot showing how to begin creating a new container instance in the Azure portal.

選取 [容器]>[容器執行個體]

Screenshot showing how to select a new container instance that you want to create in the Azure portal.

在 [基本] 頁面上,選擇訂用帳戶,然後針對 [資源群組]、[容器名稱]、[映像來源] 和 [容器映像] 輸入下列值。

  • 資源群組:建立新的>myresourcegroup
  • 容器名稱:mycontainer
  • 映像來源:快速入門映像
  • 容器映像:mcr.microsoft.com/azuredocs/aci-helloworld:latest (Linux)

Configuring basic settings for a new container instance in the Azure portal

注意

在本快速入門中,您會使用預設設定部署公用 Microsoft aci-helloworld:latest 映像。 此範例 Linux 映像會封裝以 Node.js 撰寫並提供靜態 HTML 網頁的小型 Web 應用程式。 您也可以使用儲存在 Azure Container Registry、Docker Hub 或其他登錄中自己的容器映像。

將其他的值保留為預設值,然後選取 [下一步:網路]

在 [網路] 頁面上,為您的容器指定 [DNS 名稱標籤]。 這在您建立容器執行個體所在的 Azure 區域中,必須是唯一的名稱。 您的容器將可在 <dns-name-label>.<region>.azurecontainer.io 讓他人公開存取。 如果出現「DNS 名稱標籤無法使用」錯誤訊息,請嘗試使用不同的 DNS 名稱標籤。

自動產生的雜湊會作為 DNS 名稱標籤新增至容器執行個體的完整網域名稱 (FQDN),以防止惡意子網域接管。 指定 FQDN 的 DNS 名稱標籤範圍重複使用。 您可以選擇這些選項的其中一個:

  • 租用戶
  • 訂用帳戶
  • 資源群組
  • 不重複使用
  • 任何重複使用 (此選項最不安全。)

針對此範例,請選取 [租用戶]

Configuring network settings for a new container instance in the Azure portal

將所有其他設定保留預設值,然後選取 [檢閱 + 建立]

當驗證完成時,系統會向您顯示容器設定的摘要。 選取 [建立] 以提交容器部署要求。

Settings summary for a new container instance in the Azure portal

部署開始時會出現通知,指出部署正在進行中。 容器群組部署完成時,會顯示另一個通知。

瀏覽至 [資源群組]>[myresourcegroup]>[mycontainer],開啟容器群組的概觀。 記下容器執行個體的 FQDN 及其狀態

Container group overview in the Azure portal

當其 [狀態] 成為 [執行中] 時,請在瀏覽器中瀏覽至容器的 FQDN。

App deployed using Azure Container Instances viewed in browser

恭喜! 在進行幾項設定後,您即已部署可在 Azure 容器執行個體中公開存取的應用程式。

檢視容器記錄

在對您的容器或其執行的應用程式排解問題時,檢視的容器執行個體的記錄會很有幫助。

若要檢視容器的記錄,請在 [設定] 下選取 [容器]>[記錄]。 您應該會看到您在瀏覽器中檢視應用程式時產生的 HTTP GET 要求。

Container logs in the Azure portal

清除資源

完成容器的作業後,請選取 mycontainer 容器執行個體的 [概觀],然後選取 [刪除]

Deleting the container instance in the Azure portal]

在確認對話方塊出現時,選取 [是]

Delete confirmation of a container instance in the Azure portal]

下一步

在本快速入門中,您已從公用 Microsoft 映像建立 Azure 容器執行個體。 如果您想要建置容器映像,並從私人的 Azure 容器登錄進行部署,請繼續進行 Azure Container Instances 教學課程。