tramp-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Tramp is operating on host filesystem instead of container filesystem


From: Camden Narzt
Subject: Tramp is operating on host filesystem instead of container filesystem
Date: Mon, 11 May 2020 21:28:08 -0600

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. The host is a Mac, though I don’t think that should make a difference here. Can anyone help me fix this?

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

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

(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))
    ad-do-it))

reply via email to

[Prev in Thread] Current Thread [Next in Thread]