tramp-devel
[Top][All Lists]
Advanced

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

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


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

I still have no workaround for this and have been forced to use vscode
for devcontainer integration sadly.

I was going to resort to just setting the path manually for this docker
container to
`/root/.cabal/bin:/root/.local/bin:/opt/ghc/9.4.2/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin`.

The problem with that is non-existent directories are removed. An
additional issue is that for some reason tramp doesn't have permissions
to `ls /root` but I can do so fine with docker:

```
~ $ docker exec -it  2b24658794d8 bash -i -c 'ls -larth /root'
total 36K
-rw-r--r-- 1 root root  570 Jan 31  2010 .bashrc
-rw-r--r-- 1 root root  148 Aug 17  2015 .profile~
drwxr-xr-x 3 root root 4.0K Aug 23  2022 .stack
drwxr-xr-x 1 root root 4.0K Mar 16 04:36 ..
-rw-r--r-- 1 root root  215 Mar 26 10:26 .profile
drwx------ 1 root root 4.0K Mar 26 10:26 .
-rw------- 1 root root 4.7K Mar 26 21:48 .bash_history
```

Another observation I had is that using the `-l` parameter to bash
overwrites the correct PATH variable already present in the
environmental variables. Here is what I mean.

With the login parameter that is used by default with tramp and docker
we get the incorrect PATH:

~ $ docker exec -it  2b24658794d8 bash -l -i -c 'echo $PATH'
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin


But if we don't use `-l` then we get the correct one:

~ $ docker exec -it  2b24658794d8 bash -i -c 'echo $PATH'
/root/.cabal/bin:/root/.local/bin:/opt/ghc/9.4.2/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

I thought this meant I could just do:

(add-to-list 'tramp-connection-properties
             (list (regexp-quote "/docker:")
                   "remote-shell-login" nil))

However then I get an error actually running the ghc executable and get
sent into some sort of sub sub shell:


~ $ cd /docker:root@2b2465:
/docker:root@2b2465:~ # which ghc
/docker:root@2b2465://opt/ghc/9.4.2/bin/ghc
/docker:root@2b2465:~ # ghc
sh: cd: /root/: Permission denied
///ee39fe935a84035afb87c3a91b677b7f#$

So it seems the login shell is needed for other things. And for some
reason permission is denied to `/root/`. Maybe for security reasons.

Regrettably, this security consciousness is incompatible with docker
images and containers that largely use root by default. It's not
typically very feasible to convert every container you use to be
rootless either sadly.

I'm kind of at a loss for what to do at this point.

I've spent many hours trying to understand the tramp code to even arrive
at this solution.

I say this only to present my actual experience report and vent about my
failures despite a good faith effort. I'm aware there
are likely more pressing priorities for the project and appreciate all
volunteer time and efforts though.

Thanks!

P.S. I further complicated things for myself at one point by using this
nefarious command to confuse myself:

`docker exec -it  2b24658794d8 bash -i -c "echo $PATH"`

Notice the double quotes which meant I was using echo inside of the
docker container to print my local PATH to maximally confuse myself 😅



reply via email to

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