大网数据广告活动
服务器运维问答

Pre-populating GCE persistent disks while building and/or before running Docker image on GKE

· 52CE 我爱测

I would like to build a Docker container and then run it in GKE after mounting some directories from GCE persistent disks (PDs). For instance, I'd like for the application's (read-write) configuration files in /etc/<application>/…

问题原文

原帖链接 · Drux · CC BY-SA 3.0

I would like to build a Docker container and then run it in GKE after mounting some directories from GCE persistent disks (PDs). For instance, I'd like for the application's (read-write) configuration files in /etc/<application>/ to live longer than its pods (which may restart at any time.)

The regular build puts default configuration files into /etc/<application>/ and it is imperative that these are somehow "copied" once from the image's ephemeral disk into the PD, such that the application can start in its expected environment.

Is there a best practice for making this happen? For instance, would I have to mount PDs also in my Dockerfile, or can I somehow request that PDs be "synced" with files from another directory/volume/disk when they are first mounted by a VM instance during deployment?

已采纳解答

原帖链接 · Drux · CC BY-SA 3.0

I did not hear about best practices, so this is what I have adopted for now:

  1. docker build the image with Dockerfile that also tars e.g. /etc/<application>/ into <application>.tar after it has done its other build steps
  2. briefly docker run the image and scp tar files off the running image
  3. briefly create a temporary VM instance and add/attach the PD to it; scp tar files to the VM instance; gcloud compute ssh into tit, mount the PD, and untar needed files below mount point

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2016-07-24)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。