Which command only updates the Docker image?

סיכום מבוסס בינה מלאכותית

该讨论主题探讨了如何单独更新Discourse的Docker基础镜像,以优化在网络不佳环境下的重建流程。singi2016cn指出当前没有专门的命令仅拉取镜像,导致rebuild时会卡在镜像下载步骤,建议官方增加类似./launcher pull-docker的功能。

Lilly提供了替代方案:首先通过git pull更新启动脚本,然后使用grep查找当前使用的镜像标签(如discourse/base:2.0.20260915-0028),并手动执行docker pull进行下载。这样在后续执行./launcher rebuild app时,系统会检测到镜像已是最新,从而跳过下载过程。针对singi2016cn关于自动化脚本可能因官方更新而失效的担忧,Lilly认为短期内兼容性风险不大,建议可通过Bash脚本结合Cron任务实现自动化。

singi2016cn承认这是最坏情况的假设,并表示会采取“先执行再调整”的策略。随后singi2016cn更新了查找镜像标签的方法,建议使用grep base_image /var/discourse/templates/*.yml来更准确地获取模板中定义的镜像版本(如2.0.20261027-1647),再执行相应的docker pull命令。总结来说,虽然没有原生的一键更新镜像命令,但通过查找最新镜像标签并预先手动拉取,可以有效解决重建时的下载瓶颈。

Which command is used to update only the Docker image?

/var/discourse# ./launcher -h
Usage: launcher COMMAND CONFIG [--skip-prereqs] [--docker-args STRING]
Commands:
    start:       Start/initialize a container
    stop:        Stop a running container
    restart:     Restart a container
    destroy:     Stop and remove a container
    enter:       Open a shell to run commands inside the container
    logs:        View the Docker logs for a container
    bootstrap:   Bootstrap a container for the config based on a template
    run:         Run the given command with the config in the context of the last bootstrapped image
    rebuild:     Rebuild a container (destroy old, bootstrap, start new)
    cleanup:     Remove all containers that have stopped for > 24 hours
    start-cmd:   Generate docker command used to start container

Options:
    --skip-prereqs             Don't check launcher prerequisites
    --docker-args              Extra arguments to pass when running docker
    --skip-mac-address         Don't assign a mac address
    --run-image                Override the image used for running the container

My use case is:
Currently, during the build process, if a Docker image update is required but the server’s network connection is poor, the process gets stuck at the image update step for a very long time. I would like to have a dedicated command for updating the Docker image, so that I can update the image in advance separately and then build the code without any rush. For example:

./launcher pull-docker

I know I can manually create a working version, but I would still prefer if the official team could provide one.

hmmm, only way i know is to first update the launcher script:

cd /var/discourse
git pull

then find the default image tag the launcher is using:

grep -m1 '^image=' launcher

the output should look like:

image="discourse/base:2.0.20260915-0028"

then run:

docker pull discourse/base:2.0.20260915-0028

then when you run ./launcher rebuild app it should skip the download i think.

it should say Status: Image is up to date for discourse/base:2.0.20260915-0028 when you run the rebuild…

Thanks for the reply. I’m currently updating using a similar method, but it’s quite cumbersome. I’d like to write my own automation script, but I’m worried about potential incompatibility after official updates.

you can do it with an executable bash script and even use a cron job to automate it. not sure why it would become incompatible any time soon.

What I mean is that it might become incompatible in the future, and I may need to check this script every single time, which undoubtedly adds extra work. I’m just assuming the worst-case scenario :joy:. Of course, when it comes to solving the problem, let’s just get started first and adjust as we go.

The latest way to check images

grep base_image /var/discourse/templates/*.yml

Output:

/var/discourse/templates/postgres.template.yml:base_image: discourse/base:2.0.20261027-1647
/var/discourse/templates/redis.template.yml:base_image: discourse/base:2.0.20261027-1647
/var/discourse/templates/web.template.yml:base_image: discourse/base:2.0.20261027-1647
/var/discourse/templates/web.webonly.template.yml:base_image: discourse/base:2.0.20261027-1647-web-only

Then manually update by running

docker pull discourse/base:2.0.20261027-1647