duandianwen1723 2018-01-08 15:17
浏览 84

如何使用Golang SDK将Docker映像推入AWS ECR

I am trying to write a tool to automatically push docker image into aws ECR.

I am trying to push a docker image into aws ECR using aws golang sdk. was trying to follow this documentation https://docs.aws.amazon.com/sdk-for-go/api/service/ecr/#ECR.PutImage

but no clue how to make ImageManifest object https://docs.aws.amazon.com/sdk-for-go/api/service/ecr/#PutImageInput Help is very much appreciated.

  • 写回答

1条回答 默认 最新

  • dongxixian7803 2018-01-09 13:58
    关注

    The documentation clearly says:

    This operation is used by the Amazon ECR proxy, and it is not intended for general use by customers for pulling and pushing images. In most cases, you should use the docker CLI to pull, tag, and push images.

    Instead doing that way I will recommend you to use exec Go package and implement the exec commands directly in your build machine.

    You can do something like this:

    package main
    
    import (
        "fmt"
        "os"
        "os/exec"
    )
    
    func main() {
        name := "docker"
        args := []string{"push", "registry/name:tag"}
        cmd := exec.Command(name, args...)
        if err := cmd.Run(); err != nil {
            fmt.Fprintln(os.Stderr, err)
            os.Exit(1)
        }
        fmt.Println("done")
    }
    

    I took this example from the this blog https://nathanleclaire.com/blog/2014/12/29/shelled-out-commands-in-golang/

    I hope you can have this info useful

    评论

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度