20
8

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

no basic auth credentials ! Error: docker push exited with 1

Last updated at Posted at 2019-03-24

概要

試しに heroku のデプロイを Dockerのイメージごとやったらどうなるのかを試して見たかったので、やってみたら詰まったお話。

エラーの内容

$ heroku container:push web
=== Building web (/Users/oki.suguru/workspace/docker/go/Dockerfile)
Sending build context to Docker daemon  38.91kB
Step 1/10 : FROM golang:latest as builder
 ---> 36e5881731e4
Step 2/10 : ENV CGO_ENABLED=0
 ---> Using cache
 ---> 038493d74c24
Step 3/10 : ENV GOOS=linux
 ---> Using cache
 ---> a18000304e4c
Step 4/10 : ENV GOARCH=amd64
 ---> Using cache
 ---> dd7c60bdd218
Step 5/10 : WORKDIR /go/src/github.com/yokoe/go-server-example
 ---> Using cache
 ---> b0ed8cbc042c
Step 6/10 : COPY . .
 ---> Using cache
 ---> 77b5bfebb449
Step 7/10 : RUN go build main.go
 ---> Using cache
 ---> ff8e57971358
Step 8/10 : FROM alpine
 ---> 5cb3aa00f899
Step 9/10 : COPY --from=builder /go/src/github.com/yokoe/go-server-example /app
 ---> Using cache
 ---> e6233c2177f8
Step 10/10 : CMD /app/main $PORT
 ---> Using cache
 ---> 6364bb214f79
Successfully built 6364bb214f79
Successfully tagged registry.heroku.com/afternoon-inlet-94103/web:latest
=== Pushing web (/Users/oki.suguru/workspace/docker/go/Dockerfile)
The push refers to repository [registry.heroku.com/afternoon-inlet-94103/web]
f6d129803085: Preparing
bcf2f368fe23: Preparing
no basic auth credentials
 ▸    Error: docker push exited with Error: 1

やったこと

  1. heroku cli において heroku login を実行して、成功している
  2. heroku の Docker でないデプロイはできる
  3. Dockerfileにおけるbuild自体に失敗はない
  4. ローカルにおけるDockerのrunについては問題なく稼働している
  5. heroku container:push を実行した → ここでタイトルのエラーが発生する。

今回の問題の解決方法

実行コマンドは以下の通り。

$ heroku container:login
$ heroku container:push

このようにしたところ成功した。
どうやら heroku container を実行して heroku コンテナのレジストリにもログインが必要らしい。

参考

Goで書いたサーバーをHerokuにDocker Deployする
fiorix/freegeoip - Issues #171 [Docker Deploy to Heroku]

20
8
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
20
8

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?