Kamil Łęczycki
Kamil Łęczycki

Reputation: 189

Heroku docker deployment

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.

Upvotes: 8

Views: 5673

Answers (6)

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.

Upvotes: 0

user4408933
user4408933

Reputation:

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.

Upvotes: 1

Kenneth Jiang
Kenneth Jiang

Reputation: 589

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.

Upvotes: 2

Kamil Łęczycki
Kamil Łęczycki

Reputation: 189

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.

Upvotes: 1

user2634633
user2634633

Reputation: 529

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.

Upvotes: 7

Luís Brito
Luís Brito

Reputation: 1772

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.

Upvotes: 0

Related Questions