【问题标题】:Deploy docker image (not Dockerfile) to Heroku?将 docker 镜像(不是 Dockerfile)部署到 Heroku?
【发布时间】:2018-11-20 04:08:25
【问题描述】:

我想将现有的 Docker 映像部署到 Heroku,本地目录中没有 Dockerfile。 (我使用数据集创建了 Docker foo:bar 镜像,我不知道它把 Docker 镜像放在哪里)。

这些是我可用的 Docker 映像:

$ 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

我想将第一个 docker 镜像 (foo:bar) 部署到 Heroku。

我试过heroku create my-app-12355,然后:

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

但这给了我:

  ▸    No images to push

如何指定图片的名称?我认为the section on "Building and pushing images" in the documentation是我需要的,但我不明白“app”和“process-type”应该是什么。

更新:我试过了:

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

但是当我做heroku container:push web -a my-app-12355 时,我仍然得到No images to push。如何告诉它图片在哪里?

【问题讨论】:

标签: docker heroku


【解决方案1】:

有用链接:https://toedter.com/2016/11/05/deploying-spring-boot-apps-to-heroku-using-docker/

我认为您需要先标记您的图像,然后将其推送到 heroku 注册表:

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

d41xx 是图像 ID。或者您可以尝试 {image name}/{tag} 例如富/酒吧

可能的进程类型是 web、worker 和 image。

在 docker push 之后,你需要按照 link 运行 docker release 命令

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

【讨论】:

  • 谢谢!我做了docker tag d41xxxc69862 registry.heroku.com/my-app-12355/web,然后是docker push registry.heroku.com/my-app-12355/web,两者都运行良好。但是当我做heroku container:push web -a my-app-12355 时,我仍然看到No images to push
  • 另外,不确定您是否希望https://registry.heroku.com/my-app-12355/webhttps://registry.heroku.com/my-app-12355 出现任何内容(对不起,我对 Heroku 和 Docker 都很陌生,不明白它们是如何组合在一起的。 ..)。但我在两个地址都看到了 404。
  • docker tag d41xxxc69862 registry.heroku.com/my-app-12355/webdocker push registry.heroku.com/my-app-12355/web 之后不需要container:push 命令。根据上面的文章,应用程序应该可以通过https://my-app-12355.herokuapp.com 访问
  • 上述命令上周工作。似乎不再起作用了。有人可以在这里帮助我们吗?
  • 只是为了澄清我将本指南用作参考blog.devcenter.co/…
【解决方案2】:

重要的部分是将应用程序名称添加到 Dockerfile 中,因此将 Dockerfile 重命名为 Dockerfile.web 并分别用于任何 docker-compose 服务。然后你可以简单地一次推送所有

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

【讨论】:

  • 请删除您的答案,问题是关于推送 Dockerfile 不存在的现有图像。
【解决方案3】:
heroku container:push image_name -a=app_name

【讨论】:

    【解决方案4】:

    将 docker 镜像推送到 heroku 时,请确保您的 Dockerfile 以大写“D”命名。 Heroku CLI 似乎没有将 dockerfile(带有小写“D”)识别为搜索图像文件的可行名称,尽管 docker 本身可以。我用这个解决方案解决了这个问题。希望有帮助。

    【讨论】:

      【解决方案5】:

      您必须重命名您的文件:从 dockerfileDockerfile

      【讨论】:

        猜你喜欢
        • 2020-09-09
        • 1970-01-01
        • 2020-05-26
        • 2015-08-04
        • 2019-09-16
        • 1970-01-01
        • 2020-08-19
        • 1970-01-01
        相关资源
        最近更新 更多