diff --git a/python/ray/autoscaler/command_runner.py b/python/ray/autoscaler/command_runner.py index 1d1602708..1da2f8836 100644 --- a/python/ray/autoscaler/command_runner.py +++ b/python/ray/autoscaler/command_runner.py @@ -617,6 +617,10 @@ class DockerCommandRunner(SSHCommandRunner): f"mkdir -p {os.path.dirname(target.rstrip('/'))}") self.ssh_command_runner.run_rsync_up(source, target) if self._check_container_status(): + if os.path.isdir(source): + # Adding a "." means that docker copies the *contents* + # Without it, docker copies the source *into* the target + target += "/." self.ssh_command_runner.run("docker cp {} {}:{}".format( target, self.docker_name, self._docker_expand_user(protected_path))) @@ -627,6 +631,10 @@ class DockerCommandRunner(SSHCommandRunner): source = source.replace("/root", "/tmp/root") self.ssh_command_runner.run( f"mkdir -p {os.path.dirname(source.rstrip('/'))}") + if protected_path[-1] == "/": + protected_path += "." + # Adding a "." means that docker copies the *contents* + # Without it, docker copies the source *into* the target self.ssh_command_runner.run("docker cp {}:{} {}".format( self.docker_name, self._docker_expand_user(protected_path), source))