Deploy docker image (not Dockerfile) to Heroku?

心已入冬 提交于 2020-06-12 06:18:46

问题


I want to deploy an existing Docker image to Heroku, where there is no Dockerfile in the local directory. (I created the Docker foo:bar image using datasette, and I don't know where it puts the Docker image).

These are the Docker images I have available:

$ docker images
REPOSITORY                                     TAG        IMAGE ID            CREATED             SIZE
foo                                            bar        d41xxxc69862        About an hour ago   1.08GB
<none>                                         <none>     af079eb9ceda        About an hour ago   980MB

I want to deploy the first docker image (foo:bar) to Heroku.

I have tried doing heroku create my-app-12355, then:

heroku container:push web -a my-app-12355

But this gives me:

  ▸    No images to push

How do I specify the name of the image? I think the section on "Building and pushing images" in the documentation is what I need, but I don't understand what "app" and "process-type" should be.

UPDATE: I tried:

docker tag d41xxxc69862 registry.heroku.com/my-app-12355/web
docker push registry.heroku.com/my-app-12355/web

But when I do heroku container:push web -a my-app-12355 I still get No images to push. How do I tell it where the image is?


回答1:


Useful Link: https://toedter.com/2016/11/05/deploying-spring-boot-apps-to-heroku-using-docker/

I think you need to first tag your image and then push it to heroku registry:

docker tag d41xxxc69862 registry.heroku.com/my-app-12355/web
docker push registry.heroku.com/my-app-12355/web

d41xx is image id. Or you can try {image name}/{tag} e.g. foo/bar

Possible process-types are web, worker and image.

After docker push you need to run docker release command as per this link

heroku container:release web --app=my-app-12355 -- you don't require the '/' before the app name. That worked for me.



回答2:


The important part is to add the app name to the Dockerfile, so rename Dockerfile to be Dockerfile.web and respectively for any docker-compose services. Then you can simply push all at once with

heroku container:push --recursive --context-path .



回答3:


heroku container:push image_name -a=app_name


来源:https://stackoverflow.com/questions/50788725/deploy-docker-image-not-dockerfile-to-heroku

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