I'm using a slightly modified version of the usual docker tramp integration (below) which works fine to complete up to /docker:container_name: but where it goes wrong is it opens files on the host computer, and performs completion from the host file-system instead of in the container. Can anyone help me fix this?

(require 'tramp)
(setq tramp-verbose 10)

  '((tramp-login-program "docker")
    (tramp-login-args (("exec" "-it") ("%h") ("/bin/bash")))
    (tramp-remote-shell "/bin/bash")
    (tramp-remote-shell-args ("-i") ("-c"))

(defadvice tramp-completion-handle-file-name-all-completions
    (around dotemacs-completion-docker activate)
  "(tramp-completion-handle-file-name-all-completions \"\" \"/docker:\" returns
    a list of active Docker container names, followed by colons."
  (if (equal (ad-get-arg 1) "/docker:")
      (let* ((dockernames-raw (shell-command-to-string "/usr/local/bin/docker ps | awk '$NF != \"NAMES\" { print $NF \":\" }'"))
             (dockernames (cl-remove-if-not
                           #'(lambda (dockerline) (string-match ":$" dockerline))
                           (split-string dockernames-raw "\n"))))
        (setq ad-return-value dockernames))
  • 1
    This needs debugging. Ask on the Tramp mailing list, tramp-devel@gnu.org. – Michael Albinus May 10 '20 at 8:41

This was somehow ido-mode's fault. Disabling ido-mode in my emacs config fixed it. No idea why.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.