Skip to content

Conversation

unclejack
Copy link
Contributor

@unclejack unclejack commented Nov 21, 2014

This PR adds a flag to docker build. docker build --pull . will force the pulling of the image, even if it exists locally.
Force pulling the image will update the existing local image if there's one.

@unclejack
Copy link
Contributor Author

I need to update this to modify the API docs.

@tianon
Copy link
Member

tianon commented Nov 21, 2014

So much cleaner and simpler than docker pull $(awk '/^FROM\s/ { print /:/ ? $2 : $2":latest" }' Dockerfile) ❤️

Signed-off-by: Cristian Staretu <cristian.staretu@gmail.com>
@@ -1016,6 +1016,9 @@ func postBuild(eng *engine.Engine, version version.Version, w http.ResponseWrite
} else {
job.Setenv("rm", r.FormValue("rm"))
}
if r.FormValue("pull") == "1" && version.GreaterThanOrEqualTo("1.16") {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this needed? I think we could always set it and we would be ok right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is needed to make sure we don't change older API versions. This is similar to the checks for the --rm and --force-rm flags.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But these old versions don't have this flag right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, they don't have it and that's the reason why we're making sure we don't allow it for older versions.

@unclejack
Copy link
Contributor Author

API and doc changes have been made.

@jessfraz
Copy link
Contributor

LGTM

1 similar comment
@crosbymichael
Copy link
Contributor

LGTM

crosbymichael added a commit that referenced this pull request Nov 24, 2014
build: add pull flag to force image pulling
@crosbymichael crosbymichael merged commit 5e19ecf into moby:master Nov 24, 2014
@unclejack unclejack deleted the build_pull_flag branch November 24, 2014 22:22
bltavares added a commit to bltavares/cross that referenced this pull request Mar 21, 2019
It is important to keep Docker images up-to date, as upstream images
could have important security fixes, even using the same tag and
version.

When building images, it is possible to pass in a `--pull` flag to check
if the base image has updates, and rebuild as necessary. This feature is
available since 2014, and will still retain the image cache if there are
no updates on the base image.

[since 2014]: moby/moby#9281
@mooyah
Copy link

mooyah commented Jul 16, 2019

Hello,

Is there a way to use this --pull flag via docker-compose?

Something like this?
build: context: . dockerfile: Dockerfile pull: true

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

docker build doesn't pull down latest images from index if there is already an image locally
7 participants