天天看點

使用 Docker 快速部署 Golang 應用

文章目錄:

  • 目标
  • 鏡像
    • Golang
    • Alpine
  • 端口映射
    • 占用本地端口 8081
  • 備注
    • Dockerfile

文章使用到的軟體:

  • Mac 12.0 Beta(macOS Monterey),處理器為:M1
  • Portainer.io:2.5.1
  • Docker:20.10.6
使用 Docker 快速部署 Golang 應用

目标

  • 快速部署 Golang 應用

建構Dockerfile

  • Golang 網址 [1]
  • Alpine 網址 [2]
  • Goproxy 網址 [3]

打包Docker鏡像

部署Go程式

我是通過Portainer[4]來運作的,可視化的容器鏡像的圖形管理工具

方式二:

參考資料

[1]

Golang Docker鏡像網址: https://registry.hub.docker.com/_/golang

[2]

Alpine Docker鏡像網址: https://registry.hub.docker.com/_/alpine

[3]

Goproxy 代理網址: https://goproxy.cn/

[4]

Portainer 官網: https://www.portainer.io/