Skip to content

Commit

Permalink
Merge pull request #292 from rjra2611/feature-pull-amd-image-for-arm-…
Browse files Browse the repository at this point in the history
…users

Feature pull `AMD` image if not a custom image
  • Loading branch information
Martin-Molinero authored Mar 6, 2023
2 parents 70d8e48 + c612e77 commit c172d4b
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lean/components/docker/docker_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,17 @@ def pull_image(self, image: DockerImage) -> None:
return

self._logger.info(f"Pulling {image}...")

# We cannot really use docker_client.images.pull() here as it doesn't let us log the progress
# Downloading multiple gigabytes without showing progress does not provide good developer experience
# Since the pull command is the same on Windows, macOS and Linux we can safely use a system call
if which("docker") is not None:
process = run(["docker", "image", "pull", str(image)])
process = run(["docker", "image", "pull", str(image), "--platform=linux/amd64"])
if process.returncode != 0:
raise RuntimeError(
f"Something went wrong while pulling {image}, see the logs above for more information")
else:
self._get_docker_client().images.pull(image.name, image.tag)
self._get_docker_client().images.pull(image.name, image.tag, platform="linux/amd64")

def run_image(self, image: DockerImage, **kwargs) -> bool:
"""Runs a Docker image. If the image is not available locally it will be pulled first.
Expand Down

0 comments on commit c172d4b

Please sign in to comment.