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

Is it a good practice to put update/upgrade statements inside the Dockerfile?

· 52CE 我爱测

new to Docker here and I am trying to make it right. I want to create a docker container to 'deep freeze' an application created with bash scripts and a lot of dependencies, so that I don't have to maintain it as much anymore. I …

问题原文

原帖链接 · MortyAndFam · CC BY-SA 4.0

new to Docker here and I am trying to make it right.

I want to create a docker container to 'deep freeze' an application created with bash scripts and a lot of dependencies, so that I don't have to maintain it as much anymore. I think docker is going to help me with that. Is it a good practice to put update/upgrade statements inside the Dockerfile like 'apt-get upgrade'? Wouldn't that potentially break the application in the future which is what docker should prevent?

社区高分解答

原帖链接 · Håkan Lindqvist · CC BY-SA 4.0

The main reason why you'll want to either use an updated base image (which itself been built from up-to-date packages) or update it yourself (eg, apt-get upgrade) is to get security fixes, as well as other bug fixes.

You don't say much about what software is in there, but "a lot of dependencies" probably means there will be security fixes to track.

The overall idea for using containers is that you build an up-to-date image with the software you need, test it, it then stays frozen throughout its lifetime and later gets discarded as a whole when a new version is released and a new image is deployed.

From a security perspective, this of course implies regular releases.

As for what you will get in terms of updated packages in Debian (if we assume Debian, from your use of apt-get), they have stable (ie, unchanging) releases. Ie, they don't ship new versions of the packaged software (with rare exceptions), but backport fixes to their packaged version.
This may be helpful in your "deep freeze" effort, as the chance of changed behaviour is much lower than with new versions.

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

资料来源与适用范围

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

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

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