mirror of
https://github.com/wassname/ray.git
synced 2026-07-07 07:43:45 +08:00
[docker] Pull if image is not present (#13136)
This commit is contained in:
@@ -765,16 +765,20 @@ class DockerCommandRunner(CommandRunnerInterface):
|
||||
"~/ray_bootstrap_config.yaml", "~/ray_bootstrap_key.pem"
|
||||
]
|
||||
|
||||
image = self.docker_config.get("image")
|
||||
image = self.docker_config.get(
|
||||
f"{'head' if as_head else 'worker'}_image", image)
|
||||
specific_image = self.docker_config.get(
|
||||
f"{'head' if as_head else 'worker'}_image",
|
||||
self.docker_config.get("image"))
|
||||
|
||||
self._check_docker_installed()
|
||||
if self.docker_config.get("pull_before_run", True):
|
||||
assert image, "Image must be included in config if " + \
|
||||
assert specific_image, "Image must be included in config if " + \
|
||||
"pull_before_run is specified"
|
||||
self.run("docker pull {}".format(specific_image), run_env="host")
|
||||
else:
|
||||
|
||||
self.run("docker pull {}".format(image), run_env="host")
|
||||
self.run(
|
||||
f"docker image inspect {specific_image} 1> /dev/null 2>&1 || "
|
||||
f"docker pull {specific_image}")
|
||||
|
||||
# Bootstrap files cannot be bind mounted because docker opens the
|
||||
# underlying inode. When the file is switched, docker becomes outdated.
|
||||
@@ -788,14 +792,14 @@ class DockerCommandRunner(CommandRunnerInterface):
|
||||
requires_re_init = False
|
||||
if container_running:
|
||||
requires_re_init = self._check_if_container_restart_is_needed(
|
||||
image, cleaned_bind_mounts)
|
||||
specific_image, cleaned_bind_mounts)
|
||||
if requires_re_init:
|
||||
self.run(f"docker stop {self.container_name}", run_env="host")
|
||||
|
||||
if (not container_running) or requires_re_init:
|
||||
# Get home directory
|
||||
image_env = self.ssh_command_runner.run(
|
||||
"docker inspect -f '{{json .Config.Env}}' " + image,
|
||||
"docker inspect -f '{{json .Config.Env}}' " + specific_image,
|
||||
with_output=True).decode().strip()
|
||||
home_directory = "/root"
|
||||
for env_var in json.loads(image_env):
|
||||
@@ -804,8 +808,8 @@ class DockerCommandRunner(CommandRunnerInterface):
|
||||
break
|
||||
|
||||
start_command = docker_start_cmds(
|
||||
self.ssh_command_runner.ssh_user, image, cleaned_bind_mounts,
|
||||
self.container_name,
|
||||
self.ssh_command_runner.ssh_user, specific_image,
|
||||
cleaned_bind_mounts, self.container_name,
|
||||
self.docker_config.get(
|
||||
"run_options", []) + self.docker_config.get(
|
||||
f"{'head' if as_head else 'worker'}_run_options", []) +
|
||||
|
||||
Reference in New Issue
Block a user