Heroku docker deployment

天大地大妈咪最大 提交于 2020-01-24 04:04:57

问题


I was following the this article https://devcenter.heroku.com/articles/container-registry-and-runtime and I'm stuck with "heroku container:push". I run "heroku container:push --app mediabox" and the docker image is properly build and then it start to push it to registry and this is what I get:

Successfully built 7926b98d51b5
The push refers to a repository [registry.heroku.com/mediabox/web]
38d48dd6de30: Preparing 
969058e6ddc9: Preparing 
2f454953e0e7: Preparing 
f67c1ecd32a1: Preparing 
44fade3982ca: Preparing 
0accb1c81980: Waiting 
e79bbdfaa0d3: Waiting 
1be5d1797b73: Waiting 
5c0a4f4b3a35: Waiting 
011b303988d2: Waiting 
error parsing HTTP 400 response body: unexpected end of JSON input: ""
 !    Error: docker push exited with 1

This is my Dockerfile:

FROM ruby:2.3.1-alpine

RUN apk --update --no-cache add build-base less libxml2-dev libxslt-dev nodejs postgresql-dev && mkdir -p /app

WORKDIR /app

COPY Gemfile Gemfile.lock ./

RUN gem install bundler

RUN bundle

COPY . ./

CMD ["script/docker-entrypoint.sh"]

I can't find the solution here. Thanks for your help.


回答1:


I had this problem when I forgot to run heroku container:login. Even if you're logged in to heroku, heroku container service requires a separate login. That's why you're getting the error right at the beginning of the upload - you are not authorised.




回答2:


registry.heroku.com/mediabox/web

Just to create an app with name 'mediabox' by using of heroku dashboard and try again to push image, it works for me.




回答3:


Following the Heroku documentation (https://devcenter.heroku.com/articles/container-registry-and-runtime#logging-in-to-the-registry):

  1. Login: First of all, check if you're logged in.

docker login --username=YOUR_USER --password=$(heroku auth:token) registry.heroku.com

Or

heroku container:login

  1. Push the image: Execute the heroku cli or docker command.

heroku container:push IMG_NAME

Or

docker tag registry.heroku.com/APP/IMG_NAME

docker push registry.heroku.com/APP/IMG_NAME

  1. Notice that the application (APP above) must exist on Heroku dashboard.



回答4:


First of all, Docker integration in Heroku is in BETA, as the article you linked says. It may still have some bugs. So maybe is a good idea to contact directly the Heroku support on this.

Assuming Heroku integration and your code are both OK, I can only suggest you to stop using heroku container:push and use only the official docker commands. This may avoid some pushing issues.

You can build the image locally using:

docker build . 

Then push it to Heroku using:

docker tag <image> registry.heroku.com/<app>/<process-type>
docker push registry.heroku.com/<app>/<process-type>

I have production environments based on Gitlab CI and Heroku using Docker. All our integration depends only on docker commands, and we have never experienced any issues with pushing images built locally.




回答5:


I needed to explicitly pass the app name and not the internal one so doing heroku container:push --app rocky-wildwood-86034 went well.

I did: heroku container:push --app mediabox

the proper one was: heroku container:push --app rocky-wildwood-86034

Simple the app name should be the global heroku app name instead of the one which was defined in docker-compose.yml.




回答6:


I had the same error when I forgot to heroku container:login first. Not sure if your problem was caused by the same user error.



来源:https://stackoverflow.com/questions/40807796/heroku-docker-deployment

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!