-
Notifications
You must be signed in to change notification settings - Fork 14.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[AIRFLOW-3203] Fix DockerOperator & some operator test #4049
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why were these remove? (I can't work out from the diff alone.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @ashb , this is because I found out that this will be handled by
docker
package itself.Here this operator is using
docker.APIClient.create_container(image=...)
to create the container under the hood. If theimage
is just the name withOUT tag, say"fake_image"
, then the program will go search for"fake_image:latest"
by default (of course it will search for the tag given by user if user has specified the tag).You can try the code below to validate:
It will tell you something like
"'fake_image:latest' can't be found"
(I don't have Docker on the laptop I'm using at this moment so can't provide the exact exception). Please help double-validate.Cheers
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @ashb , I have checked on a machine with Docker installed.
Without Tag
Result:
With Tag
Result:
Conclusion
So as I shared earlier: if tag is omitted for
image
, "latest" will be used by default; if tag is provided by user, then that tag will be used.So here in
DockerOperator
, we don't need to explicitly check & add ":latest".There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @XD-DENG were you really certain about that? Because I noticed something weird when I use for example just
r-base
as an image name.The DockerOperator task pulled every image.
pip list
shows medocker 3.7.2
in airflow 1.10.2There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@feluelle let me have a quick check and get back here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@feluelle may you share your log? You may have logs like
Pulling image (xxx) from xxx
. ThanksThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @feluelle the change was made based on the facts below:
For
pull
: https://docker-py.readthedocs.io/en/stable/api.html#docker.api.image.ImageApiMixin.pull In the example, you can find that thelatest
tag is used if no tag is provided together with the repo.For
create_container
: you can try to code belowIt will give you error "ImageNotFound: 404 Client Error: Not Found ("No such image:
fake_image:latest
")"There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure. https://pastebin.com/raw/NUmS0tYh
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(That's not all) I think it is for like 3 images