Subject: bug#69085: 29.2; Tramp: Extend tramp-make-copy-program-file-name via tramp-methods

From: Sean Devlin <[email-masked]>
Date: Fri, 16 Feb 2024 12:51:17 -0500

Hi Michael,

>> I think what is needed is some way for the tramp-docker method to
>> specify the format for remote paths in the OOB copy command, since
>> tramp-make-copy-program-file-name will include the user if it is
>> specified in the connection.
>> 
>> One method might be to add a key to tramp-methods that lets you
>> specify the format similar to tramp-login-args and tramp-copy-args:
> 
> I've tried another approach. In Tramp 2.7, I've added a new method
> "dockercp" which doesn't use the user at all, and which adds
> tramp-copy-program and tramp-copy-args.
> 
> Do you have a chance to install Tramp from its repository like
> 
> --8<---------------cut here---------------start------------->8---
> # git clone https://git.savannah.gnu.org/git/tramp.git
> --8<---------------cut here---------------end--------------->8---
> 
> Then pls modify tramp-container.el with the appended patch. After that,
> you should be able to access your docker container like
> /dockercp:CONTAINER:/path/to/file. And if you copy large files, "docker
> cp" will be applied.

The patch does work as described, but it doesn’t integrate well with typical
workflows.

For example, I’m likely to start a session from Eshell or Dired browsing
around the remote. At this point, I may not realize I will need to copy files to
or from the remote. I would start with the normal “docker” method, because
I usually want to have an explicit user for my connection, so that I can run
programs as the user.

Now, suppose I do need to copy a file back to the host. I need to:

1. Check the size of the file. If it’s small, I can copy it normally using the
inline method.

2. If the file is big, I now need to switch to the other method, so I open a new
connection to the same container under the “dockercp” method.

3. I also need to find my way back to the same directory. This may be a
minor nuisance, but for example it won’t show up in the Recentf list, since
Emacs and Tramp and Recentf will not know that
/docker:user@container:/path/to/dir and /dockercp:container:/path/to/dir are
related.

4. Finally, I copy the file.

So while this approach does work for Docker containers, it adds some
ergonomic overhead for the user making it inconvenient to use.

Thanks,

Sean