-
Notifications
You must be signed in to change notification settings - Fork 383
Make Podman support more prominent in the documentation #1471
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
Merged
Merged
Changes from all commits
Commits
Show all changes
30 commits
Select commit
Hold shift + click to select a range
4ae4be0
Add support to DockerEngine
rgaiacs 3108885
Use "container" instead of Docker when possible in index.md
rgaiacs 45c3fb3
Use "container" instead of Docker when possible in start.md
rgaiacs 5f17fed
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 606cc87
Auto configure container_cli property based on DOCKER_HOST
rgaiacs d4fc92d
Add podman as container cli for GitHub Actions
rgaiacs d1985fb
Select correct hostname for Podman
rgaiacs 905fe0b
Add note about Podman service to documentation
rgaiacs 080f61b
Enable Podman socket during test
rgaiacs 916d3c1
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] b0ad00b
Avoid infinite loop in test
rgaiacs f05f420
Hide output of "docker version" test
rgaiacs 8d74803
Add WorkingDir to bridge the gap with Podman
rgaiacs 7ac468a
Fix tests/unit/test_app.py::test_extra_buildx_build_args
rgaiacs 3027e2c
Make DOCKER_HOST more robust
rgaiacs e1807c5
Prefer to use attribute over internal variable
rgaiacs 07808e6
Minor improve to docker.py wrap
rgaiacs f29e7de
Expose DOCKER_CLI from docker.py
rgaiacs f73d267
Mark some tests with @pytest.mark.skipif
rgaiacs ba52252
Skip registry test for Podman
rgaiacs 7063a1f
Fix English mistakes in documentation
rgaiacs 308ac22
Reduce the number of tests for Podman
rgaiacs 37d2612
Add comment explaining DOCKER_HOST
rgaiacs fee0b11
Guard subprocess.run() with try block
rgaiacs 9259ca8
Re-write matrix strategy to use include
rgaiacs 7270129
Remove if-block already cover in try-block
rgaiacs 7f6b65e
Fix include for GItHub Actions
rgaiacs 6baaf08
Delete container and image after test
rgaiacs f010e36
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 9032292
Disable test of conda for podman
rgaiacs 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,13 +13,28 @@ | |
| from pathlib import Path | ||
|
|
||
| from iso8601 import parse_date | ||
| from traitlets import Dict, List, Unicode | ||
| from traitlets import Dict, List, Unicode, default | ||
|
|
||
| import docker | ||
|
|
||
| from .engine import Container, ContainerEngine, Image | ||
| from .utils import execute_cmd | ||
|
|
||
| # The DOCKER_HOST environment variable is used by Docker to set a remote host. | ||
| # The same DOCKER_HOST environment variable is also used | ||
| # by the official Software Development Kit (SDK) and other libraries | ||
| # as a way to select the socket to communicate with. | ||
| # Because repo2docker uses the official Docker SDK, | ||
| # Podman users MUST configure the DOCKER_HOST environment variable. | ||
| DOCKER_HOST = os.getenv("DOCKER_HOST") | ||
| # It is possible for a user to create a Podman socket | ||
| # that does not include the string "podman" | ||
| # but expect the string "podman" is good enough for repo2docker use case. | ||
| if DOCKER_HOST is not None and DOCKER_HOST.find("podman") != -1: | ||
rgaiacs marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| DOCKER_CLI = "podman" | ||
| else: | ||
| DOCKER_CLI = "docker" | ||
|
|
||
|
|
||
| class DockerContainer(Container): | ||
| def __init__(self, container): | ||
|
|
@@ -66,6 +81,42 @@ class DockerEngine(ContainerEngine): | |
|
|
||
| string_output = True | ||
|
|
||
| _container_cli = None | ||
|
|
||
| @property | ||
| def container_cli(self): | ||
| if self._container_cli is not None: | ||
| return self._container_cli | ||
|
|
||
| cli = DOCKER_CLI | ||
|
|
||
| cli_version_call = [cli, "version"] | ||
| try: | ||
| docker_version = subprocess.run( | ||
| cli_version_call, stdout=subprocess.DEVNULL, check=True | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| ) | ||
| except (subprocess.CalledProcessError, OSError) as e: | ||
| raise RuntimeError( | ||
| f"The {cli} commandline client must be installed: {e}" | ||
| ) from None | ||
|
|
||
| # docker buildx is based in a plugin that might not be installed | ||
| # https://github.com/docker/buildx | ||
| # | ||
| # podman buildx command is an alias of podman build. | ||
| # Not all buildx build features are available in Podman. | ||
| cli_buildx_version_call = [cli, "buildx", "version"] | ||
| try: | ||
| docker_buildx_version = subprocess.run( | ||
| cli_buildx_version_call, stdout=subprocess.DEVNULL, check=True | ||
| ) | ||
| except (subprocess.CalledProcessError, OSError) as e: | ||
| raise RuntimeError(f"The buildx plugin must be installed: {e}") from None | ||
|
|
||
| self._container_cli = cli | ||
|
|
||
| return self._container_cli | ||
|
|
||
| extra_init_args = Dict( | ||
| {}, | ||
| help=""" | ||
|
|
@@ -105,16 +156,7 @@ def build( | |
| platform=None, | ||
| **kwargs, | ||
| ): | ||
| if not shutil.which("docker"): | ||
| raise RuntimeError("The docker commandline client must be installed") | ||
|
|
||
| # docker buildx is based in a plugin that might not be installed | ||
| # https://github.com/docker/buildx | ||
| docker_buildx_version = subprocess.run(["docker", "buildx", "version"]) | ||
| if docker_buildx_version.returncode: | ||
| raise RuntimeError("The docker buildx plugin must be installed") | ||
|
|
||
| args = ["docker", "buildx", "build", "--progress", "plain"] | ||
| args = [self.container_cli, "buildx", "build", "--progress", "plain"] | ||
| if load: | ||
| if push: | ||
| raise ValueError( | ||
|
|
@@ -171,14 +213,22 @@ def inspect_image(self, image): | |
| Return image configuration if it exists, otherwise None | ||
| """ | ||
| proc = subprocess.run( | ||
| ["docker", "image", "inspect", image], capture_output=True | ||
| [self.container_cli, "image", "inspect", image], capture_output=True | ||
| ) | ||
|
|
||
| if proc.returncode != 0: | ||
| return None | ||
|
|
||
| config = json.loads(proc.stdout.decode())[0] | ||
| return Image(tags=config["RepoTags"], config=config["Config"]) | ||
| tags = config["RepoTags"] | ||
| oci_image_configuration = config["Config"] | ||
|
|
||
| # WorkingDir is optional but docker always include it. | ||
| # https://github.com/containers/podman/discussions/27313 | ||
| if "WorkingDir" not in oci_image_configuration: | ||
| oci_image_configuration["WorkingDir"] = "" | ||
|
|
||
| return Image(tags=tags, config=oci_image_configuration) | ||
|
|
||
| @contextmanager | ||
| def docker_login(self, username, password, registry): | ||
|
|
@@ -200,7 +250,7 @@ def docker_login(self, username, password, registry): | |
| try: | ||
| subprocess.run( | ||
| [ | ||
| "docker", | ||
| self.container_cli, | ||
| "login", | ||
| "--username", | ||
| username, | ||
|
|
||
This file contains hidden or 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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.