在 GHA 的 Dockerfile 中使用 ghcr

Pio*_*otr 6 caching docker dockerfile github-actions ghcr

我想使用 ghcr 作为缓存来存储 docker 映像,其部分在我的项目中几乎不会改变(Ubuntu、miniconda 和一堆 Python 包),然后在 Dockerfile 中使用此映像,将项目的卷和代码添加到其中。Dockerfile 由 Github Actions 运行。如何在 Dockerfile 的 From 语句中引用 ghcr 存储的图像?

BMi*_*tch 9

如何在 Dockerfile 的 From 语句中引用 ghcr 存储的图像?

镜像引用前面有注册表,如果不包含,则默认为 Docker Hub。因此,对于像 ghcr 这样的注册表,您需要:

FROM ghcr.io/path/to/image:tag
Run Code Online (Sandbox Code Playgroud)