tramp-devel
[Top][All Lists]
Advanced

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

tramp-container doesn't follow `ENV PATH` in docker file


From: ParetoOptimalDev
Subject: tramp-container doesn't follow `ENV PATH` in docker file
Date: Tue, 14 Mar 2023 19:11:36 -0500
User-agent: Gnus/5.13 (Gnus v5.13)

Hi, all. I'm having some issues with using docker container and have an
idea for improving it.

Firstly, I'm familiar with
https://www.gnu.org/software/emacs//manual/html_node/tramp/Remote-programs.html
and `tramp-own-remote-path`, but they aren't sufficient for seamlessly
dropping into a docker container and using binaries inside of it.

Here's an example with emacs 30 using `emacs -Q`. First the code:

```
(require 'tramp)
(message "")

(message "using the docker haskell image")
(message (concat "path should be: 
""/root/.cabal/bin:/root/.local/bin:/opt/ghc/9.4.2/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"))

(message "show that using tramp-own-remote-path isn't sufficient")
(let ((docker-container-id (string-trim (shell-command-to-string "docker run 
-it --rm --detach haskell"))))
  (let ((default-directory (concat "/docker:" docker-container-id ":"))
        (tramp-remote-path '(tramp-own-remote-path)))
        (message docker-container-id)
        (message (concat "path is: " (truncate-string-to-width 
(eshell-command-result "echo $PATH") 100)))))
```

Here are it's results:

```
using the docker haskell image
path should be: 
/root/.cabal/bin:/root/.local/bin:/opt/ghc/9.4.2/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
show that using tramp-own-remote-path isn’t sufficient
69ae6adb42d95fd9ebef5738218217d822ee2977956b61227b43eb8ccb1401d4
Tramp: Opening connection nil for 
69ae6adb42d95fd9ebef5738218217d822ee2977956b61227b43eb8ccb1401d4 using 
docker...done
path is: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
```

This means that when you:

- open eshell
- navigate to
- `/docker:69ae6adb42d95fd9ebef5738218217d822ee2977956b61227b43eb8ccb1401d4:`
- run `ghc`

You'll be met with an error that `ghc` doesn't exist in the Haskell
docker container.

It seems that the typical way for docker containers to specify PATH uses
`ENV PATH` so it seems good to support it (if that's not already
implemented).

I noticed when using docker inspect on the container that it contains
the PATH set by the docker file.

Perhaps tramp could simply use that for the docker container method?

Thanks.




reply via email to

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