From: Michael Albinus via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
To: Artem Smushkov <artyom.smushkov@gmail.com>
Cc: 74219@debbugs.gnu.org
Subject: bug#74219: 29.4; TRAMP uses the same ad-hoc proxy for every docker container on remote hosts
Date: Thu, 07 Nov 2024 19:48:35 +0100 [thread overview]
Message-ID: <87msiaev7g.fsf@gmx.de> (raw)
In-Reply-To: <QGNHMS.49S6LX9JK1UB2@gmail.com> (Artem Smushkov's message of "Tue, 05 Nov 2024 19:34:02 +0200")
Artem Smushkov <artyom.smushkov@gmail.com> writes:
Hi Artem,
your subject isn't correct. True is "Tramp uses the same ad-hoc proxy
for every docker container with the same name on remote hosts".
> I need to access some number of similarly named docker containers on
> different remote hosts. For example I run
>
> cd "/ssh:host1|docker:container_name:/"
>
> in eshell, run some commands there, then I may run
>
> cd "/ssh:host2|docker:container_name:/"
>
> and run some commands there, etc. Emacs lisp functions (like cd, ls,
> find-file, dired, etc) work as expected, but when I run some
> executable
> there (bash, python, etc) it always connects to the same host no
> matter
> what I specified in "cd" command previously. The workaround to make
> things work is to run
>
> (setq tramp-default-proxies-alist nil)
>
> before switching to different host.
That's not possible with Tramp. Not with the current design. The proxy
definitions are kept internally, and they apply in reverse order of
their appearance in the remote file names.
After you have accessed "/ssh:host1|docker:container_name:", Tramp
caches the information, that the remote host "/docker:container_name:"
is reachable via "/ssh:host1:". You can even use the short form
"/docker:container_name:" now, and Tramp remembers the hops.
When you give a different multi-hop remote file name, like
"/ssh:host2|docker:container_name:", Tramp parses from the end, and it
detects, that it should use the hop "/ssh:host1:" as proxy. No further
check. That's why you see the observed behavior.
One could argue that this is an error. I'm not so sure, it is rather a
consequence of the design. Proxy declarations were introduced in Tramp by
means of configuring tramp-default-proxies-alist. This list is organized
to detect proxy hops by starting with the final, target host, and adding
the proxies to pass in order to reach that target. People found the
configuration of that user option too complex, and that's why ad-hoc
multi-hop remote file names have been added years later. But the
principle has been kept.
One possible mitigation is to set tramp-default-proxies-alist to nil
before using different ad-hoc multi-hop file names. However, this is too
drastic in my mind, because you will lose *all* specifications there,
even for other multi-hops.
Another, and better, solution is to use different target names. Do you
need to give the containers the very same name "container_name" on both
"host1" and "host2"? If you would give them different names, the problem
doesn't exist.
Best regards, Michael.
next prev parent reply other threads:[~2024-11-07 18:48 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-05 17:34 bug#74219: 29.4; TRAMP uses the same ad-hoc proxy for every docker container on remote hosts Artem Smushkov
2024-11-07 18:48 ` Michael Albinus via Bug reports for GNU Emacs, the Swiss army knife of text editors [this message]
2024-11-09 9:40 ` Michael Albinus via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-11-11 10:51 ` Artem Smushkov
[not found] ` <CAM9Mw788gEhN+kTv1pS1kLknV1fJgxSCoXK+488sgococXEobQ@mail.gmail.com>
2024-11-29 12:27 ` Michael Albinus via Bug reports for GNU Emacs, the Swiss army knife of text editors
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87msiaev7g.fsf@gmx.de \
--to=bug-gnu-emacs@gnu.org \
--cc=74219@debbugs.gnu.org \
--cc=artyom.smushkov@gmail.com \
--cc=michael.albinus@gmx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).