Phương Nguyễn
Phương Nguyễn

Reputation: 8905

Use a certain FROM layer in Dockerfile

I want to base my container off centos:centos6. But for some reason, centos:centos6 is updated somehow on the registry. This results in possible unfavorable different images when being built on different machines at different time. Such change caused segmentation fault in our application recently.

Is there a way I can specify the exact version for the from declaration so the build shall be the same even when the container being built on different machines at different time?

Upvotes: 1

Views: 70

Answers (1)

Chris McKinnel
Chris McKinnel

Reputation: 15102

No, you can't tell a Dockerfile to be pinned to a particular image / layer ID, you have to use a tag (and if you don't use a tag, the tag latest is assumed and used as the default.

If you're worried that a remote registry image will change, you should take a copy of the Dockerfile and build your own version of the image yourself. You can either host it on the Docker Hub under your account or run your own private registry.

That way, you're in complete control over what's in there and when it gets updated (i.e., if you need to pin a particular package to an old version).

Upvotes: 3

Related Questions