【发布时间】:2020-07-04 18:23:19
【问题描述】:
我正在构建一个 google-cloud-sdk 基础映像,并且我正在努力使其保持精简。
ARG GCLOUD_SDK_VERSION=285.0.1-alpine
FROM google/cloud-sdk:$GCLOUD_SDK_VERSION
# Install Java 8 for Datastore emulator
RUN apk add --update --no-cache \
openjdk8-jre
RUN gcloud components install \
cloud-datastore-emulator \
pubsub-emulator \
beta \
--quiet
...
到目前为止一切都很好。当我构建并查看gcloud components install 命令的输出时,我感到很自信:
┌──────────────────────────────────────────────────┐
│ These components will be installed. │
├──────────────────────────┬────────────┬──────────┤
│ Name │ Version │ Size │
├──────────────────────────┼────────────┼──────────┤
│ Cloud Datastore Emulator │ 2.1.0 │ 18.4 MiB │
│ Cloud Pub/Sub Emulator │ 2019.09.27 │ 34.9 MiB │
│ gcloud Beta Commands │ 2019.05.17 │ < 1 MiB │
└──────────────────────────┴────────────┴──────────┘
然而,我的最终图像大小令人震惊:1.11GB。当我查看 docker 历史记录时,我发现组件安装实际上为最终图像大小贡献了 654MB:
CREATED BY SIZE
/bin/sh -c gcloud components install … 654MB
/bin/sh -c apk add --update --no-cache … 78.2MB
我目前假设它与安装过程的最后一行有关。
╔════════════════════════════════════════════════════════════╗
╠═ Creating backup and activating new installation ═╣
╚════════════════════════════════════════════════════════════╝
在您的本地工作站上似乎是一件好事,但在 docker 映像中却没有。我试图查看是否可以停用此备份或之后将其删除。手册页中没有任何有用的段落,在线搜索总是将我引导到一些可以使用 gcloud 命令启动的云数据库备份过程。
有人对这里发生的事情有进一步的了解吗?也许导致大部分开销的根本不是备份?
【问题讨论】:
标签: docker google-cloud-platform gcloud